Bug 1548253 - Port pref cache variables of nsContentUtils to StaticPrefs - network.http.tailing.enabled, r=Ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 01 May 2019 21:10:31 +0000
changeset 530999 f218dd7cbfadac37309ccc3273f3320815d669ef
parent 530998 2635d54614b26d88e167e2d71bf18468680012a8
child 531000 431944c99e17780bdb1a99e150620eceeedd40ae
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1548253
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1548253 - Port pref cache variables of nsContentUtils to StaticPrefs - network.http.tailing.enabled, r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D29520
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/fetch/FetchDriver.cpp
dom/script/ScriptLoader.cpp
dom/xhr/XMLHttpRequestMainThread.cpp
image/imgLoader.cpp
modules/libpref/init/StaticPrefList.h
modules/libpref/init/all.js
netwerk/url-classifier/UrlClassifierCommon.cpp
toolkit/components/places/FaviconHelpers.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -305,17 +305,16 @@ bool nsContentUtils::sAllowXULXBL_for_fi
 nsString* nsContentUtils::sShiftText = nullptr;
 nsString* nsContentUtils::sControlText = nullptr;
 nsString* nsContentUtils::sMetaText = nullptr;
 nsString* nsContentUtils::sOSText = nullptr;
 nsString* nsContentUtils::sAltText = nullptr;
 nsString* nsContentUtils::sModifierSeparator = nullptr;
 
 bool nsContentUtils::sInitialized = false;
-bool nsContentUtils::sTailingEnabled = false;
 bool nsContentUtils::sShowInputPlaceholderOnFocus = true;
 bool nsContentUtils::sAutoFocusEnabled = true;
 #ifndef RELEASE_OR_BETA
 bool nsContentUtils::sBypassCSSOMOriginCheck = false;
 #endif
 
 bool nsContentUtils::sIsBytecodeCacheEnabled = false;
 int32_t nsContentUtils::sBytecodeCacheStrategy = 0;
