Bug 851046: Patch 9 - Small misc fixes; r=mrbkap
authorEric Chou <echou@mozilla.com>
Thu, 04 Apr 2013 17:25:45 -0700
changeset 138677 9ba6b7c64335c7457684f40ee99d3909b47f7110
parent 138676 76f4a2ff72d92775e31e4e0538a23b2010f8a02a
child 138678 1576f07a1d8b72e27079a884840b6787f1d82890
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs851046
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 851046: Patch 9 - Small misc fixes; r=mrbkap
dom/bluetooth/BluetoothHfpManager.cpp
dom/bluetooth/BluetoothHfpManager.h
dom/bluetooth/BluetoothOppManager.cpp
dom/bluetooth/BluetoothOppManager.h
dom/bluetooth/BluetoothScoManager.cpp
dom/bluetooth/BluetoothScoManager.h
--- a/dom/bluetooth/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/BluetoothHfpManager.cpp
@@ -392,17 +392,17 @@ bool
 BluetoothHfpManager::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mSocket = new BluetoothSocket(this,
                                 BluetoothSocketType::RFCOMM,
                                 true,
                                 true);
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
 
   sHfpObserver = new BluetoothHfpManagerObserver();
   if (!sHfpObserver->Init()) {
     NS_WARNING("Cannot set up Hfp Observers!");
   }
 
   mListener = new BluetoothTelephonyListener();
   if (!mListener->StartListening()) {
@@ -456,17 +456,16 @@ BluetoothHfpManager::Get()
   // If we're in shutdown, don't create a new instance
   if (gInShutdown) {
     NS_WARNING("BluetoothHfpManager can't be created during shutdown");
     return nullptr;
   }
 
   // Create new instance, register, return
   BluetoothHfpManager* manager = new BluetoothHfpManager();
-  NS_ENSURE_TRUE(manager, nullptr);
   NS_ENSURE_TRUE(manager->Init(), nullptr);
 
   gBluetoothHfpManager = manager;
   return gBluetoothHfpManager;
 }
 
 void
 BluetoothHfpManager::NotifySettings()
@@ -997,17 +996,17 @@ BluetoothHfpManager::Listen()
 
   mSocket->Disconnect();
 
   if (!mSocket->Listen(BluetoothReservedChannels::CHANNEL_HANDSFREE_AG)) {
     NS_WARNING("[HFP] Can't listen on socket!");
     return false;
   }
 
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
   return true;
 }
 
 void
 BluetoothHfpManager::Disconnect()
 {
   mSocket->Disconnect();
 }
