Bug 1569004 - Convert dom.min_timeout_value to StaticPref r=njn
authorkriswright <kwright@mozilla.com>
Fri, 26 Jul 2019 19:15:44 +0000
changeset 485154 2655857e489d107844616ce2feeef0da41aa106a
parent 485153 d4061d6bc8c5f4ad9183da40fe4c475bfc154f0f
child 485155 a5d0fdf989304bbb9fdad74b0f8ac15baad8ff3f
push id36360
push userccoroiu@mozilla.com
push dateMon, 29 Jul 2019 21:38:39 +0000
treeherdermozilla-central@927abd2c418b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1569004
milestone70.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 1569004 - Convert dom.min_timeout_value to StaticPref r=njn Converts dom.min_timeout_value varcache pref from TimeoutManager::Initialize() to a static pref, and removes its entry and associated constants from TimeoutManager.cpp and all.js Differential Revision: https://phabricator.services.mozilla.com/D39416
dom/base/TimeoutManager.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "TimeoutManager.h"
 #include "nsGlobalWindow.h"
 #include "mozilla/Logging.h"
 #include "mozilla/PerformanceCounter.h"
+#include "mozilla/StaticPrefs_dom.h"
 #include "mozilla/StaticPrefs_privacy.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/ThrottledEventQueue.h"
 #include "mozilla/TimeStamp.h"
 #include "nsIDocShell.h"
 #include "nsINamed.h"
 #include "mozilla/dom/DocGroup.h"
 #include "mozilla/dom/PopupBlocker.h"
@@ -29,21 +30,19 @@
 using namespace mozilla;
 using namespace mozilla::dom;
 
 LazyLogModule gTimeoutLog("Timeout");
 
 static int32_t gRunningTimeoutDepth = 0;
 
 // The default shortest interval/timeout we permit
-#define DEFAULT_MIN_CLAMP_TIMEOUT_VALUE 4                   // 4ms
 #define DEFAULT_MIN_BACKGROUND_TIMEOUT_VALUE 1000           // 1000ms
 #define DEFAULT_MIN_TRACKING_TIMEOUT_VALUE 4                // 4ms
 #define DEFAULT_MIN_TRACKING_BACKGROUND_TIMEOUT_VALUE 1000  // 1000ms
-static int32_t gMinClampTimeoutValue = 0;
 static int32_t gMinBackgroundTimeoutValue = 0;
 static int32_t gMinTrackingTimeoutValue = 0;
 static int32_t gMinTrackingBackgroundTimeoutValue = 0;
 static int32_t gTimeoutThrottlingDelay = 0;
 
 #define DEFAULT_BACKGROUND_BUDGET_REGENERATION_FACTOR 100  // 1ms per 100ms
 #define DEFAULT_FOREGROUND_BUDGET_REGENERATION_FACTOR 1    // 1ms per 1ms
 #define DEFAULT_BACKGROUND_THROTTLING_MAX_BUDGET 50        // 50ms
@@ -321,18 +320,19 @@ bool TimeoutManager::IsInvalidFiringId(u
 // uses 5.
 #define DOM_CLAMP_TIMEOUT_NESTING_LEVEL 5u
 
 TimeDuration TimeoutManager::CalculateDelay(Timeout* aTimeout) const {
   MOZ_DIAGNOSTIC_ASSERT(aTimeout);
   TimeDuration result = aTimeout->mInterval;
 
   if (aTimeout->mNestingLevel >= DOM_CLAMP_TIMEOUT_NESTING_LEVEL) {
-    result = TimeDuration::Max(
-        result, TimeDuration::FromMilliseconds(gMinClampTimeoutValue));
+    uint32_t minTimeoutValue = StaticPrefs::dom_min_timeout_value();
+    result = TimeDuration::Max(result,
+                               TimeDuration::FromMilliseconds(minTimeoutValue));
   }
 
   return result;
 }
 
 PerformanceCounter* TimeoutManager::GetPerformanceCounter() {
   Document* doc = mWindow.GetDocument();
   if (doc) {
@@ -474,18 +474,16 @@ TimeoutManager::~TimeoutManager() {
   mIdleExecutor->Shutdown();
 
   MOZ_LOG(gTimeoutLog, LogLevel::Debug,
           ("TimeoutManager %p destroyed\n", this));
 }
 
 /* static */
 void TimeoutManager::Initialize() {
-  Preferences::AddIntVarCache(&gMinClampTimeoutValue, "dom.min_timeout_value",
-                              DEFAULT_MIN_CLAMP_TIMEOUT_VALUE);
   Preferences::AddIntVarCache(&gMinBackgroundTimeoutValue,
                               "dom.min_background_timeout_value",
                               DEFAULT_MIN_BACKGROUND_TIMEOUT_VALUE);
   Preferences::AddIntVarCache(&gMinTrackingTimeoutValue,
                               "dom.min_tracking_timeout_value",
                               DEFAULT_MIN_TRACKING_TIMEOUT_VALUE);
   Preferences::AddIntVarCache(&gMinTrackingBackgroundTimeoutValue,
                               "dom.min_tracking_background_timeout_value",
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1418,16 +1418,22 @@
   value: false
   mirror: always
 
 - name: dom.metaElement.setCookie.allowed
   type: bool
   value: false
   mirror: always
 
+# Timeout clamp in ms for timeouts we clamp.
+- name: dom.min_timeout_value
+  type: int32_t
+  value: 4
+  mirror: always
+
 # Is support for module scripts (<script type="module">) enabled for content?
 - name: dom.moduleScripts.enabled
   type: bool
   value: true
   mirror: always
 
 # Is support for mozBrowser frames enabled?
 - name: dom.mozBrowserFramesEnabled
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1079,18 +1079,16 @@ pref("dom.storage.default_quota",      5
 pref("dom.storage.shadow_writes", true);
 pref("dom.storage.snapshot_prefill", 16384);
 pref("dom.storage.snapshot_gradual_prefill", 4096);
 pref("dom.storage.snapshot_reusing", true);
 pref("dom.storage.client_validation", true);
 
 pref("dom.send_after_paint_to_content", false);
 
-// Timeout clamp in ms for timeouts we clamp
-pref("dom.min_timeout_value", 4);
 // And for background windows
 pref("dom.min_background_timeout_value", 1000);
 // Timeout clamp in ms for tracking timeouts we clamp
 // Note that this requires the privacy.trackingprotection.annotate_channels pref to be on in order to have any effect.
 pref("dom.min_tracking_timeout_value", 4);
 // And for background windows
 // Note that this requires the privacy.trackingprotection.annotate_channels pref to be on in order to have any effect.
 pref("dom.min_tracking_background_timeout_value", 4);