Bug 1503011 - Make sure DNSPrefetch is called. r=mayhemer

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dragana Damjanovic 2018-10-30 10:27:28 +00:00
Родитель 8a4d8f4fa4
Коммит dd7c87fd1f
2 изменённых файлов: 23 добавлений и 15 удалений

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

@ -6687,6 +6687,7 @@ nsHttpChannel::BeginConnect()
}
if (!(mLoadFlags & LOAD_CLASSIFY_URI)) {
MaybeStartDNSPrefetch();
return ContinueBeginConnectWithResult();
}
@ -6721,21 +6722,9 @@ nsHttpChannel::BeginConnect()
return NS_OK;
}
nsresult
nsHttpChannel::BeginConnectActual()
void
nsHttpChannel::MaybeStartDNSPrefetch()
{
if (mCanceled) {
return mStatus;
}
if (mTrackingProtectionCancellationPending) {
LOG(("Waiting for tracking protection cancellation in BeginConnectActual [this=%p]\n", this));
MOZ_ASSERT(!mCallOnResume ||
mCallOnResume == &nsHttpChannel::HandleContinueCancelledByTrackingProtection,
"We should be paused waiting for cancellation from tracking protection");
return NS_OK;
}
if (!mConnectionInfo->UsingHttpProxy() &&
!(mLoadFlags & (LOAD_NO_NETWORK_IO | LOAD_ONLY_FROM_CACHE))) {
// Start a DNS lookup very early in case the real open is queued the DNS can
@ -6751,7 +6740,7 @@ nsHttpChannel::BeginConnectActual()
// be correct, and even when it isn't, the timing still represents _a_
// valid DNS lookup timing for the site, even if it is not _the_
// timing we used.
LOG(("nsHttpChannel::BeginConnect [this=%p] prefetching%s\n",
LOG(("nsHttpChannel::MaybeStartDNSPrefetch [this=%p] prefetching%s\n",
this, mCaps & NS_HTTP_REFRESH_DNS ? ", refresh requested" : ""));
OriginAttributes originAttributes;
NS_GetOriginAttributes(this, originAttributes);
@ -6759,6 +6748,24 @@ nsHttpChannel::BeginConnectActual()
this, mTimingEnabled);
mDNSPrefetch->PrefetchHigh(mCaps & NS_HTTP_REFRESH_DNS);
}
}
nsresult
nsHttpChannel::BeginConnectActual()
{
if (mCanceled) {
return mStatus;
}
if (mTrackingProtectionCancellationPending) {
LOG(("Waiting for tracking protection cancellation in BeginConnectActual [this=%p]\n", this));
MOZ_ASSERT(!mCallOnResume ||
mCallOnResume == &nsHttpChannel::HandleContinueCancelledByTrackingProtection,
"We should be paused waiting for cancellation from tracking protection");
return NS_OK;
}
MaybeStartDNSPrefetch();
nsresult rv = ContinueBeginConnectWithResult();
if (NS_FAILED(rv)) {

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

@ -300,6 +300,7 @@ private:
// Connections will only be established in this function.
// (including DNS prefetch and speculative connection.)
nsresult BeginConnectActual();
void MaybeStartDNSPrefetch();
// We might synchronously or asynchronously call BeginConnectActual,
// which includes DNS prefetch and speculative connection, according to