Bug 928223 - 0001. Add function to perform setup for listen socket. r=qDot echou vicamo yoshi

This commit is contained in:
Chuck Lee 2013-10-25 10:00:22 +08:00
parent a52fbf4399
commit c81c6692fc
6 changed files with 43 additions and 1 deletions

View File

@ -166,6 +166,13 @@ BluetoothUnixSocketConnector::SetUp(int aFd)
return true;
}
bool
BluetoothUnixSocketConnector::SetUpListenSocket(int aFd)
{
// Nothing to do here.
return true;
}
int
BluetoothUnixSocketConnector::Create()
{

View File

@ -26,6 +26,7 @@ public:
mozilla::ipc::sockaddr_any& aAddr,
const char* aAddress) MOZ_OVERRIDE;
virtual bool SetUp(int aFd) MOZ_OVERRIDE;
virtual bool SetUpListenSocket(int aFd) MOZ_OVERRIDE;
virtual void GetSocketAddr(const mozilla::ipc::sockaddr_any& aAddr,
nsAString& aAddrStr) MOZ_OVERRIDE;

View File

@ -77,6 +77,7 @@ public:
sockaddr_any& aAddr,
const char* aAddress);
virtual bool SetUp(int aFd);
virtual bool SetUpListenSocket(int aFd);
virtual void GetSocketAddr(const sockaddr_any& aAddr,
nsAString& aAddrStr);
};
@ -151,6 +152,13 @@ NfcConnector::SetUp(int aFd)
return true;
}
bool
NfcConnector::SetUpListenSocket(int aFd)
{
// Nothing to do here.
return true;
}
void
NfcConnector::GetSocketAddr(const sockaddr_any& aAddr,
nsAString& aAddrStr)

View File

@ -76,6 +76,7 @@ public:
sockaddr_any& aAddr,
const char* aAddress);
virtual bool SetUp(int aFd);
virtual bool SetUpListenSocket(int aFd);
virtual void GetSocketAddr(const sockaddr_any& aAddr,
nsAString& aAddrStr);
@ -152,6 +153,13 @@ RilConnector::SetUp(int aFd)
return true;
}
bool
RilConnector::SetUpListenSocket(int aFd)
{
// Nothing to do here.
return true;
}
void
RilConnector::GetSocketAddr(const sockaddr_any& aAddr,
nsAString& aAddrStr)

View File

@ -521,6 +521,14 @@ UnixSocketImpl::Accept()
return;
}
if (!mConnector->SetUpListenSocket(mFd)) {
NS_WARNING("Could not set up listen socket!");
nsRefPtr<OnSocketEventTask> t =
new OnSocketEventTask(this, OnSocketEventTask::CONNECT_ERROR);
NS_DispatchToMainThread(t);
return;
}
}
SetUpIO();

View File

@ -119,7 +119,8 @@ public:
const char* aAddress) = 0;
/**
* Does any socket type specific setup that may be needed
* Does any socket type specific setup that may be needed, only for socket
* created by ConnectSocket()
*
* @param aFd File descriptor for opened socket
*
@ -127,6 +128,15 @@ public:
*/
virtual bool SetUp(int aFd) = 0;
/**
* Perform socket setup for socket created by ListenSocket(), after listen().
*
* @param aFd File descriptor for opened socket
*
* @return true is successful, false otherwise
*/
virtual bool SetUpListenSocket(int aFd) = 0;
/**
* Get address of socket we're currently connected to. Return null string if
* not connected.