зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1053650 - Part 2: Populate networkInterfaceId to SocketTransport. r=mcmanus
--HG-- extra : rebase_source : a198156d6d430d7f92801c0f2db51cb297820867
This commit is contained in:
Родитель
41c41098cf
Коммит
90b7e51843
|
@ -898,6 +898,21 @@ HttpBaseChannel::SetRequestMethod(const nsACString& aMethod)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetNetworkInterfaceId(nsACString& aNetworkInterfaceId)
|
||||
{
|
||||
aNetworkInterfaceId = mNetworkInterfaceId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetNetworkInterfaceId(const nsACString& aNetworkInterfaceId)
|
||||
{
|
||||
ENSURE_CALLED_BEFORE_CONNECT();
|
||||
mNetworkInterfaceId = aNetworkInterfaceId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetReferrer(nsIURI **referrer)
|
||||
{
|
||||
|
|
|
@ -184,6 +184,8 @@ public:
|
|||
NS_IMETHOD TakeAllSecurityMessages(nsCOMArray<nsISecurityConsoleMessage> &aMessages) override;
|
||||
NS_IMETHOD GetResponseTimeoutEnabled(bool *aEnable) override;
|
||||
NS_IMETHOD SetResponseTimeoutEnabled(bool aEnable) override;
|
||||
NS_IMETHOD GetNetworkInterfaceId(nsACString& aNetworkInterfaceId);
|
||||
NS_IMETHOD SetNetworkInterfaceId(const nsACString& aNetworkInterfaceId);
|
||||
NS_IMETHOD AddRedirect(nsIPrincipal *aRedirect) override;
|
||||
NS_IMETHOD ForcePending(bool aForcePending) override;
|
||||
NS_IMETHOD GetLastModifiedTime(PRTime* lastModifiedTime) override;
|
||||
|
@ -428,6 +430,9 @@ protected:
|
|||
// This parameter is used to ensure that we do not call OnStartRequest more
|
||||
// than once.
|
||||
bool mOnStartRequestCalled;
|
||||
|
||||
// The network interface id that's associated with this channel.
|
||||
nsCString mNetworkInterfaceId;
|
||||
};
|
||||
|
||||
// Share some code while working around C++'s absurd inability to handle casting
|
||||
|
|
|
@ -4872,6 +4872,12 @@ nsHttpChannel::BeginConnect()
|
|||
Telemetry::Accumulate(Telemetry::HTTP_TRANSACTION_USE_ALTSVC, false);
|
||||
}
|
||||
|
||||
// Set network interface id only when it's not empty to avoid
|
||||
// rebuilding hash key.
|
||||
if (!mNetworkInterfaceId.IsEmpty()) {
|
||||
mConnectionInfo->SetNetworkInterfaceId(mNetworkInterfaceId);
|
||||
}
|
||||
|
||||
mAuthProvider =
|
||||
do_CreateInstance("@mozilla.org/network/http-channel-auth-provider;1",
|
||||
&rv);
|
||||
|
|
|
@ -80,11 +80,14 @@ nsHttpConnectionInfo::Init(const nsACString &host, int32_t port,
|
|||
}
|
||||
|
||||
void
|
||||
nsHttpConnectionInfo::SetOriginServer(const nsACString &host, int32_t port)
|
||||
nsHttpConnectionInfo::SetNetworkInterfaceId(const nsACString& aNetworkInterfaceId)
|
||||
{
|
||||
mHost = host;
|
||||
mPort = port == -1 ? DefaultPort() : port;
|
||||
mNetworkInterfaceId = aNetworkInterfaceId;
|
||||
BuildHashKey();
|
||||
}
|
||||
|
||||
void nsHttpConnectionInfo::BuildHashKey()
|
||||
{
|
||||
//
|
||||
// build hash key:
|
||||
//
|
||||
|
@ -116,6 +119,11 @@ nsHttpConnectionInfo::SetOriginServer(const nsACString &host, int32_t port)
|
|||
|
||||
mHashKey.AssignLiteral("......");
|
||||
mHashKey.Append(keyHost);
|
||||
if (!mNetworkInterfaceId.IsEmpty()) {
|
||||
mHashKey.Append('(');
|
||||
mHashKey.Append(mNetworkInterfaceId);
|
||||
mHashKey.Append(')');
|
||||
}
|
||||
mHashKey.Append(':');
|
||||
mHashKey.AppendInt(keyPort);
|
||||
if (!mUsername.IsEmpty()) {
|
||||
|
@ -169,6 +177,14 @@ nsHttpConnectionInfo::SetOriginServer(const nsACString &host, int32_t port)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpConnectionInfo::SetOriginServer(const nsACString &host, int32_t port)
|
||||
{
|
||||
mHost = host;
|
||||
mPort = port == -1 ? DefaultPort() : port;
|
||||
BuildHashKey();
|
||||
}
|
||||
|
||||
nsHttpConnectionInfo*
|
||||
nsHttpConnectionInfo::Clone() const
|
||||
{
|
||||
|
@ -182,6 +198,10 @@ nsHttpConnectionInfo::Clone() const
|
|||
mAuthenticationPort);
|
||||
}
|
||||
|
||||
if (!mNetworkInterfaceId.IsEmpty()) {
|
||||
clone->SetNetworkInterfaceId(mNetworkInterfaceId);
|
||||
}
|
||||
|
||||
// Make sure the anonymous, relaxed, and private flags are transferred
|
||||
clone->SetAnonymous(GetAnonymous());
|
||||
clone->SetPrivate(GetPrivate());
|
||||
|
@ -208,6 +228,9 @@ nsHttpConnectionInfo::CloneAsDirectRoute(nsHttpConnectionInfo **outCI)
|
|||
clone->SetPrivate(GetPrivate());
|
||||
clone->SetRelaxed(GetRelaxed());
|
||||
clone->SetNoSpdy(GetNoSpdy());
|
||||
if (!mNetworkInterfaceId.IsEmpty()) {
|
||||
clone->SetNetworkInterfaceId(mNetworkInterfaceId);
|
||||
}
|
||||
clone.forget(outCI);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,12 +55,19 @@ private:
|
|||
PR_LOG(gHttpLog, 4, ("Destroying nsHttpConnectionInfo @%x\n", this));
|
||||
}
|
||||
|
||||
void BuildHashKey();
|
||||
|
||||
public:
|
||||
const nsAFlatCString &HashKey() const { return mHashKey; }
|
||||
|
||||
const nsCString &GetAuthenticationHost() const { return mAuthenticationHost; }
|
||||
int32_t GetAuthenticationPort() const { return mAuthenticationPort; }
|
||||
|
||||
// With overhead rebuilding the hash key. The initial
|
||||
// network interface is empty. So you can reduce one call
|
||||
// if there's no explicit route after ctor.
|
||||
void SetNetworkInterfaceId(const nsACString& aNetworkInterfaceId);
|
||||
|
||||
// OK to treat these as an infalible allocation
|
||||
nsHttpConnectionInfo* Clone() const;
|
||||
void CloneAsDirectRoute(nsHttpConnectionInfo **outParam);
|
||||
|
@ -100,6 +107,8 @@ public:
|
|||
{ mHashKey.SetCharAt(aNoSpdy ? 'X' : '.', 5); }
|
||||
bool GetNoSpdy() const { return mHashKey.CharAt(5) == 'X'; }
|
||||
|
||||
const nsCString &GetNetworkInterfaceId() const { return mNetworkInterfaceId; }
|
||||
|
||||
const nsCString &GetHost() { return mHost; }
|
||||
const nsCString &GetNPNToken() { return mNPNToken; }
|
||||
const nsCString &GetUsername() { return mUsername; }
|
||||
|
@ -136,6 +145,7 @@ private:
|
|||
|
||||
nsCString mHashKey;
|
||||
nsCString mHost;
|
||||
nsCString mNetworkInterfaceId;
|
||||
int32_t mPort;
|
||||
nsCString mUsername;
|
||||
nsCString mAuthenticationHost;
|
||||
|
|
|
@ -3166,6 +3166,10 @@ nsHalfOpenSocket::SetupStreams(nsISocketTransport **transport,
|
|||
|
||||
socketTransport->SetQoSBits(gHttpHandler->GetQoSBits());
|
||||
|
||||
if (!mEnt->mConnInfo->GetNetworkInterfaceId().IsEmpty()) {
|
||||
socketTransport->SetNetworkInterfaceId(mEnt->mConnInfo->GetNetworkInterfaceId());
|
||||
}
|
||||
|
||||
rv = socketTransport->SetEventSink(this, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ interface nsIHttpUpgradeListener : nsISupports
|
|||
* using any feature exposed by this interface, be aware that this interface
|
||||
* will change and you will be broken. You have been warned.
|
||||
*/
|
||||
[scriptable, uuid(80ee20a9-757b-4c4e-8a4a-84cbb5981879)]
|
||||
[scriptable, uuid(ad8192a1-668e-4a47-bd77-081eb23e50fa)]
|
||||
interface nsIHttpChannelInternal : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -241,6 +241,11 @@ interface nsIHttpChannelInternal : nsISupports
|
|||
*/
|
||||
readonly attribute nsIURI topWindowURI;
|
||||
|
||||
/**
|
||||
* The network interface id that's associated with this channel.
|
||||
*/
|
||||
attribute ACString networkInterfaceId;
|
||||
|
||||
/**
|
||||
* Used only by nsChannelClassifier to resume connecting or abort the
|
||||
* channel after a remote classification verdict.
|
||||
|
|
Загрузка…
Ссылка в новой задаче