Bug 1535697 - Part 2: Represent whether the channel is isolated by anti-tracking as a separate axis on the connection info hash key; r=michal

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-04-29 17:09:37 +00:00
Родитель 7fb3204d5c
Коммит 3fcf2c3bae
4 изменённых файлов: 15 добавлений и 6 удалений

Просмотреть файл

@ -627,11 +627,10 @@ nsresult nsHttpChannel::ContinueOnBeforeConnect(bool aShouldUpgrade,
mCaps |= NS_HTTP_DISABLE_TRR;
}
bool isIsolated = mPrivateBrowsing || IsIsolated();
// Finalize ConnectionInfo flags before SpeculativeConnect
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
mConnectionInfo->SetPrivate(isIsolated);
mConnectionInfo->SetPrivate(mPrivateBrowsing);
mConnectionInfo->SetIsolated(IsIsolated());
mConnectionInfo->SetNoSpdy(mCaps & NS_HTTP_DISALLOW_SPDY);
mConnectionInfo->SetBeConservative((mCaps & NS_HTTP_BE_CONSERVATIVE) ||
mBeConservative);

Просмотреть файл

@ -131,8 +131,9 @@ void nsHttpConnectionInfo::BuildHashKey() {
// byte 4 is I/. I is for insecure scheme on TLS for http:// uris
// byte 5 is X/. X is for disallow_spdy flag
// byte 6 is C/. C is for be Conservative
// byte 7 is i/. i is for isolated
mHashKey.AssignLiteral(".......[tlsflags0x00000000]");
mHashKey.AssignLiteral("........[tlsflags0x00000000]");
mHashKey.Append(keyHost);
mHashKey.Append(':');
@ -249,6 +250,7 @@ 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());
@ -275,6 +277,7 @@ void nsHttpConnectionInfo::CloneAsDirectRoute(nsHttpConnectionInfo **outCI) {
clone->SetInsecureScheme(GetInsecureScheme());
clone->SetNoSpdy(GetNoSpdy());
clone->SetBeConservative(GetBeConservative());
clone->SetIsolated(GetIsolated());
clone->SetTlsFlags(GetTlsFlags());
clone->SetTrrUsed(GetTrrUsed());
clone->SetTrrDisabled(GetTrrDisabled());
@ -328,7 +331,7 @@ void nsHttpConnectionInfo::SetIPv6Disabled(bool aNoIPv6) {
void nsHttpConnectionInfo::SetTlsFlags(uint32_t aTlsFlags) {
mTlsFlags = aTlsFlags;
mHashKey.Replace(18, 8, nsPrintfCString("%08x", mTlsFlags));
mHashKey.Replace(19, 8, nsPrintfCString("%08x", mTlsFlags));
}
bool nsHttpConnectionInfo::UsingProxy() {

Просмотреть файл

@ -122,6 +122,11 @@ class nsHttpConnectionInfo final : public ARefBase {
}
bool GetBeConservative() const { return mHashKey.CharAt(6) == 'C'; }
void SetIsolated(bool aIsolated) {
mHashKey.SetCharAt(aIsolated ? 'i' : '.', 7);
}
bool GetIsolated() const { return mHashKey.CharAt(7) == 'i'; }
void SetTlsFlags(uint32_t aTlsFlags);
uint32_t GetTlsFlags() const { return mTlsFlags; }

Просмотреть файл

@ -4025,7 +4025,9 @@ nsresult nsHttpConnectionMgr::nsHalfOpenSocket::SetupStreams(
if (mCaps & NS_HTTP_LOAD_ANONYMOUS)
tmpFlags |= nsISocketTransport::ANONYMOUS_CONNECT;
if (ci->GetPrivate()) tmpFlags |= nsISocketTransport::NO_PERMANENT_STORAGE;
if (ci->GetPrivate() || ci->GetIsolated()) {
tmpFlags |= nsISocketTransport::NO_PERMANENT_STORAGE;
}
if (ci->GetLessThanTls13()) {
tmpFlags |= nsISocketTransport::DONT_TRY_ESNI;