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
This commit is contained in:
Kristen Wright 2020-05-24 18:27:35 +00:00
Родитель 51439289c1
Коммит 3420ea8aed
4 изменённых файлов: 9 добавлений и 20 удалений

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

@ -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

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

@ -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

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

@ -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;
}

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

@ -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.
*