Bug 1164425: Rename |SocketBase::CloseSocket| to |SocketBase::Close|, r=kmachulis
☠☠ backed out by bfa38d84133c ☠ ☠
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 20 May 2015 09:54:27 +0200
changeset 275315 1e93024c9fec38aec9b1be669e7e5b329baa492a
parent 275314 28474b6ce2543baff6d17c78543d396500320c9a
child 275316 2fd186d1a2888f414a12b7f541cbb7454a813698
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmachulis
bugs1164425
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 1164425: Rename |SocketBase::CloseSocket| to |SocketBase::Close|, r=kmachulis
dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
dom/bluetooth/bluedroid/BluetoothOppManager.cpp
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/bluedroid/BluetoothSocket.h
dom/bluetooth/bluez/BluetoothSocket.cpp
dom/bluetooth/bluez/BluetoothSocket.h
ipc/bluetooth/BluetoothDaemonConnection.cpp
ipc/bluetooth/BluetoothDaemonConnection.h
ipc/unixsocket/ListenSocket.cpp
ipc/unixsocket/ListenSocket.h
ipc/unixsocket/SocketBase.cpp
ipc/unixsocket/SocketBase.h
ipc/unixsocket/StreamSocket.cpp
ipc/unixsocket/StreamSocket.h
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
@@ -1906,17 +1906,17 @@ BluetoothDaemonInterface::OnConnectSucce
       break;
     case CMD_CHANNEL:
       // Init, step 3: Listen for notification channel...
       if (!mNtfChannel) {
         mNtfChannel = new BluetoothDaemonChannel(this, NTF_CHANNEL, mProtocol);
       } else if (
         NS_WARN_IF(mNtfChannel->GetConnectionStatus() == SOCKET_CONNECTED)) {
         /* Notification channel should not be open; let's close it. */
-        mNtfChannel->CloseSocket();
+        mNtfChannel->Close();
       }
       if (!mListenSocket->Listen(mNtfChannel)) {
         OnConnectError(NTF_CHANNEL);
       }
       break;
     case NTF_CHANNEL: {
         nsRefPtr<BluetoothResultHandler> res = mResultHandlerQ.ElementAt(0);
         mResultHandlerQ.RemoveElementAt(0);
@@ -1937,17 +1937,17 @@ void
 BluetoothDaemonInterface::OnConnectError(enum Channel aChannel)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!mResultHandlerQ.IsEmpty());
 
   switch (aChannel) {
     case NTF_CHANNEL:
       // Close command channel
-      mCmdChannel->CloseSocket();
+      mCmdChannel->Close();
     case CMD_CHANNEL:
       // Stop daemon and close listen socket
       unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd"));
       mListenSocket->Close();
     case LISTEN_SOCKET:
       if (!mResultHandlerQ.IsEmpty()) {
         // Signal error to caller
         nsRefPtr<BluetoothResultHandler> res = mResultHandlerQ.ElementAt(0);
@@ -2115,17 +2115,17 @@ BluetoothDaemonInterface::Init(
 
   // Init, step 1: Listen for command channel... */
 
   if (!mCmdChannel) {
     mCmdChannel = new BluetoothDaemonChannel(this, CMD_CHANNEL, mProtocol);
   } else if (
     NS_WARN_IF(mCmdChannel->GetConnectionStatus() == SOCKET_CONNECTED)) {
     // Command channel should not be open; let's close it.
-    mCmdChannel->CloseSocket();
+    mCmdChannel->Close();
   }
 
   // The listen socket's name is generated with a random postfix. This
   // avoids naming collisions if we still have a listen socket from a
   // previously failed cleanup. It also makes it hard for malicious
   // external programs to capture the socket name or connect before
   // the daemon can do so. If no random postfix can be generated, we
   // simply use the base name as-is.
@@ -2177,17 +2177,17 @@ private:
     MOZ_ASSERT(mInterface->mProtocol);
 
     if (!mUnregisteredCoreModule) {
       mUnregisteredCoreModule = true;
       // Cleanup, step 2: Unregister Core module
       mInterface->mProtocol->UnregisterModuleCmd(0x01, this);
     } else {
       // Cleanup, step 3: Close command channel
-      mInterface->mCmdChannel->CloseSocket();
+      mInterface->mCmdChannel->Close();
     }
   }
 
   BluetoothDaemonInterface* mInterface;
   bool mUnregisteredCoreModule;
 };
 
 /*
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
@@ -178,17 +178,17 @@ public:
   CloseSocketTask(BluetoothSocket* aSocket) : mSocket(aSocket)
   {
     MOZ_ASSERT(aSocket);
   }
 
   void Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
-    mSocket->CloseSocket();
+    mSocket->Close();
   }
 
 private:
   nsRefPtr<BluetoothSocket> mSocket;
 };
 
 BluetoothOppManager::BluetoothOppManager() : mConnected(false)
                                            , mRemoteObexVersion(0)
@@ -277,17 +277,17 @@ 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 (mServerSocket) {
-    mServerSocket->CloseSocket();
+    mServerSocket->Close();
     mServerSocket = nullptr;
   }
 
   mIsServer = false;
 
   BluetoothService* bs = BluetoothService::Get();
   if (!bs || sInShutdown || mSocket) {
     OnSocketConnectError(mSocket);
@@ -347,17 +347,17 @@ BluetoothOppManager::Listen()
   }
 
   /**
    * Restart server socket since its underlying fd becomes invalid when
    * BT stops; otherwise no more read events would be received even if
    * BT restarts.
    */
   if (mServerSocket) {
-    mServerSocket->CloseSocket();
+    mServerSocket->Close();
     mServerSocket = nullptr;
   }
 
   mServerSocket =
     new BluetoothSocket(this, BluetoothSocketType::RFCOMM, false, true);
 
   if (!mServerSocket->ListenSocket(NS_LITERAL_STRING("OBEX Object Push"),
                                    kObexObjectPush,
@@ -1547,17 +1547,17 @@ BluetoothOppManager::OnSocketDisconnect(
     Listen();
   }
 }
 
 void
 BluetoothOppManager::Disconnect(BluetoothProfileController* aController)
 {
   if (mSocket) {
-    mSocket->CloseSocket();
+    mSocket->Close();
   } else {
     BT_WARNING("%s: No ongoing file transfer to stop", __FUNCTION__);
   }
 }
 
 NS_IMPL_ISUPPORTS(BluetoothOppManager, nsIObserver)
 
 bool
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -738,17 +738,17 @@ BluetoothSocket::SendSocketData(UnixSock
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<DroidSocketImpl, UnixSocketIOBuffer>(mImpl, aBuffer));
 }
 
 // |SocketBase|
 
 void
-BluetoothSocket::CloseSocket()
+BluetoothSocket::Close()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(sBluetoothSocketInterface);
   if (!mImpl) {
     return;
   }
 
   // Stop any watching |SocketMessageWatcher|
--- a/dom/bluetooth/bluedroid/BluetoothSocket.h
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.h
@@ -58,17 +58,17 @@ public:
   // Methods for |DataSocket|
   //
 
   void SendSocketData(mozilla::ipc::UnixSocketIOBuffer* aBuffer) override;
 
   // Methods for |SocketBase|
   //
 
-  void CloseSocket() override;
+  void Close() override;
 
   void OnConnectSuccess() override;
   void OnConnectError() override;
   void OnDisconnect() override;
 
 private:
   BluetoothSocketObserver* mObserver;
   BluetoothSocketResultHandler* mCurrentRes;
--- a/dom/bluetooth/bluez/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluez/BluetoothSocket.cpp
@@ -715,17 +715,17 @@ BluetoothSocket::SendSocketData(UnixSock
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<BluetoothSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 // |SocketBase|
 
 void
-BluetoothSocket::CloseSocket()
+BluetoothSocket::Close()
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (!mIO) {
     return;
   }
 
   mIO->CancelDelayedConnectTask();
 
--- a/dom/bluetooth/bluez/BluetoothSocket.h
+++ b/dom/bluetooth/bluez/BluetoothSocket.h
@@ -33,17 +33,17 @@ public:
   bool Connect(const nsAString& aDeviceAddress,
                const BluetoothUuid& aServiceUuid,
                int aChannel);
   bool Listen(const nsAString& aServiceName,
               const BluetoothUuid& aServiceUuid,
               int aChannel);
   inline void Disconnect()
   {
-    CloseSocket();
+    Close();
   }
 
   inline void GetAddress(nsAString& aDeviceAddress)
   {
     GetSocketAddr(aDeviceAddress);
   }
 
   /**
@@ -97,17 +97,17 @@ public:
   // Methods for |DataSocket|
   //
 
   void SendSocketData(mozilla::ipc::UnixSocketIOBuffer* aBuffer) override;
 
   // Methods for |SocketBase|
   //
 
-  void CloseSocket() override;
+  void Close() override;
 
   void OnConnectSuccess() override;
   void OnConnectError() override;
   void OnDisconnect() override;
 
 private:
   class BluetoothSocketIO;
   class ConnectTask;
--- a/ipc/bluetooth/BluetoothDaemonConnection.cpp
+++ b/ipc/bluetooth/BluetoothDaemonConnection.cpp
@@ -564,17 +564,17 @@ BluetoothDaemonConnection::SendSocketDat
     FROM_HERE,
     new SocketIOSendTask<BluetoothDaemonConnectionIO,
                          UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 // |SocketBase|
 
 void
-BluetoothDaemonConnection::CloseSocket()
+BluetoothDaemonConnection::Close()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (!mIO) {
     CHROMIUM_LOG("Bluetooth daemon already disconnected!");
     return;
   }
 
--- a/ipc/bluetooth/BluetoothDaemonConnection.h
+++ b/ipc/bluetooth/BluetoothDaemonConnection.h
@@ -126,17 +126,17 @@ public:
   // Methods for |DataSocket|
   //
 
   void SendSocketData(UnixSocketIOBuffer* aBuffer) override;
 
   // Methods for |SocketBase|
   //
 
-  void CloseSocket() override;
+  void Close() override;
 
 protected:
 
   // Prepares an instance of |BluetoothDaemonConnection| in DISCONNECTED
   // state for accepting a connection. Subclasses implementing |GetIO|
   // need to call this method.
   ConnectionOrientedSocketIO*
     PrepareAccept(BluetoothDaemonPDUConsumer* aConsumer);
--- a/ipc/unixsocket/ListenSocket.cpp
+++ b/ipc/unixsocket/ListenSocket.cpp
@@ -309,37 +309,16 @@ ListenSocket::ListenSocket()
 : mIO(nullptr)
 { }
 
 ListenSocket::~ListenSocket()
 {
   MOZ_ASSERT(!mIO);
 }
 
-void
-ListenSocket::Close()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!mIO) {
-    return;
-  }
-
-  // From this point on, we consider mIO as being deleted. We sever
-  // the relationship here so any future calls to listen or connect
-  // will create a new implementation.
-  mIO->ShutdownOnMainThread();
-
-  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
-
-  mIO = nullptr;
-
-  NotifyDisconnect();
-}
-
 bool
 ListenSocket::Listen(UnixSocketConnector* aConnector,
                      ConnectionOrientedSocket* aCOSocket)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aConnector);
   MOZ_ASSERT(aCOSocket);
 
@@ -380,15 +359,30 @@ ListenSocket::GetSocketAddr(nsAString& a
     return;
   }
   mIO->GetSocketAddr(aAddrStr);
 }
 
 // |SocketBase|
 
 void
-ListenSocket::CloseSocket()
+ListenSocket::Close()
 {
-  Close();
+  MOZ_ASSERT(NS_IsMainThread());
+
+  if (!mIO) {
+    return;
+  }
+
+  // From this point on, we consider mIO as being deleted. We sever
+  // the relationship here so any future calls to listen or connect
+  // will create a new implementation.
+  mIO->ShutdownOnMainThread();
+
+  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
+
+  mIO = nullptr;
+
+  NotifyDisconnect();
 }
 
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/unixsocket/ListenSocket.h
+++ b/ipc/unixsocket/ListenSocket.h
@@ -46,30 +46,24 @@ public:
    * @param aCOSocket The connection-oriented socket for handling the
    *                  accepted connection.
    *
    * @return true on listen started, false otherwise
    */
   bool Listen(ConnectionOrientedSocket* aCOSocket);
 
   /**
-   * Queues the internal representation of socket for deletion. Can be called
-   * from main thread.
-   */
-  void Close();
-
-  /**
    * Get the current sockaddr for the socket
    */
   void GetSocketAddr(nsAString& aAddrStr);
 
   // Methods for |SocketBase|
   //
 
-  void CloseSocket() override;
+  void Close() override;
 
 private:
   ListenSocketIO* mIO;
 };
 
 } // namespace ipc
 } // namepsace mozilla
 