@@ -1022,17 +1021,17 @@ BluetoothHfpManager::SendLine(const char
   msg.AppendLiteral(kHfpCrlf);
 
   return mSocket->SendSocketData(msg);
 }
 
 bool
 BluetoothHfpManager::SendCommand(const char* aCommand, uint8_t aValue)
 {
-  if (mSocketStatus != SocketConnectionStatus::SOCKET_CONNECTED) {
+  if (mPrevSocketStatus != SocketConnectionStatus::SOCKET_CONNECTED) {
     return false;
   }
 
   nsAutoCString message;
   int value = aValue;
   message += aCommand;
 
   if (!strcmp(aCommand, "+CIEV: ")) {
@@ -1322,17 +1321,17 @@ BluetoothHfpManager::OnConnectSuccess(Bl
     DispatchBluetoothReply(mRunnable, v, errorStr);
 
     mRunnable.forget();
   }
 
   // Cache device path for NotifySettings() since we can't get socket address
   // when a headset disconnect with us
   mSocket->GetAddress(mDevicePath);
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
 
   NotifySettings();
 }
 
 void
 BluetoothHfpManager::OnConnectError(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket == mSocket);
@@ -1353,20 +1352,20 @@ BluetoothHfpManager::OnConnectError(Blue
 
 void
 BluetoothHfpManager::OnDisconnect(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket == mSocket);
 
   // When we close a connected socket, then restart listening again and
   // notify Settings app.
-  if (mSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
+  if (mPrevSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
     Listen();
     NotifySettings();
-  } else if (mSocketStatus == SocketConnectionStatus::SOCKET_CONNECTING) {
+  } else if (mPrevSocketStatus == SocketConnectionStatus::SOCKET_CONNECTING) {
     NS_WARNING("BluetoothHfpManager got unexpected socket status!");
   }
 
   CloseScoSocket();
   Reset();
 }
 
 bool
--- a/dom/bluetooth/BluetoothHfpManager.h
+++ b/dom/bluetooth/BluetoothHfpManager.h
@@ -109,17 +109,17 @@ private:
   bool mCLIP;
   bool mCMEE;
   bool mCMER;
   int mNetworkSelectionMode;
   bool mReceiveVgsFlag;
   nsString mDevicePath;
   nsString mMsisdn;
   nsString mOperatorName;
-  enum SocketConnectionStatus mSocketStatus;
+  SocketConnectionStatus mPrevSocketStatus;
 
   nsTArray<Call> mCurrentCallArray;
   nsAutoPtr<BluetoothTelephonyListener> mListener;
   nsRefPtr<BluetoothReplyRunnable> mRunnable;
   nsRefPtr<BluetoothSocket> mSocket;
 };
 
 END_BLUETOOTH_NAMESPACE
--- a/dom/bluetooth/BluetoothOppManager.cpp
+++ b/dom/bluetooth/BluetoothOppManager.cpp
@@ -230,17 +230,17 @@ BluetoothOppManager::BluetoothOppManager
                                            , mWaitingForConfirmationFlag(false)
 {
   mConnectedDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
 
   mSocket = new BluetoothSocket(this,
                                 BluetoothSocketType::RFCOMM,
                                 true,
                                 true);
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
 }
 
 BluetoothOppManager::~BluetoothOppManager()
 {
 }
 
 //static
 BluetoothOppManager*
@@ -322,17 +322,17 @@ BluetoothOppManager::Listen()
 
   Disconnect();
 
   if (!mSocket->Listen(BluetoothReservedChannels::CHANNEL_OPUSH)) {
     NS_WARNING("[OPP] Can't listen on socket!");
     return false;
   }
 
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
   return true;
 }
 
 bool
 BluetoothOppManager::SendFile(BlobParent* aActor)
 {
   if (mBlob) {
     // Means there's a sending process. Reply error.
@@ -1314,17 +1314,17 @@ BluetoothOppManager::OnConnectSuccess(Bl
       NS_WARNING("Failed to dispatch to main thread!");
     }
     mRunnable.forget();
   }
 
   // Cache device address since we can't get socket address when a remote
   // device disconnect with us.
   mSocket->GetAddress(mConnectedDeviceAddress);
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
 }
 
 void
 BluetoothOppManager::OnConnectError(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket == mSocket);
 
   if (mRunnable) {
@@ -1334,33 +1334,33 @@ BluetoothOppManager::OnConnectError(Blue
     mRunnable->SetReply(reply);
     if (NS_FAILED(NS_DispatchToMainThread(mRunnable))) {
       NS_WARNING("Failed to dispatch to main thread!");
     }
     mRunnable.forget();
   }
 
   mSocket->Disconnect();
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
   Listen();
 }
 
 void
 BluetoothOppManager::OnDisconnect(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket == mSocket);
 
   /**
    * It is valid for a bluetooth device which is transfering file via OPP
    * closing socket without sending OBEX disconnect request first. So we
    * delete the broken file when we failed to receive a file from the remote,
    * and notify the transfer has been completed (but failed). We also call
    * AfterOppDisconnected here to ensure all variables will be cleaned.
    */
-  if (mSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
+  if (mPrevSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
     if (mTransferMode) {
       if (!mSuccessFlag) {
         DeleteReceivedFile();
       } else if (mDsFile) {
         nsString data;
         CopyASCIItoUTF16("modified", data);
 
         nsCOMPtr<nsIObserverService> obs =
@@ -1371,16 +1371,16 @@ BluetoothOppManager::OnDisconnect(Blueto
       }
     }
 
     if (!mSuccessFlag) {
       FileTransferComplete();
     }
 
     Listen();
-  } else if (mSocketStatus == SocketConnectionStatus::SOCKET_CONNECTING) {
+  } else if (mPrevSocketStatus == SocketConnectionStatus::SOCKET_CONNECTING) {
     NS_WARNING("BluetoothOppManager got unexpected socket status!");
   }
 
   AfterOppDisconnected();
   mConnectedDeviceAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE);
   mSuccessFlag = false;
 }
--- a/dom/bluetooth/BluetoothOppManager.h
+++ b/dom/bluetooth/BluetoothOppManager.h
@@ -101,17 +101,17 @@ private:
   void AfterFirstPut();
   void AfterOppDisconnected();
   void ValidateFileName();
   bool IsReservedChar(PRUnichar c);
 
   /**
    * RFCOMM socket status.
    */
-  enum mozilla::ipc::SocketConnectionStatus mSocketStatus;
+  mozilla::ipc::SocketConnectionStatus mPrevSocketStatus;
 
   /**
    * OBEX session status.
    * Set when OBEX session is established.
    */
   bool mConnected;
   nsString mConnectedDeviceAddress;
 
--- a/dom/bluetooth/BluetoothScoManager.cpp
+++ b/dom/bluetooth/BluetoothScoManager.cpp
@@ -119,17 +119,17 @@ BluetoothScoManager::BluetoothScoManager
 
 bool
 BluetoothScoManager::Init()
 {
   mSocket = new BluetoothSocket(this,
                                 BluetoothSocketType::SCO,
                                 true,
                                 false);
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
 
   sScoObserver = new BluetoothScoManagerObserver();
   if (!sScoObserver->Init()) {
     NS_WARNING("Cannot set up SCO observers!");
   }
   return true;
 }
 
@@ -159,17 +159,16 @@ BluetoothScoManager::Get()
   // If we're in shutdown, don't create a new instance
   if (gInShutdown) {
     NS_WARNING("BluetoothScoManager can't be created during shutdown");
     return nullptr;
   }
 
   // Create new instance, register, return
   BluetoothScoManager* manager = new BluetoothScoManager();
-  NS_ENSURE_TRUE(manager, nullptr);
   NS_ENSURE_TRUE(manager->Init(), nullptr);
 
   gBluetoothScoManager = manager;
   return gBluetoothScoManager;
 }
 
 // Virtual function of class SocketConsumer
 void
