Bug 1053650 - Part 3: Make use of gonk-specific per-interface DNS lookup. r=mcmanus

--HG--
extra : rebase_source : a859ed97ede124c0d87dd72c6399be15c72c272d
This commit is contained in:
Henry Chang 2015-01-28 11:21:37 +08:00
parent 90b7e51843
commit d7d5a942ab
4 changed files with 45 additions and 4 deletions

View File

@ -28,8 +28,8 @@ native NetAddr(mozilla::net::NetAddr);
* NOTE: This is a free-threaded interface, meaning that the methods on
* this interface may be called from any thread.
*/
[scriptable, uuid(a0b3b547-d6f0-4b65-a3de-a99ffa368840)]
interface nsISocketTransport : nsITransport
[scriptable, uuid(79221831-85e2-43a8-8152-05d77d6fde31)]
interface nsISocketTransport : nsITransport
{
/**
* Get the peer's host for the underlying socket connection.
@ -44,6 +44,13 @@ interface nsISocketTransport : nsITransport
*/
readonly attribute long port;
/**
* The platform-specific network interface id that this socket
* associated with. Note that this attribute can be only accessed
* in the socket thread.
*/
attribute ACString networkInterfaceId;
/**
* Returns the IP address of the socket connection peer. This
* attribute is defined only once a connection has been established.
@ -207,6 +214,8 @@ interface nsISocketTransport : nsITransport
/**
* TCP keepalive configuration (support varies by platform).
* Note that the attribute as well as the setter can only accessed
* in the socket thread.
*/
attribute boolean keepaliveEnabled;
void setKeepaliveVals(in long keepaliveIdleTime,

View File

@ -1046,8 +1046,8 @@ nsSocketTransport::ResolveHost()
"Setting both RESOLVE_DISABLE_IPV6 and RESOLVE_DISABLE_IPV4");
SendStatus(NS_NET_STATUS_RESOLVING_HOST);
rv = dns->AsyncResolve(SocketHost(), dnsFlags, this, nullptr,
getter_AddRefs(mDNSRequest));
rv = dns->AsyncResolveExtended(SocketHost(), dnsFlags, mNetworkInterfaceId, this,
nullptr, getter_AddRefs(mDNSRequest));
if (NS_SUCCEEDED(rv)) {
SOCKET_LOG((" advancing to STATE_RESOLVING\n"));
mState = STATE_RESOLVING;
@ -2195,6 +2195,22 @@ nsSocketTransport::GetPort(int32_t *port)
return NS_OK;
}
NS_IMETHODIMP
nsSocketTransport::GetNetworkInterfaceId(nsACString_internal &aNetworkInterfaceId)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
aNetworkInterfaceId = mNetworkInterfaceId;
return NS_OK;
}
NS_IMETHODIMP
nsSocketTransport::SetNetworkInterfaceId(const nsACString_internal &aNetworkInterfaceId)
{
MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread");
mNetworkInterfaceId = aNetworkInterfaceId;
return NS_OK;
}
NS_IMETHODIMP
nsSocketTransport::GetPeerAddr(NetAddr *addr)
{

View File

@ -296,6 +296,10 @@ private:
bool mInputClosed;
bool mOutputClosed;
// The platform-specific network interface id that this socket
// associated with.
nsCString mNetworkInterfaceId;
// this flag is used to determine if the results of a host lookup arrive
// recursively or not. this flag is not protected by any lock.
bool mResolving;

View File

@ -1606,6 +1606,18 @@ SocketTransportShim::GetTimeout(uint32_t aType, uint32_t *_retval)
return mWrapped->GetTimeout(aType, _retval);
}
NS_IMETHODIMP
SocketTransportShim::GetNetworkInterfaceId(nsACString_internal &aNetworkInterfaceId)
{
return mWrapped->GetNetworkInterfaceId(aNetworkInterfaceId);
}
NS_IMETHODIMP
SocketTransportShim::SetNetworkInterfaceId(const nsACString_internal &aNetworkInterfaceId)
{
return mWrapped->SetNetworkInterfaceId(aNetworkInterfaceId);
}
NS_IMETHODIMP
SocketTransportShim::SetTimeout(uint32_t aType, uint32_t aValue)
{