Bug 1168446: Remove |Disconnect| from BlueZ's |BluetoothSocket|, r=shuang
authorThomas Zimmermann <tdz@users.sourceforge.net>
Mon, 01 Jun 2015 10:42:29 +0200
changeset 246487 543d15b145753962fb4a535150e816234e4c60a2
parent 246398 8c0d16b24adcd738f4e35a308506b419eb14e4ed
child 246488 fdbfea9d6c0cd18f45cb792835264b60a8c39fc4
push id28833
push userkwierso@gmail.com
push dateMon, 01 Jun 2015 19:19:37 +0000
treeherdermozilla-central@a2d68ee6628c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs1168446
milestone41.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 1168446: Remove |Disconnect| from BlueZ's |BluetoothSocket|, r=shuang The method |BluetoothSocket::Disconnect| is just a wrapper around |Close|. This patch replaces all invocations of |Disconnect| with |Close| and removes the method.
dom/bluetooth/bluez/BluetoothHfpManager.cpp
dom/bluetooth/bluez/BluetoothOppManager.cpp
dom/bluetooth/bluez/BluetoothSocket.h
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -1145,22 +1145,22 @@ BluetoothHfpManager::Connect(const nsASt
 
   if (NS_FAILED(bs->GetServiceChannel(aDeviceAddress, uuid, this))) {
     aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
     return;
   }
 
   // Stop listening because currently we only support one connection at a time.
   if (mHandsfreeSocket) {
-    mHandsfreeSocket->Disconnect();
+    mHandsfreeSocket->Close();
     mHandsfreeSocket = nullptr;
   }
 
   if (mHeadsetSocket) {
-    mHeadsetSocket->Disconnect();
+    mHeadsetSocket->Close();
     mHeadsetSocket = nullptr;
   }
 
   mController = aController;
   mSocket =
     new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
 }
 
@@ -1197,17 +1197,17 @@ BluetoothHfpManager::Listen()
     mHeadsetSocket =
       new BluetoothSocket(this, BluetoothSocketType::RFCOMM, true, true);
 
     if (!mHeadsetSocket->Listen(
           NS_LITERAL_STRING("Headset Audio Gateway"),
           kHeadsetAG,
           BluetoothReservedChannels::CHANNEL_HEADSET_AG)) {
       BT_WARNING("[HSP] Can't listen on RFCOMM socket!");
-      mHandsfreeSocket->Disconnect();
+      mHandsfreeSocket->Close();
       mHandsfreeSocket = nullptr;
       mHeadsetSocket = nullptr;
       return false;
     }
   }
 
   return true;
 }
@@ -1222,17 +1222,17 @@ BluetoothHfpManager::Disconnect(Bluetoot
       aController->NotifyCompletion(NS_LITERAL_STRING(ERR_ALREADY_DISCONNECTED));
     }
     return;
   }
 
   MOZ_ASSERT(!mController);
 
   mController = aController;
-  mSocket->Disconnect();
+  mSocket->Close();
 }
 
 #ifdef MOZ_B2G_RIL
 void
 BluetoothHfpManager::SendCCWA(const nsAString& aNumber, int aType)
 {
   if (mCCWA) {
     nsAutoCString ccwaMsg("+CCWA: \"");
@@ -1791,24 +1791,24 @@ BluetoothHfpManager::OnSocketConnectSucc
    * connections, we do nothing since sockets have been already handled in
    * function Connect().
    */
   if (aSocket == mHandsfreeSocket) {
     MOZ_ASSERT(!mSocket);
     mIsHsp = false;
     mHandsfreeSocket.swap(mSocket);
 
-    mHeadsetSocket->Disconnect();
+    mHeadsetSocket->Close();
     mHeadsetSocket = nullptr;
   } else if (aSocket == mHeadsetSocket) {
     MOZ_ASSERT(!mSocket);
     mIsHsp = true;
     mHeadsetSocket.swap(mSocket);
 
-    mHandsfreeSocket->Disconnect();
+    mHandsfreeSocket->Close();
     mHandsfreeSocket = nullptr;
   }
 
 #ifdef MOZ_B2G_RIL
   // Enumerate current calls
   mListener->EnumerateCalls();
 
   mFirstCKPD = true;
@@ -1985,34 +1985,34 @@ BluetoothHfpManager::ConnectSco(Bluetoot
   // established before we start to set up SCO (synchronous connection).
   if (!mSlcConnected && !mIsHsp) {
     mConnectScoRequest = true;
     BT_WARNING("ConnectSco called before Service Level Connection established");
     return false;
   }
 
   // Stop listening
-  mScoSocket->Disconnect();
+  mScoSocket->Close();
 
   mScoSocket->Connect(mDeviceAddress, kUnknownService, -1);
   mScoSocketStatus = mScoSocket->GetConnectionStatus();
 
   mScoRunnable = aRunnable;
   return true;
 }
 
 bool
 BluetoothHfpManager::DisconnectSco()
 {
   if (!IsScoConnected()) {
     BT_WARNING("SCO has been already disconnected.");
     return false;
   }
 
-  mScoSocket->Disconnect();
+  mScoSocket->Close();
   return true;
 }
 
 bool
 BluetoothHfpManager::ListenSco()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -2022,17 +2022,17 @@ BluetoothHfpManager::ListenSco()
   }
 
   if (mScoSocket->GetConnectionStatus() ==
       SocketConnectionStatus::SOCKET_LISTENING) {
     BT_WARNING("SCO socket has been already listening");
     return false;
   }
 
-  mScoSocket->Disconnect();
+  mScoSocket->Close();
 
   if (!mScoSocket->Listen(NS_LITERAL_STRING("Handsfree Audio Gateway SCO"),
                           kUnknownService, -1)) {
     BT_WARNING("Can't listen on SCO socket!");
     return false;
   }
 
   mScoSocketStatus = mScoSocket->GetConnectionStatus();
--- a/dom/bluetooth/bluez/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothOppManager.cpp
@@ -180,17 +180,17 @@ public:
   }
 
   void Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (mSocket->GetConnectionStatus() ==
         SocketConnectionStatus::SOCKET_CONNECTED) {
-      mSocket->Disconnect();
+      mSocket->Close();
     }
   }
 
 private:
   nsRefPtr<BluetoothSocket> mSocket;
 };
 
 BluetoothOppManager::BluetoothOppManager() : mConnected(false)