@@ -610,19 +609,16 @@ nsresult nsContentUtils::Init() {
 
   Preferences::AddBoolVarCache(&sAllowXULXBL_for_file,
                                "dom.allow_XUL_XBL_for_file");
 
 #ifndef RELEASE_OR_BETA
   sBypassCSSOMOriginCheck = getenv("MOZ_BYPASS_CSSOM_ORIGIN_CHECK");
 #endif
 
-  Preferences::AddBoolVarCache(&sTailingEnabled, "network.http.tailing.enabled",
-                               true);
-
   Preferences::AddBoolVarCache(&sShowInputPlaceholderOnFocus,
                                "dom.placeholder.show_on_focus", true);
 
   Preferences::AddBoolVarCache(&sAutoFocusEnabled, "browser.autofocus", true);
 
   Preferences::AddBoolVarCache(&sIsBytecodeCacheEnabled,
                                "dom.script_loader.bytecode_cache.enabled",
                                false);
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -3183,19 +3183,16 @@ class nsContentUtils {
   static uint64_t GenerateBrowsingContextId();
 
   /**
    * Determine whether or not the user is currently interacting with the web
    * browser. This method is safe to call from off of the main thread.
    */
   static bool GetUserIsInteracting();
 
-  // Whether tracker tailing is turned on - "network.http.tailing.enabled".
-  static bool IsTailingEnabled() { return sTailingEnabled; }
-
   // Check pref "dom.placeholder.show_on_focus" to see
   // if we want to show the placeholder inside input elements
   // when they have focus.
   static bool ShowInputPlaceholderOnFocus() {
     return sShowInputPlaceholderOnFocus;
   }
 
   // Check pref "browser.autofocus" to see if we want to enable autofocusing
@@ -3413,17 +3410,16 @@ class nsContentUtils {
   static AutoTArray<nsCOMPtr<nsIRunnable>, 8>* sBlockedScriptRunners;
   static uint32_t sRunnersCountAtFirstBlocker;
   static uint32_t sScriptBlockerCountWhereRunnersPrevented;
 
   static nsIInterfaceRequestor* sSameOriginChecker;
 
   static bool sIsHandlingKeyBoardEvent;
   static bool sAllowXULXBL_for_file;
-  static bool sTailingEnabled;
   static bool sShowInputPlaceholderOnFocus;
   static bool sAutoFocusEnabled;
 #ifndef RELEASE_OR_BETA
   static bool sBypassCSSOMOriginCheck;
 #endif
   static bool sIsBytecodeCacheEnabled;
   static int32_t sBytecodeCacheStrategy;
   static bool sAntiTrackingControlCenterUIEnabled;
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -687,17 +687,17 @@ nsresult FetchDriver::HttpFetch(
   // in the request.
   if (mRequest->Mode() == RequestMode::Cors) {
     AutoTArray<nsCString, 5> unsafeHeaders;
     mRequest->Headers()->GetUnsafeHeaders(unsafeHeaders);
     nsCOMPtr<nsILoadInfo> loadInfo = chan->LoadInfo();
     loadInfo->SetCorsPreflightInfo(unsafeHeaders, false);
   }
 
-  if (mIsTrackingFetch && nsContentUtils::IsTailingEnabled() && cos) {
+  if (mIsTrackingFetch && StaticPrefs::network_http_tailing_enabled() && cos) {
     cos->AddClassFlags(nsIClassOfService::Throttleable |
                        nsIClassOfService::Tail);
   }
 
   if (mIsTrackingFetch &&
       StaticPrefs::privacy_trackingprotection_lower_network_priority()) {
     nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(chan);
     if (p) {
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -24,16 +24,17 @@
 #include "nsCycleCollectionParticipant.h"
 #include "nsIContent.h"
 #include "nsJSUtils.h"
 #include "mozilla/dom/DocGroup.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/SRILogHelper.h"
 #include "mozilla/net/UrlClassifierFeatureFactory.h"
+#include "mozilla/StaticPrefs.h"
 #include "nsGkAtoms.h"
 #include "nsNetUtil.h"
 #include "nsGlobalWindowInner.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIPrincipal.h"
 #include "nsJSPrincipals.h"
@@ -1311,21 +1312,21 @@ nsresult ScriptLoader::StartLoad(ScriptL
 
   nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(channel));
   if (cos) {
     if (aRequest->mScriptFromHead && aRequest->IsBlockingScript()) {
       // synchronous head scripts block loading of most other non js/css
       // content such as images, Leader implicitely disallows tailing
       cos->AddClassFlags(nsIClassOfService::Leader);
     } else if (aRequest->IsDeferredScript() &&
-               !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.
+               !StaticPrefs::network_http_tailing_enabled()) {
+      // Bug 1395525 and the !StaticPrefs::network_http_tailing_enabled() 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.
 
       // head/body deferred scripts are blocked by leaders but are not
       // allowed tailing because they block DOMContentLoaded
       cos->AddClassFlags(nsIClassOfService::TailForbidden);
     } else {
       // other scripts (=body sync or head/body async) are neither blocked
       // nor prioritized
       cos->AddClassFlags(nsIClassOfService::Unblocked);
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -2423,17 +2423,17 @@ void XMLHttpRequestMainThread::MaybeLowe
   if (!nsJSUtils::GetCallingLocation(cx, fileNameString)) {
     return;
   }
 
   if (!doc->IsScriptTracking(fileNameString)) {
     return;
   }
 
-  if (nsContentUtils::IsTailingEnabled()) {
+  if (StaticPrefs::network_http_tailing_enabled()) {
     nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(mChannel);
     if (cos) {
       // Adding TailAllowed to overrule the Unblocked flag, but to preserve
       // the effect of Unblocked when tailing is off.
       cos->AddClassFlags(nsIClassOfService::Throttleable |
                          nsIClassOfService::Tail |
                          nsIClassOfService::TailAllowed);
     }
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -12,16 +12,17 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/Move.h"
 #include "mozilla/NullPrincipal.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ChaosMode.h"
 #include "mozilla/LoadInfo.h"
+#include "mozilla/StaticPrefs.h"
 
 #include "nsImageModule.h"
 #include "imgRequestProxy.h"
 
 #include "nsCOMPtr.h"
 
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
@@ -2217,17 +2218,17 @@ nsresult imgLoader::LoadImage(
              this, request.get()));
 
     nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(newChannel));
     if (cos) {
       if (aUseUrgentStartForChannel) {
         cos->AddClassFlags(nsIClassOfService::UrgentStart);
       }
 
-      if (nsContentUtils::IsTailingEnabled() &&
+      if (StaticPrefs::network_http_tailing_enabled() &&
           aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON) {
         cos->AddClassFlags(nsIClassOfService::Throttleable |
                            nsIClassOfService::Tail);
         nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(newChannel));
         if (httpChannel) {
           Unused << httpChannel->SetRequestContextID(aRequestContextID);
         }
       }
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -2287,16 +2287,25 @@ VARCACHE_PREF(
 
 // Max time to shutdown the resolver threads
 VARCACHE_PREF(
   "network.dns.resolver_shutdown_timeout_ms",
    network_dns_resolver_shutdown_timeout_ms,
    uint32_t, 2000
 )
 
+// Some requests during a page load are marked as "tail", mainly trackers, but not only.
+// This pref controls whether such requests are put to the tail, behind other requests
+// emerging during page loading process.
+VARCACHE_PREF(
+  "network.http.tailing.enabled",
+   network_http_tailing_enabled,
+   bool, true
+)
+
 //---------------------------------------------------------------------------
 // ContentSessionStore prefs
 //---------------------------------------------------------------------------
 // Maximum number of bytes of DOMSessionStorage data we collect per origin.
 VARCACHE_PREF(
   "browser.sessionstore.dom_storage_limit",
   browser_sessionstore_dom_storage_limit,
   uint32_t, 2048
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2339,20 +2339,16 @@ pref("network.http.throttle.hold-time-ms
 // throttle for this period of time.  This prevents comet and unresponsive
 // http requests to engage long-standing throttling.
 pref("network.http.throttle.max-time-ms", 500);
 
 // Give higher priority to requests resulting from a user interaction event
 // like click-to-play, image fancy-box zoom, navigation.
 pref("network.http.on_click_priority", true);
 
-// Some requests during a page load are marked as "tail", mainly trackers, but not only.
-// This pref controls whether such requests are put to the tail, behind other requests
-// emerging during page loading process.
-pref("network.http.tailing.enabled", true);
 // When the page load has not yet reached DOMContentLoaded point, tail requestes are delayed
 // by (non-tailed requests count + 1) * delay-quantum milliseconds.
 pref("network.http.tailing.delay-quantum", 600);
 // The same as above, but applied after the document load reached DOMContentLoaded event.
 pref("network.http.tailing.delay-quantum-after-domcontentloaded", 100);
 // Upper limit for the calculated delay, prevents long standing and comet-like requests
 // tail forever.  This is in milliseconds as well.
 pref("network.http.tailing.delay-max", 6000);
--- a/netwerk/url-classifier/UrlClassifierCommon.cpp
+++ b/netwerk/url-classifier/UrlClassifierCommon.cpp
@@ -340,17 +340,17 @@ void SetClassificationFlagsHelper(nsICha
 
 void LowerPriorityHelper(nsIChannel* aChannel) {
   MOZ_ASSERT(aChannel);
 
   bool isBlockingResource = false;
 
   nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(aChannel));
   if (cos) {
-    if (nsContentUtils::IsTailingEnabled()) {
+    if (StaticPrefs::network_http_tailing_enabled()) {
       uint32_t cosFlags = 0;
       cos->GetClassFlags(&cosFlags);
       isBlockingResource =
           cosFlags & (nsIClassOfService::UrgentStart |
                       nsIClassOfService::Leader | nsIClassOfService::Unblocked);
 
       // Requests not allowed to be tailed are usually those with higher
       // prioritization.  That overweights being a tracker: don't throttle
--- a/toolkit/components/places/FaviconHelpers.cpp
+++ b/toolkit/components/places/FaviconHelpers.cpp
@@ -11,23 +11,23 @@
 #include "nsIClassOfService.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIPrincipal.h"
 
 #include "nsNavHistory.h"
 #include "nsFaviconService.h"
 #include "mozilla/storage.h"
 #include "mozilla/Telemetry.h"
+#include "mozilla/StaticPrefs.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 #include "nsStreamUtils.h"
 #include "nsStringStream.h"
 #include "nsIPrivateBrowsingChannel.h"
 #include "nsISupportsPriority.h"
-#include "nsContentUtils.h"
 #include <algorithm>
 #include <deque>
 #include "mozilla/gfx/2D.h"
 #include "imgIContainer.h"
 #include "ImageOps.h"
 #include "imgIEncoder.h"
 
 using namespace mozilla::places;
@@ -587,17 +587,17 @@ nsresult AsyncFetchAndSetIconForPage::Fe
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCOMPtr<nsISupportsPriority> priorityChannel = do_QueryInterface(channel);
   if (priorityChannel) {
     priorityChannel->AdjustPriority(nsISupportsPriority::PRIORITY_LOWEST);
   }
 
-  if (nsContentUtils::IsTailingEnabled()) {
+  if (StaticPrefs::network_http_tailing_enabled()) {
     nsCOMPtr<nsIClassOfService> cos = do_QueryInterface(channel);
     if (cos) {
       cos->AddClassFlags(nsIClassOfService::Tail |
                          nsIClassOfService::Throttleable);
     }
 
     nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
     if (httpChannel) {