зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1395525 - Make all changes landed as part of tracker request tailing preferrable. r=dragana
This commit is contained in:
Родитель
9084ce73bb
Коммит
8d492fe637
|
@ -304,6 +304,7 @@ bool nsContentUtils::sGetBoxQuadsEnabled = false;
|
||||||
bool nsContentUtils::sSkipCursorMoveForSameValueSet = false;
|
bool nsContentUtils::sSkipCursorMoveForSameValueSet = false;
|
||||||
bool nsContentUtils::sRequestIdleCallbackEnabled = false;
|
bool nsContentUtils::sRequestIdleCallbackEnabled = false;
|
||||||
bool nsContentUtils::sLowerNetworkPriority = false;
|
bool nsContentUtils::sLowerNetworkPriority = false;
|
||||||
|
bool nsContentUtils::sTailingEnabled = false;
|
||||||
bool nsContentUtils::sShowInputPlaceholderOnFocus = true;
|
bool nsContentUtils::sShowInputPlaceholderOnFocus = true;
|
||||||
bool nsContentUtils::sAutoFocusEnabled = true;
|
bool nsContentUtils::sAutoFocusEnabled = true;
|
||||||
#ifndef RELEASE_OR_BETA
|
#ifndef RELEASE_OR_BETA
|
||||||
|
@ -768,6 +769,9 @@ nsContentUtils::Init()
|
||||||
Preferences::AddBoolVarCache(&sLowerNetworkPriority,
|
Preferences::AddBoolVarCache(&sLowerNetworkPriority,
|
||||||
"privacy.trackingprotection.lower_network_priority", false);
|
"privacy.trackingprotection.lower_network_priority", false);
|
||||||
|
|
||||||
|
Preferences::AddBoolVarCache(&sTailingEnabled,
|
||||||
|
"network.http.tailing.enabled", true);
|
||||||
|
|
||||||
Preferences::AddBoolVarCache(&sShowInputPlaceholderOnFocus,
|
Preferences::AddBoolVarCache(&sShowInputPlaceholderOnFocus,
|
||||||
"dom.placeholder.show_on_focus", true);
|
"dom.placeholder.show_on_focus", true);
|
||||||
|
|
||||||
|
|
|
@ -3093,6 +3093,9 @@ public:
|
||||||
// if we want to lower the priority of the channel.
|
// if we want to lower the priority of the channel.
|
||||||
static bool IsLowerNetworkPriority() { return sLowerNetworkPriority; }
|
static bool IsLowerNetworkPriority() { return sLowerNetworkPriority; }
|
||||||
|
|
||||||
|
// Whether tracker tailing is turned on - "network.http.tailing.enabled".
|
||||||
|
static bool IsTailingEnabled() { return sTailingEnabled; }
|
||||||
|
|
||||||
// Check pref "dom.placeholder.show_on_focus" to see
|
// Check pref "dom.placeholder.show_on_focus" to see
|
||||||
// if we want to show the placeholder inside input elements
|
// if we want to show the placeholder inside input elements
|
||||||
// when they have focus.
|
// when they have focus.
|
||||||
|
@ -3284,6 +3287,7 @@ private:
|
||||||
static bool sSkipCursorMoveForSameValueSet;
|
static bool sSkipCursorMoveForSameValueSet;
|
||||||
static bool sRequestIdleCallbackEnabled;
|
static bool sRequestIdleCallbackEnabled;
|
||||||
static bool sLowerNetworkPriority;
|
static bool sLowerNetworkPriority;
|
||||||
|
static bool sTailingEnabled;
|
||||||
static bool sShowInputPlaceholderOnFocus;
|
static bool sShowInputPlaceholderOnFocus;
|
||||||
static bool sAutoFocusEnabled;
|
static bool sAutoFocusEnabled;
|
||||||
#ifndef RELEASE_OR_BETA
|
#ifndef RELEASE_OR_BETA
|
||||||
|
|
|
@ -378,10 +378,12 @@ FetchDriver::HttpFetch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsTrackingFetch && nsContentUtils::IsLowerNetworkPriority()) {
|
if (mIsTrackingFetch && nsContentUtils::IsTailingEnabled()) {
|
||||||
cos->AddClassFlags(nsIClassOfService::Throttleable |
|
cos->AddClassFlags(nsIClassOfService::Throttleable |
|
||||||
nsIClassOfService::Tail);
|
nsIClassOfService::Tail);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mIsTrackingFetch && nsContentUtils::IsLowerNetworkPriority()) {
|
||||||
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(chan);
|
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(chan);
|
||||||
if (p) {
|
if (p) {
|
||||||
p->SetPriority(nsISupportsPriority::PRIORITY_LOWEST);
|
p->SetPriority(nsISupportsPriority::PRIORITY_LOWEST);
|
||||||
|
|
|
@ -1067,7 +1067,12 @@ ScriptLoader::StartLoad(ScriptLoadRequest* aRequest)
|
||||||
// synchronous head scripts block loading of most other non js/css
|
// synchronous head scripts block loading of most other non js/css
|
||||||
// content such as images, Leader implicitely disallows tailing
|
// content such as images, Leader implicitely disallows tailing
|
||||||
cos->AddClassFlags(nsIClassOfService::Leader);
|
cos->AddClassFlags(nsIClassOfService::Leader);
|
||||||
} else if (defer && !async) {
|
} else if (defer && (!async || !nsContentUtils::IsTailingEnabled())) {
|
||||||
|
// Bug 1395525 and the !nsContentUtils::IsTailingEnabled() bit:
|
||||||
|
// We want to make sure that turing tailing off by the pref makes
|
||||||
|
// the browser behave exactly the same way as before landing
|
||||||
|
// the tailing patch, which has added the "&& !async" part.
|
||||||
|
|
||||||
// head/body deferred scripts are blocked by leaders but are not
|
// head/body deferred scripts are blocked by leaders but are not
|
||||||
// allowed tailing because they block DOMContentLoaded
|
// allowed tailing because they block DOMContentLoaded
|
||||||
cos->AddClassFlags(nsIClassOfService::TailForbidden);
|
cos->AddClassFlags(nsIClassOfService::TailForbidden);
|
||||||
|
|
|
@ -2621,13 +2621,15 @@ XMLHttpRequestMainThread::MaybeLowerChannelPriority()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(mChannel);
|
if (nsContentUtils::IsTailingEnabled()) {
|
||||||
if (cos) {
|
nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(mChannel);
|
||||||
// Adding TailAllowed to overrule the Unblocked flag, but to preserve
|
if (cos) {
|
||||||
// the effect of Unblocked when tailing is off.
|
// Adding TailAllowed to overrule the Unblocked flag, but to preserve
|
||||||
cos->AddClassFlags(nsIClassOfService::Throttleable |
|
// the effect of Unblocked when tailing is off.
|
||||||
nsIClassOfService::Tail |
|
cos->AddClassFlags(nsIClassOfService::Throttleable |
|
||||||
nsIClassOfService::TailAllowed);
|
nsIClassOfService::Tail |
|
||||||
|
nsIClassOfService::TailAllowed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mChannel);
|
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mChannel);
|
||||||
|
|
|
@ -210,16 +210,23 @@ LowerPriorityHelper(nsIChannel* aChannel)
|
||||||
|
|
||||||
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(aChannel));
|
nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(aChannel));
|
||||||
if (cos) {
|
if (cos) {
|
||||||
uint32_t cosFlags = 0;
|
if (nsContentUtils::IsTailingEnabled()) {
|
||||||
cos->GetClassFlags(&cosFlags);
|
uint32_t cosFlags = 0;
|
||||||
isBlockingResource = cosFlags & (nsIClassOfService::UrgentStart |
|
cos->GetClassFlags(&cosFlags);
|
||||||
nsIClassOfService::Leader |
|
isBlockingResource = cosFlags & (nsIClassOfService::UrgentStart |
|
||||||
nsIClassOfService::Unblocked);
|
nsIClassOfService::Leader |
|
||||||
|
nsIClassOfService::Unblocked);
|
||||||
|
|
||||||
|
// Requests not allowed to be tailed are usually those with higher
|
||||||
|
// prioritization. That overweights being a tracker: don't throttle
|
||||||
|
// them when not in background.
|
||||||
|
if (!(cosFlags & nsIClassOfService::TailForbidden)) {
|
||||||
|
cos->AddClassFlags(nsIClassOfService::Throttleable);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Yes, we even don't want to evaluate the isBlockingResource when tailing is off
|
||||||
|
// see bug 1395525.
|
||||||
|
|
||||||
// Requests not allowed to be tailed are usually those with higher
|
|
||||||
// prioritization. That overweights being a tracker: don't throttle
|
|
||||||
// them when not in background.
|
|
||||||
if (!(cosFlags & nsIClassOfService::TailForbidden)) {
|
|
||||||
cos->AddClassFlags(nsIClassOfService::Throttleable);
|
cos->AddClassFlags(nsIClassOfService::Throttleable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7576,7 +7576,6 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
|
||||||
"We should not call OnStopRequest twice");
|
"We should not call OnStopRequest twice");
|
||||||
mListener->OnStopRequest(this, mListenerContext, status);
|
mListener->OnStopRequest(this, mListenerContext, status);
|
||||||
mOnStopRequestCalled = true;
|
mOnStopRequestCalled = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveAsNonTailRequest();
|
RemoveAsNonTailRequest();
|
||||||
|
|
|
@ -594,10 +594,12 @@ AsyncFetchAndSetIconForPage::FetchFromNetwork() {
|
||||||
priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOWEST);
|
priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOWEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(channel);
|
if (nsContentUtils::IsTailingEnabled()) {
|
||||||
if (cos) {
|
nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(channel);
|
||||||
cos->AddClassFlags(nsIClassOfService::Tail |
|
if (cos) {
|
||||||
nsIClassOfService::Throttleable);
|
cos->AddClassFlags(nsIClassOfService::Tail |
|
||||||
|
nsIClassOfService::Throttleable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = channel->AsyncOpen2(this);
|
rv = channel->AsyncOpen2(this);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче