Bug 1159709: Cleanup inherited methods of |ListenSocket|, r=kmachulis

This patch cleans up the inherited methods of |ListenSocket|. Methods
of the same base class are grouped within the file, and each method is
labeled with 'override'.
This commit is contained in:
Thomas Zimmermann 2015-04-30 12:55:37 +02:00
parent 80b0466f0f
commit 5cab8e5006
2 changed files with 69 additions and 68 deletions

View File

@ -19,8 +19,9 @@ namespace ipc {
// ListenSocketIO // ListenSocketIO
// //
class ListenSocketIO final : public UnixSocketWatcher class ListenSocketIO final
, public SocketIOBase : public UnixSocketWatcher
, public SocketIOBase
{ {
public: public:
class ListenTask; class ListenTask;
@ -31,18 +32,7 @@ public:
const nsACString& aAddress); const nsACString& aAddress);
~ListenSocketIO(); ~ListenSocketIO();
void GetSocketAddr(nsAString& aAddrStr) const; void GetSocketAddr(nsAString& aAddrStr) const;
DataSocket* GetDataSocket();
SocketBase* GetSocketBase() override;
// Shutdown state
//
bool IsShutdownOnMainThread() const override;
void ShutdownOnMainThread() override;
bool IsShutdownOnIOThread() const override;
void ShutdownOnIOThread() override;
// Task callback methods // Task callback methods
// //
@ -61,6 +51,17 @@ public:
void OnError(const char* aFunction, int aErrno) override; void OnError(const char* aFunction, int aErrno) override;
void OnListening() override; void OnListening() override;
// Methods for |SocketIOBase|
//
SocketBase* GetSocketBase() override;
bool IsShutdownOnMainThread() const override;
bool IsShutdownOnIOThread() const override;
void ShutdownOnMainThread() override;
void ShutdownOnIOThread() override;
private: private:
void FireSocketError(); void FireSocketError();
@ -135,53 +136,6 @@ ListenSocketIO::GetSocketAddr(nsAString& aAddrStr) const
mConnector->GetSocketAddr(mAddr, aAddrStr); mConnector->GetSocketAddr(mAddr, aAddrStr);
} }
DataSocket*
ListenSocketIO::GetDataSocket()
{
MOZ_CRASH("Listen sockets cannot transfer data");
return nullptr;
}
SocketBase*
ListenSocketIO::GetSocketBase()
{
return mListenSocket.get();
}
bool
ListenSocketIO::IsShutdownOnMainThread() const
{
MOZ_ASSERT(NS_IsMainThread());
return mListenSocket == nullptr;
}
void
ListenSocketIO::ShutdownOnMainThread()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!IsShutdownOnMainThread());
mListenSocket = nullptr;
}
bool
ListenSocketIO::IsShutdownOnIOThread() const
{
return mShuttingDownOnIOThread;
}
void
ListenSocketIO::ShutdownOnIOThread()
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!mShuttingDownOnIOThread);
Close(); // will also remove fd from I/O loop
mShuttingDownOnIOThread = true;
}
void void
ListenSocketIO::Listen(ConnectionOrientedSocketIO* aCOSocketIO) ListenSocketIO::Listen(ConnectionOrientedSocketIO* aCOSocketIO)
{ {
@ -319,6 +273,47 @@ ListenSocketIO::SetSocketFlags(int aFd)
return true; return true;
} }
// |SocketIOBase|
SocketBase*
ListenSocketIO::GetSocketBase()
{
return mListenSocket.get();
}
bool
ListenSocketIO::IsShutdownOnMainThread() const
{
MOZ_ASSERT(NS_IsMainThread());
return mListenSocket == nullptr;
}
bool
ListenSocketIO::IsShutdownOnIOThread() const
{
return mShuttingDownOnIOThread;
}
void
ListenSocketIO::ShutdownOnMainThread()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!IsShutdownOnMainThread());
mListenSocket = nullptr;
}
void
ListenSocketIO::ShutdownOnIOThread()
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!mShuttingDownOnIOThread);
Close(); // will also remove fd from I/O loop
mShuttingDownOnIOThread = true;
}
// //
// Socket tasks // Socket tasks
// //
@ -429,5 +424,13 @@ ListenSocket::GetSocketAddr(nsAString& aAddrStr)
mIO->GetSocketAddr(aAddrStr); mIO->GetSocketAddr(aAddrStr);
} }
// |SocketBase|
void
ListenSocket::CloseSocket()
{
Close();
}
} // namespace ipc } // namespace ipc
} // namespace mozilla } // namespace mozilla

View File

@ -61,14 +61,12 @@ public:
*/ */
void GetSocketAddr(nsAString& aAddrStr); void GetSocketAddr(nsAString& aAddrStr);
// Methods for |SocketBase|
//
void CloseSocket() override;
private: private:
// Legacy interface from |SocketBase|; should be replaced by |Close|.
void CloseSocket() override
{
Close();
}
ListenSocketIO* mIO; ListenSocketIO* mIO;
}; };