--- a/ipc/unixsocket/SocketBase.cpp
+++ b/ipc/unixsocket/SocketBase.cpp
@@ -335,17 +335,17 @@ SocketIORequestClosingRunnable::Run()
     // Since we've already explicitly closed and the close
     // happened before this, this isn't really an error.
     return NS_OK;
   }
 
   SocketBase* socketBase = io->GetSocketBase();
   MOZ_ASSERT(socketBase);
 
-  socketBase->CloseSocket();
+  socketBase->Close();
 
   return NS_OK;
 }
 
 //
 // SocketIODeleteInstanceRunnable
 //
 
--- a/ipc/unixsocket/SocketBase.h
+++ b/ipc/unixsocket/SocketBase.h
@@ -253,17 +253,17 @@ public:
   SocketConnectionStatus GetConnectionStatus() const;
 
   int GetSuggestedConnectDelayMs() const;
 
   /**
    * Queues the internal representation of socket for deletion. Can be called
    * from main thread.
    */
-  virtual void CloseSocket() = 0;
+  virtual void Close() = 0;
 
   /**
    * Callback for socket connect/accept success. Called after connect/accept has
    * finished. Will be run on main thread, before any reads take place.
    */
   virtual void OnConnectSuccess() = 0;
 
   /**
--- a/ipc/unixsocket/StreamSocket.cpp
+++ b/ipc/unixsocket/StreamSocket.cpp
@@ -538,39 +538,16 @@ StreamSocket::SendSocketData(const nsACS
   }
 
   SendSocketData(new UnixSocketRawData(aStr.BeginReading(), aStr.Length()));
 
   return true;
 }
 
 void
-StreamSocket::Close()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!mIO) {
-    return;
-  }
-
-  mIO->CancelDelayedConnectTask();
-
-  // From this point on, we consider mIO as being deleted.
-  // We sever the relationship here so any future calls to listen or connect
-  // will create a new implementation.
-  mIO->ShutdownOnMainThread();
-
-  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
-
-  mIO = nullptr;
-
-  NotifyDisconnect();
-}
-
-void
 StreamSocket::GetSocketAddr(nsAString& aAddrStr)
 {
   aAddrStr.Truncate();
   if (!mIO || GetConnectionStatus() != SOCKET_CONNECTED) {
     NS_WARNING("No socket currently open!");
     return;
   }
   mIO->GetSocketAddr(aAddrStr);
@@ -635,15 +612,33 @@ StreamSocket::SendSocketData(UnixSocketI
   XRE_GetIOMessageLoop()->PostTask(
     FROM_HERE,
     new SocketIOSendTask<StreamSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
 }
 
 // |SocketBase|
 
 void
-StreamSocket::CloseSocket()
+StreamSocket::Close()
 {
-  Close();
+  MOZ_ASSERT(NS_IsMainThread());
+
+  if (!mIO) {
+    return;
+  }
+
+  mIO->CancelDelayedConnectTask();
+
+  // From this point on, we consider mIO as being deleted.
+  // We sever the relationship here so any future calls to listen or connect
+  // will create a new implementation.
+  mIO->ShutdownOnMainThread();
+
+  XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
+
+  mIO = nullptr;
+
+  NotifyDisconnect();
 }
 
+
 } // namespace ipc
 } // namespace mozilla
--- a/ipc/unixsocket/StreamSocket.h
+++ b/ipc/unixsocket/StreamSocket.h
@@ -51,35 +51,29 @@ public:
    *
    * @return true on connect task started, false otherwise.
    */
   bool Connect(UnixSocketConnector* aConnector,
                const char* aAddress,
                int aDelayMs = 0);
 
   /**
-   * Queues the internal representation of socket for deletion. Can be called
-   * from main thread.
-   */
-  void Close();
-
-  /**
    * Get the current sockaddr for the socket
    */
   void GetSocketAddr(nsAString& aAddrStr);
 
   // Methods for |DataSocket|
   //
 
   void SendSocketData(UnixSocketIOBuffer* aBuffer) override;
 
   // Methods for |SocketBase|
   //
 
-  void CloseSocket() override;
+  void Close() override;
 
 protected:
   virtual ~StreamSocket();
 
   // Prepares an instance of |StreamSocket| in DISCONNECTED state
   // for accepting a connection. Subclasses implementing |GetIO|
   // need to call this method.
   ConnectionOrientedSocketIO* PrepareAccept(UnixSocketConnector* aConnector);