@@ -264,22 +264,22 @@ BluetoothOppManager::Get()
 
 void
 BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Stop listening because currently we only support one connection at a time.
   if (mRfcommSocket) {
-    mRfcommSocket->Disconnect();
+    mRfcommSocket->Close();
     mRfcommSocket = nullptr;
   }
 
   if (mL2capSocket) {
-    mL2capSocket->Disconnect();
+    mL2capSocket->Close();
     mL2capSocket = nullptr;
   }
 
   mIsServer = false;
 
   BluetoothService* bs = BluetoothService::Get();
   if (!bs || sInShutdown || mSocket) {
     OnSocketConnectError(mSocket);
@@ -335,17 +335,17 @@ BluetoothOppManager::Listen()
   if (!mL2capSocket) {
     mL2capSocket =
       new BluetoothSocket(this, BluetoothSocketType::EL2CAP, true, true);
 
     if (!mL2capSocket->Listen(NS_LITERAL_STRING("OBEX Object Push"),
                               kObexObjectPush,
                               BluetoothReservedChannels::CHANNEL_OPUSH_L2CAP)) {
       BT_WARNING("[OPP] Can't listen on L2CAP socket!");
-      mRfcommSocket->Disconnect();
+      mRfcommSocket->Close();
       mRfcommSocket = nullptr;
       mL2capSocket = nullptr;
       return false;
     }
   }
 
   mIsServer = true;
 
@@ -1528,23 +1528,23 @@ BluetoothOppManager::OnSocketConnectSucc
    * socket because currently only one file-transfer session is allowed. After
    * that, we need to make sure that both server socket would be nulled out.
    * As for outbound connections, we just notify the controller that it's done.
    */
   if (aSocket == mRfcommSocket) {
     MOZ_ASSERT(!mSocket);
     mRfcommSocket.swap(mSocket);
 
-    mL2capSocket->Disconnect();
+    mL2capSocket->Close();
     mL2capSocket = nullptr;
   } else if (aSocket == mL2capSocket) {
     MOZ_ASSERT(!mSocket);
     mL2capSocket.swap(mSocket);
 
-    mRfcommSocket->Disconnect();
+    mRfcommSocket->Close();
     mRfcommSocket = nullptr;
   }
 
   // Cache device address since we can't get socket address when a remote
   // device disconnect with us.
   mSocket->GetAddress(mConnectedDeviceAddress);
 
   // Start sending file if we connect as a client
@@ -1613,17 +1613,17 @@ BluetoothOppManager::OnSocketDisconnect(
     Listen();
   }
 }
 
 void
 BluetoothOppManager::Disconnect(BluetoothProfileController* aController)
 {
   if (mSocket) {
-    mSocket->Disconnect();
+    mSocket->Close();
   } else {
     BT_WARNING("%s: No ongoing file transfer to stop", __FUNCTION__);
   }
 }
 
 void
 BluetoothOppManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
                                          const nsAString& aServiceUuid,
--- a/dom/bluetooth/bluez/BluetoothSocket.h
+++ b/dom/bluetooth/bluez/BluetoothSocket.h
@@ -31,20 +31,16 @@ public:
   ~BluetoothSocket();
 
   bool Connect(const nsAString& aDeviceAddress,
                const BluetoothUuid& aServiceUuid,
                int aChannel);
   bool Listen(const nsAString& aServiceName,
               const BluetoothUuid& aServiceUuid,
               int aChannel);
-  inline void Disconnect()
-  {
-    Close();
-  }
 
   inline void GetAddress(nsAString& aDeviceAddress)
   {
     GetSocketAddr(aDeviceAddress);
   }
 
   /**
    * Method to be called whenever data is received. This is only called on the