From 8cfe473f10a506d1eddeef256313cf000aa1872d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 5 Jul 2018 15:26:37 -0700 Subject: [PATCH] Bug 1473631: Part 15 - Use a single pref observer for all telemetry environment preferences. r=gfritzsche MozReview-Commit-ID: dGJDjUP4Vm --HG-- extra : rebase_source : d7e801b2d5b3b0e1b390a78c835e445eda1d9ac6 extra : amend_source : 342b24fec8ee3cea9677080f588593405b233734 --- .../components/telemetry/TelemetryEnvironment.jsm | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/toolkit/components/telemetry/TelemetryEnvironment.jsm b/toolkit/components/telemetry/TelemetryEnvironment.jsm index f2267ccb48cb..ed8ad9e76f12 100644 --- a/toolkit/components/telemetry/TelemetryEnvironment.jsm +++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm @@ -1124,11 +1124,7 @@ EnvironmentCache.prototype = { _startWatchingPrefs() { this._log.trace("_startWatchingPrefs - " + this._watchedPrefs); - for (let [pref, options] of this._watchedPrefs) { - if (!("requiresRestart" in options) || !options.requiresRestart) { - Services.prefs.addObserver(pref, this, true); - } - } + Services.prefs.addObserver("", this, true); }, _onPrefChanged(aData) { @@ -1144,11 +1140,7 @@ EnvironmentCache.prototype = { _stopWatchingPrefs() { this._log.trace("_stopWatchingPrefs"); - for (let [pref, options] of this._watchedPrefs) { - if (!("requiresRestart" in options) || !options.requiresRestart) { - Services.prefs.removeObserver(pref, this); - } - } + Services.prefs.removeObserver("", this); }, _addObservers() { @@ -1220,7 +1212,8 @@ EnvironmentCache.prototype = { this._updateDefaultBrowser(); break; case PREF_CHANGED_TOPIC: - if (this._watchedPrefs.has(aData)) { + let options = this._watchedPrefs.get(aData); + if (options && !options.requiresRestart) { this._onPrefChanged(aData); } break;