Bug 1535697 - Part 7: Pass the isolated flag to the nsHttpConnectionInfo constructor when cloning the object; r=michal

Building the hashkey for these objects will soon depend on the isolated flag,
therefore we need to ensure that it is available when cloning the objects
inside the constructor.  This patch refactors the clone method to avoid using
SetIsolated().

Differential Revision: https://phabricator.services.mozilla.com/D28377

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-04-29 17:09:41 +00:00
parent b1bd6e9654
commit 2422b99643
2 changed files with 43 additions and 11 deletions

View File

@ -44,19 +44,28 @@ nsHttpConnectionInfo::nsHttpConnectionInfo(
const nsACString &originHost, int32_t originPort,
const nsACString &npnToken, const nsACString &username,
const nsACString &topWindowOrigin, nsProxyInfo *proxyInfo,
const OriginAttributes &originAttributes, bool endToEndSSL)
: mRoutedPort(443), mIsolated(0), mLessThanTls13(false) {
const OriginAttributes &originAttributes, bool endToEndSSL, bool isolated)
: mRoutedPort(443), mIsolated(isolated), mLessThanTls13(false) {
Init(originHost, originPort, npnToken, username, topWindowOrigin, proxyInfo,
originAttributes, endToEndSSL);
}
nsHttpConnectionInfo::nsHttpConnectionInfo(
const nsACString &originHost, int32_t originPort,
const nsACString &npnToken, const nsACString &username,
const nsACString &topWindowOrigin, nsProxyInfo *proxyInfo,
const OriginAttributes &originAttributes, bool endToEndSSL)
: nsHttpConnectionInfo(originHost, originPort, npnToken, username,
topWindowOrigin, proxyInfo, originAttributes,
endToEndSSL, false) {}
nsHttpConnectionInfo::nsHttpConnectionInfo(
const nsACString &originHost, int32_t originPort,
const nsACString &npnToken, const nsACString &username,
const nsACString &topWindowOrigin, nsProxyInfo *proxyInfo,
const OriginAttributes &originAttributes, const nsACString &routedHost,
int32_t routedPort)
: mIsolated(0), mLessThanTls13(false) {
int32_t routedPort, bool isolated)
: mIsolated(isolated), mLessThanTls13(false) {
mEndToEndSSL = true; // so DefaultPort() works
mRoutedPort = routedPort == -1 ? DefaultPort() : routedPort;
@ -67,6 +76,16 @@ nsHttpConnectionInfo::nsHttpConnectionInfo(
originAttributes, true);
}
nsHttpConnectionInfo::nsHttpConnectionInfo(
const nsACString &originHost, int32_t originPort,
const nsACString &npnToken, const nsACString &username,
const nsACString &topWindowOrigin, nsProxyInfo *proxyInfo,
const OriginAttributes &originAttributes, const nsACString &routedHost,
int32_t routedPort)
: nsHttpConnectionInfo(originHost, originPort, npnToken, username,
topWindowOrigin, proxyInfo, originAttributes,
routedHost, routedPort, false) {}
void nsHttpConnectionInfo::Init(const nsACString &host, int32_t port,
const nsACString &npnToken,
const nsACString &username,
@ -248,14 +267,14 @@ void nsHttpConnectionInfo::SetOriginServer(const nsACString &host,
already_AddRefed<nsHttpConnectionInfo> nsHttpConnectionInfo::Clone() const {
RefPtr<nsHttpConnectionInfo> clone;
if (mRoutedHost.IsEmpty()) {
clone = new nsHttpConnectionInfo(mOrigin, mOriginPort, mNPNToken, mUsername,
mTopWindowOrigin, mProxyInfo,
mOriginAttributes, mEndToEndSSL);
clone = new nsHttpConnectionInfo(
mOrigin, mOriginPort, mNPNToken, mUsername, mTopWindowOrigin,
mProxyInfo, mOriginAttributes, mEndToEndSSL, mIsolated);
} else {
MOZ_ASSERT(mEndToEndSSL);
clone = new nsHttpConnectionInfo(
mOrigin, mOriginPort, mNPNToken, mUsername, mTopWindowOrigin,
mProxyInfo, mOriginAttributes, mRoutedHost, mRoutedPort);
mProxyInfo, mOriginAttributes, mRoutedHost, mRoutedPort, mIsolated);
}
// Make sure the anonymous, insecure-scheme, and private flags are transferred
@ -264,7 +283,6 @@ already_AddRefed<nsHttpConnectionInfo> nsHttpConnectionInfo::Clone() const {
clone->SetInsecureScheme(GetInsecureScheme());
clone->SetNoSpdy(GetNoSpdy());
clone->SetBeConservative(GetBeConservative());
clone->SetIsolated(GetIsolated());
clone->SetTlsFlags(GetTlsFlags());
clone->SetTrrUsed(GetTrrUsed());
clone->SetTrrDisabled(GetTrrDisabled());
@ -284,14 +302,13 @@ void nsHttpConnectionInfo::CloneAsDirectRoute(nsHttpConnectionInfo **outCI) {
RefPtr<nsHttpConnectionInfo> clone = new nsHttpConnectionInfo(
mOrigin, mOriginPort, EmptyCString(), mUsername, mTopWindowOrigin,
mProxyInfo, mOriginAttributes, mEndToEndSSL);
mProxyInfo, mOriginAttributes, mEndToEndSSL, mIsolated);
// Make sure the anonymous, insecure-scheme, and private flags are transferred
clone->SetAnonymous(GetAnonymous());
clone->SetPrivate(GetPrivate());
clone->SetInsecureScheme(GetInsecureScheme());
clone->SetNoSpdy(GetNoSpdy());
clone->SetBeConservative(GetBeConservative());
clone->SetIsolated(GetIsolated());
clone->SetTlsFlags(GetTlsFlags());
clone->SetTrrUsed(GetTrrUsed());
clone->SetTrrDisabled(GetTrrDisabled());

View File

@ -183,6 +183,21 @@ class nsHttpConnectionInfo final : public ARefBase {
}
private:
// These constructor versions are intended to only be used from Clone().
nsHttpConnectionInfo(const nsACString &originHost, int32_t originPort,
const nsACString &npnToken, const nsACString &username,
const nsACString &topWindowOrigin,
nsProxyInfo *proxyInfo,
const OriginAttributes &originAttributes,
bool endToEndSSL, bool isolated);
nsHttpConnectionInfo(const nsACString &originHost, int32_t originPort,
const nsACString &npnToken, const nsACString &username,
const nsACString &topWindowOrigin,
nsProxyInfo *proxyInfo,
const OriginAttributes &originAttributes,
const nsACString &routedHost, int32_t routedPort,
bool isolated);
void Init(const nsACString &host, int32_t port, const nsACString &npnToken,
const nsACString &username, const nsACString &topWindowOrigin,
nsProxyInfo *proxyInfo, const OriginAttributes &originAttributes,