Bug 796176 - Patch 1: UnixSocket changes to get connect/listen running main thread, connect status to consumers; r=cjones

This commit is contained in:
Kyle Machulis
2012-10-10 22:48:40 -07:00
parent c79d1b9999
commit f28e7f6e44
2 changed files with 142 additions and 31 deletions

View File

@@ -100,18 +100,27 @@ public:
*
* @return true is successful, false otherwise
*/
virtual bool Setup(int aFd) = 0;
virtual bool SetUp(int aFd) = 0;
};
enum SocketConnectionStatus {
SOCKET_DISCONNECTED = 0,
SOCKET_CONNECTING = 1,
SOCKET_CONNECTED = 2
};
class UnixSocketConsumer : public RefCounted<UnixSocketConsumer>
{
public:
UnixSocketConsumer()
: mImpl(nullptr)
{}
UnixSocketConsumer();
virtual ~UnixSocketConsumer();
SocketConnectionStatus GetConnectionStatus()
{
return mConnectionStatus;
}
/**
* Function to be called whenever data is received. This is only called on the
* main thread.
@@ -172,8 +181,32 @@ public:
* Cancels connect/accept task loop, if one is currently running.
*/
void CancelSocketTask();
/**
* 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;
/**
* Callback for socket connect/accept error. Will be run on main thread.
*/
virtual void OnConnectError() = 0;
/**
* Called by implementation to notify consumer of success.
*/
void NotifySuccess();
/**
* Called by implementation to notify consumer of error.
*/
void NotifyError();
private:
UnixSocketImpl* mImpl;
SocketConnectionStatus mConnectionStatus;
};
} // namespace ipc