From 8e10928ea39d4bf353230dc2e958e68347a74587 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Wed, 20 May 2015 09:54:27 +0200 Subject: [PATCH] Bug 1164425: Rename |SocketBase::CloseSocket| to |SocketBase::Close|, r=kmachulis --- .../bluedroid/BluetoothDaemonInterface.cpp | 8 ++-- .../bluedroid/BluetoothOppManager.cpp | 8 ++-- dom/bluetooth/bluedroid/BluetoothSocket.cpp | 2 +- dom/bluetooth/bluedroid/BluetoothSocket.h | 2 +- dom/bluetooth/bluez/BluetoothSocket.cpp | 2 +- dom/bluetooth/bluez/BluetoothSocket.h | 4 +- ipc/bluetooth/BluetoothDaemonConnection.cpp | 2 +- ipc/bluetooth/BluetoothDaemonConnection.h | 2 +- ipc/unixsocket/ListenSocket.cpp | 40 +++++++---------- ipc/unixsocket/ListenSocket.h | 8 +--- ipc/unixsocket/SocketBase.cpp | 2 +- ipc/unixsocket/SocketBase.h | 2 +- ipc/unixsocket/StreamSocket.cpp | 45 +++++++++---------- ipc/unixsocket/StreamSocket.h | 8 +--- 14 files changed, 56 insertions(+), 79 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp index 5b20efd8117..29c8aa819d5 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp @@ -1911,7 +1911,7 @@ BluetoothDaemonInterface::OnConnectSuccess(enum Channel aChannel) } 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); @@ -1942,7 +1942,7 @@ BluetoothDaemonInterface::OnConnectError(enum Channel aChannel) 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")); @@ -2120,7 +2120,7 @@ BluetoothDaemonInterface::Init( } 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 @@ -2182,7 +2182,7 @@ private: mInterface->mProtocol->UnregisterModuleCmd(0x01, this); } else { // Cleanup, step 3: Close command channel - mInterface->mCmdChannel->CloseSocket(); + mInterface->mCmdChannel->Close(); } } diff --git a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp index 90f463c1d55..0b969613af5 100644 --- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp @@ -183,7 +183,7 @@ public: void Run() override { MOZ_ASSERT(NS_IsMainThread()); - mSocket->CloseSocket(); + mSocket->Close(); } private: @@ -282,7 +282,7 @@ BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress) // Stop listening because currently we only support one connection at a time. if (mServerSocket) { - mServerSocket->CloseSocket(); + mServerSocket->Close(); mServerSocket = nullptr; } @@ -352,7 +352,7 @@ BluetoothOppManager::Listen() * BT restarts. */ if (mServerSocket) { - mServerSocket->CloseSocket(); + mServerSocket->Close(); mServerSocket = nullptr; } @@ -1552,7 +1552,7 @@ void BluetoothOppManager::Disconnect(BluetoothProfileController* aController) { if (mSocket) { - mSocket->CloseSocket(); + mSocket->Close(); } else { BT_WARNING("%s: No ongoing file transfer to stop", __FUNCTION__); } diff --git a/dom/bluetooth/bluedroid/BluetoothSocket.cpp b/dom/bluetooth/bluedroid/BluetoothSocket.cpp index 62edd8d3af4..b33072d2575 100644 --- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp +++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp @@ -743,7 +743,7 @@ BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer) // |SocketBase| void -BluetoothSocket::CloseSocket() +BluetoothSocket::Close() { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(sBluetoothSocketInterface); diff --git a/dom/bluetooth/bluedroid/BluetoothSocket.h b/dom/bluetooth/bluedroid/BluetoothSocket.h index f6e8dc0cc24..75443fb1f09 100644 --- a/dom/bluetooth/bluedroid/BluetoothSocket.h +++ b/dom/bluetooth/bluedroid/BluetoothSocket.h @@ -63,7 +63,7 @@ public: // Methods for |SocketBase| // - void CloseSocket() override; + void Close() override; void OnConnectSuccess() override; void OnConnectError() override; diff --git a/dom/bluetooth/bluez/BluetoothSocket.cpp b/dom/bluetooth/bluez/BluetoothSocket.cpp index 02f573de6d9..cc8a94a4e5a 100644 --- a/dom/bluetooth/bluez/BluetoothSocket.cpp +++ b/dom/bluetooth/bluez/BluetoothSocket.cpp @@ -720,7 +720,7 @@ BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer) // |SocketBase| void -BluetoothSocket::CloseSocket() +BluetoothSocket::Close() { MOZ_ASSERT(NS_IsMainThread()); if (!mIO) { diff --git a/dom/bluetooth/bluez/BluetoothSocket.h b/dom/bluetooth/bluez/BluetoothSocket.h index 9656ca8f000..6b646b30b91 100644 --- a/dom/bluetooth/bluez/BluetoothSocket.h +++ b/dom/bluetooth/bluez/BluetoothSocket.h @@ -38,7 +38,7 @@ public: int aChannel); inline void Disconnect() { - CloseSocket(); + Close(); } inline void GetAddress(nsAString& aDeviceAddress) @@ -102,7 +102,7 @@ public: // Methods for |SocketBase| // - void CloseSocket() override; + void Close() override; void OnConnectSuccess() override; void OnConnectError() override; diff --git a/ipc/bluetooth/BluetoothDaemonConnection.cpp b/ipc/bluetooth/BluetoothDaemonConnection.cpp index 269be2e448c..ac1c146b6d0 100644 --- a/ipc/bluetooth/BluetoothDaemonConnection.cpp +++ b/ipc/bluetooth/BluetoothDaemonConnection.cpp @@ -569,7 +569,7 @@ BluetoothDaemonConnection::SendSocketData(UnixSocketIOBuffer* aBuffer) // |SocketBase| void -BluetoothDaemonConnection::CloseSocket() +BluetoothDaemonConnection::Close() { MOZ_ASSERT(NS_IsMainThread()); diff --git a/ipc/bluetooth/BluetoothDaemonConnection.h b/ipc/bluetooth/BluetoothDaemonConnection.h index bfb26eefcb6..ea26b68be16 100644 --- a/ipc/bluetooth/BluetoothDaemonConnection.h +++ b/ipc/bluetooth/BluetoothDaemonConnection.h @@ -131,7 +131,7 @@ public: // Methods for |SocketBase| // - void CloseSocket() override; + void Close() override; protected: diff --git a/ipc/unixsocket/ListenSocket.cpp b/ipc/unixsocket/ListenSocket.cpp index 62cb76fba54..b49bb07b6d1 100644 --- a/ipc/unixsocket/ListenSocket.cpp +++ b/ipc/unixsocket/ListenSocket.cpp @@ -314,27 +314,6 @@ 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) @@ -385,9 +364,24 @@ ListenSocket::GetSocketAddr(nsAString& 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 diff --git a/ipc/unixsocket/ListenSocket.h b/ipc/unixsocket/ListenSocket.h index f3422f704c5..77f0aae813a 100644 --- a/ipc/unixsocket/ListenSocket.h +++ b/ipc/unixsocket/ListenSocket.h @@ -50,12 +50,6 @@ public: */ 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 */ @@ -64,7 +58,7 @@ public: // Methods for |SocketBase| // - void CloseSocket() override; + void Close() override; private: ListenSocketIO* mIO; diff --git a/ipc/unixsocket/SocketBase.cpp b/ipc/unixsocket/SocketBase.cpp index df9bd6f92cd..491c4638504 100644 --- a/ipc/unixsocket/SocketBase.cpp +++ b/ipc/unixsocket/SocketBase.cpp @@ -340,7 +340,7 @@ SocketIORequestClosingRunnable::Run() SocketBase* socketBase = io->GetSocketBase(); MOZ_ASSERT(socketBase); - socketBase->CloseSocket(); + socketBase->Close(); return NS_OK; } diff --git a/ipc/unixsocket/SocketBase.h b/ipc/unixsocket/SocketBase.h index 9d8793b2dcf..3c55f426ab3 100644 --- a/ipc/unixsocket/SocketBase.h +++ b/ipc/unixsocket/SocketBase.h @@ -258,7 +258,7 @@ public: * 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 diff --git a/ipc/unixsocket/StreamSocket.cpp b/ipc/unixsocket/StreamSocket.cpp index 79b8471efc6..cd584e037bb 100644 --- a/ipc/unixsocket/StreamSocket.cpp +++ b/ipc/unixsocket/StreamSocket.cpp @@ -542,29 +542,6 @@ StreamSocket::SendSocketData(const nsACString& aStr) 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) { @@ -640,10 +617,28 @@ StreamSocket::SendSocketData(UnixSocketIOBuffer* 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 diff --git a/ipc/unixsocket/StreamSocket.h b/ipc/unixsocket/StreamSocket.h index e3dd403a20f..02f07118512 100644 --- a/ipc/unixsocket/StreamSocket.h +++ b/ipc/unixsocket/StreamSocket.h @@ -55,12 +55,6 @@ public: 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 */ @@ -74,7 +68,7 @@ public: // Methods for |SocketBase| // - void CloseSocket() override; + void Close() override; protected: virtual ~StreamSocket();