Bug 1164425: Rename |SocketBase::CloseSocket| to |SocketBase::Close|, r=kmachulis

This commit is contained in:
Thomas Zimmermann 2015-05-20 09:54:27 +02:00
parent eeac4617ca
commit 8e10928ea3
14 changed files with 56 additions and 79 deletions

View File

@ -1911,7 +1911,7 @@ BluetoothDaemonInterface::OnConnectSuccess(enum Channel aChannel)
} else if ( } else if (
NS_WARN_IF(mNtfChannel->GetConnectionStatus() == SOCKET_CONNECTED)) { NS_WARN_IF(mNtfChannel->GetConnectionStatus() == SOCKET_CONNECTED)) {
/* Notification channel should not be open; let's close it. */ /* Notification channel should not be open; let's close it. */
mNtfChannel->CloseSocket(); mNtfChannel->Close();
} }
if (!mListenSocket->Listen(mNtfChannel)) { if (!mListenSocket->Listen(mNtfChannel)) {
OnConnectError(NTF_CHANNEL); OnConnectError(NTF_CHANNEL);
@ -1942,7 +1942,7 @@ BluetoothDaemonInterface::OnConnectError(enum Channel aChannel)
switch (aChannel) { switch (aChannel) {
case NTF_CHANNEL: case NTF_CHANNEL:
// Close command channel // Close command channel
mCmdChannel->CloseSocket(); mCmdChannel->Close();
case CMD_CHANNEL: case CMD_CHANNEL:
// Stop daemon and close listen socket // Stop daemon and close listen socket
unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd")); unused << NS_WARN_IF(property_set("ctl.stop", "bluetoothd"));
@ -2120,7 +2120,7 @@ BluetoothDaemonInterface::Init(
} else if ( } else if (
NS_WARN_IF(mCmdChannel->GetConnectionStatus() == SOCKET_CONNECTED)) { NS_WARN_IF(mCmdChannel->GetConnectionStatus() == SOCKET_CONNECTED)) {
// Command channel should not be open; let's close it. // 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 // The listen socket's name is generated with a random postfix. This
@ -2182,7 +2182,7 @@ private:
mInterface->mProtocol->UnregisterModuleCmd(0x01, this); mInterface->mProtocol->UnregisterModuleCmd(0x01, this);
} else { } else {
// Cleanup, step 3: Close command channel // Cleanup, step 3: Close command channel
mInterface->mCmdChannel->CloseSocket(); mInterface->mCmdChannel->Close();
} }
} }

View File

@ -183,7 +183,7 @@ public:
void Run() override void Run() override
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
mSocket->CloseSocket(); mSocket->Close();
} }
private: private:
@ -282,7 +282,7 @@ BluetoothOppManager::ConnectInternal(const nsAString& aDeviceAddress)
// Stop listening because currently we only support one connection at a time. // Stop listening because currently we only support one connection at a time.
if (mServerSocket) { if (mServerSocket) {
mServerSocket->CloseSocket(); mServerSocket->Close();
mServerSocket = nullptr; mServerSocket = nullptr;
} }
@ -352,7 +352,7 @@ BluetoothOppManager::Listen()
* BT restarts. * BT restarts.
*/ */
if (mServerSocket) { if (mServerSocket) {
mServerSocket->CloseSocket(); mServerSocket->Close();
mServerSocket = nullptr; mServerSocket = nullptr;
} }
@ -1552,7 +1552,7 @@ void
BluetoothOppManager::Disconnect(BluetoothProfileController* aController) BluetoothOppManager::Disconnect(BluetoothProfileController* aController)
{ {
if (mSocket) { if (mSocket) {
mSocket->CloseSocket(); mSocket->Close();
} else { } else {
BT_WARNING("%s: No ongoing file transfer to stop", __FUNCTION__); BT_WARNING("%s: No ongoing file transfer to stop", __FUNCTION__);
} }

View File

@ -743,7 +743,7 @@ BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
// |SocketBase| // |SocketBase|
void void
BluetoothSocket::CloseSocket() BluetoothSocket::Close()
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(sBluetoothSocketInterface); MOZ_ASSERT(sBluetoothSocketInterface);

View File

@ -63,7 +63,7 @@ public:
// Methods for |SocketBase| // Methods for |SocketBase|
// //
void CloseSocket() override; void Close() override;
void OnConnectSuccess() override; void OnConnectSuccess() override;
void OnConnectError() override; void OnConnectError() override;

View File

@ -720,7 +720,7 @@ BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
// |SocketBase| // |SocketBase|
void void
BluetoothSocket::CloseSocket() BluetoothSocket::Close()
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (!mIO) { if (!mIO) {

View File

@ -38,7 +38,7 @@ public:
int aChannel); int aChannel);
inline void Disconnect() inline void Disconnect()
{ {
CloseSocket(); Close();
} }
inline void GetAddress(nsAString& aDeviceAddress) inline void GetAddress(nsAString& aDeviceAddress)
@ -102,7 +102,7 @@ public:
// Methods for |SocketBase| // Methods for |SocketBase|
// //
void CloseSocket() override; void Close() override;
void OnConnectSuccess() override; void OnConnectSuccess() override;
void OnConnectError() override; void OnConnectError() override;

View File

@ -569,7 +569,7 @@ BluetoothDaemonConnection::SendSocketData(UnixSocketIOBuffer* aBuffer)
// |SocketBase| // |SocketBase|
void void
BluetoothDaemonConnection::CloseSocket() BluetoothDaemonConnection::Close()
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());

View File

@ -131,7 +131,7 @@ public:
// Methods for |SocketBase| // Methods for |SocketBase|
// //
void CloseSocket() override; void Close() override;
protected: protected:

View File

@ -314,27 +314,6 @@ ListenSocket::~ListenSocket()
MOZ_ASSERT(!mIO); 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 bool
ListenSocket::Listen(UnixSocketConnector* aConnector, ListenSocket::Listen(UnixSocketConnector* aConnector,
ConnectionOrientedSocket* aCOSocket) ConnectionOrientedSocket* aCOSocket)
@ -385,9 +364,24 @@ ListenSocket::GetSocketAddr(nsAString& aAddrStr)
// |SocketBase| // |SocketBase|
void 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 ipc

View File

@ -50,12 +50,6 @@ public:
*/ */
bool Listen(ConnectionOrientedSocket* aCOSocket); 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 * Get the current sockaddr for the socket
*/ */
@ -64,7 +58,7 @@ public:
// Methods for |SocketBase| // Methods for |SocketBase|
// //
void CloseSocket() override; void Close() override;
private: private:
ListenSocketIO* mIO; ListenSocketIO* mIO;

View File

@ -340,7 +340,7 @@ SocketIORequestClosingRunnable::Run()
SocketBase* socketBase = io->GetSocketBase(); SocketBase* socketBase = io->GetSocketBase();
MOZ_ASSERT(socketBase); MOZ_ASSERT(socketBase);
socketBase->CloseSocket(); socketBase->Close();
return NS_OK; return NS_OK;
} }

View File

@ -258,7 +258,7 @@ public:
* Queues the internal representation of socket for deletion. Can be called * Queues the internal representation of socket for deletion. Can be called
* from main thread. * from main thread.
*/ */
virtual void CloseSocket() = 0; virtual void Close() = 0;
/** /**
* Callback for socket connect/accept success. Called after connect/accept has * Callback for socket connect/accept success. Called after connect/accept has

View File

@ -542,29 +542,6 @@ StreamSocket::SendSocketData(const nsACString& aStr)
return true; 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 void
StreamSocket::GetSocketAddr(nsAString& aAddrStr) StreamSocket::GetSocketAddr(nsAString& aAddrStr)
{ {
@ -640,10 +617,28 @@ StreamSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
// |SocketBase| // |SocketBase|
void 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 ipc
} // namespace mozilla } // namespace mozilla

View File

@ -55,12 +55,6 @@ public:
const char* aAddress, const char* aAddress,
int aDelayMs = 0); 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 * Get the current sockaddr for the socket
*/ */
@ -74,7 +68,7 @@ public:
// Methods for |SocketBase| // Methods for |SocketBase|
// //
void CloseSocket() override; void Close() override;
protected: protected:
virtual ~StreamSocket(); virtual ~StreamSocket();