@@ -240,17 +239,17 @@ BluetoothScoManager::Listen()
 
   mSocket->Disconnect();
 
   if (!mSocket->Listen(-1)) {
     NS_WARNING("[SCO] Can't listen on socket!");
     return false;
   }
 
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
   return true;
 }
 
 void
 BluetoothScoManager::Disconnect()
 {
   mSocket->Disconnect();
 }
@@ -259,33 +258,33 @@ void
 BluetoothScoManager::OnConnectSuccess(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket == mSocket);
 
   nsString address;
   mSocket->GetAddress(address);
   NotifyAudioManager(address);
 
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
 }
 
 void
 BluetoothScoManager::OnConnectError(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket == mSocket);
 
   mSocket->Disconnect();
-  mSocketStatus = mSocket->GetConnectionStatus();
+  mPrevSocketStatus = mSocket->GetConnectionStatus();
   Listen();
 }
 
 void
 BluetoothScoManager::OnDisconnect(BluetoothSocket* aSocket)
 {
   MOZ_ASSERT(aSocket == mSocket);
 
-  if (mSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
+  if (mPrevSocketStatus == SocketConnectionStatus::SOCKET_CONNECTED) {
     Listen();
 
     nsString address = NS_LITERAL_STRING("");
     NotifyAudioManager(address);
   }
 }
--- a/dom/bluetooth/BluetoothScoManager.h
+++ b/dom/bluetooth/BluetoothScoManager.h
@@ -37,15 +37,15 @@ public:
 private:
   friend class BluetoothScoManagerObserver;
   BluetoothScoManager();
   bool Init();
   void Cleanup();
   nsresult HandleShutdown();
   void NotifyAudioManager(const nsAString& aAddress);
 
-  enum SocketConnectionStatus mSocketStatus;
+  SocketConnectionStatus mPrevSocketStatus;
   nsRefPtr<BluetoothSocket> mSocket;
 };
 
 END_BLUETOOTH_NAMESPACE
 
 #endif