From 3420ea8aedc389e10891a2d22014fcb5804567cb Mon Sep 17 00:00:00 2001 From: Kristen Wright Date: Sun, 24 May 2020 18:27:35 +0000 Subject: [PATCH] Bug 1637708 - Convert toolkit.content-background-hang-monitor.disabled to a static pref r=njn Converts `toolkit.content-background-hang-monitor.disabled` to a static pref. Lets us remove the IsDisabled() call in the BHM. Differential Revision: https://phabricator.services.mozilla.com/D76376 --- modules/libpref/init/StaticPrefList.yaml | 6 ++++++ modules/libpref/init/all.js | 2 -- .../BackgroundHangMonitor.cpp | 16 +++------------- .../BackgroundHangMonitor.h | 5 ----- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 63b99e33f69a..9b480d588086 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -8729,6 +8729,12 @@ # Prefs starting with "toolkit." #--------------------------------------------------------------------------- +# Returns true if BHR is disabled. +- name: toolkit.content-background-hang-monitor.disabled + type: bool + value: false + mirror: always + - name: toolkit.scrollbox.horizontalScrollDistance type: RelaxedAtomicInt32 value: 5 diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 815f932b3e93..c06d379eb9b5 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -824,8 +824,6 @@ pref("toolkit.telemetry.unified", true); // Extra logging for AsyncShutdown barriers and phases pref("toolkit.asyncshutdown.log", false); -pref("toolkit.content-background-hang-monitor.disabled", false); - // Enable JS dump() function. // IMPORTANT: These prefs must be here even though they're also defined in // StaticPrefList.yaml. They are required because MOZILLA_OFFICIAL is false in diff --git a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp index e8c5c5afcf27..bde2638869f4 100644 --- a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp +++ b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp @@ -16,6 +16,7 @@ #include "mozilla/LinkedList.h" #include "mozilla/Monitor.h" #include "mozilla/Preferences.h" +#include "mozilla/StaticPrefs_toolkit.h" #include "mozilla/Services.h" #include "mozilla/StaticPtr.h" #include "mozilla/Telemetry.h" @@ -607,18 +608,6 @@ bool BackgroundHangMonitor::ShouldDisableOnBeta(const nsCString& clientID) { return strtol(suffix, NULL, 16) % BHR_BETA_MOD; } -bool BackgroundHangMonitor::IsDisabled() { - static bool sPrefCached = false; - static bool sPrefCacheValue = false; - if (!sPrefCached) { - sPrefCached = true; - Preferences::AddBoolVarCache( - &sPrefCacheValue, "toolkit.content-background-hang-monitor.disabled"); - } - - return sPrefCacheValue; -} - bool BackgroundHangMonitor::DisableOnBeta() { nsAutoCString clientID; nsresult rv = @@ -643,7 +632,8 @@ void BackgroundHangMonitor::Startup() { #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR MOZ_ASSERT(!BackgroundHangManager::sInstance, "Already initialized"); - if (XRE_IsContentProcess() && IsDisabled()) { + if (XRE_IsContentProcess() && + StaticPrefs::toolkit_content_background_hang_monitor_disabled()) { BackgroundHangManager::sDisabled = true; return; } diff --git a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.h b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.h index 4ae3ffe047c7..037ea5e52d0f 100644 --- a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.h +++ b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.h @@ -135,11 +135,6 @@ class BackgroundHangMonitor { */ static void Shutdown(); - /** - * Returns true if BHR is disabled. - */ - static bool IsDisabled(); - /** * Start monitoring hangs for the current thread. *