Bug 1382198 - Use the prefs defined in TelemetryUtils.jsm in UITelemetry.jsm. r=dexter
authorAlejandro Rodriguez Salamanca <alexrs95>
Wed, 19 Jul 2017 06:55:00 +0200
changeset 419049 90bc71d7d3c619d37ebac8f5e6f193e41a063b68
parent 419048 d6a2235600af44fc2108d6493f1ebc629ab07ff7
child 419050 3b29f600411fcfdab16a161196fef7749cae1803
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdexter
bugs1382198
milestone56.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 1382198 - Use the prefs defined in TelemetryUtils.jsm in UITelemetry.jsm. r=dexter
toolkit/components/telemetry/UITelemetry.jsm
--- a/toolkit/components/telemetry/UITelemetry.jsm
+++ b/toolkit/components/telemetry/UITelemetry.jsm
@@ -1,24 +1,22 @@
 /* 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/. */
 
 "use strict";
 
 const Cu = Components.utils;
 
-const PREF_BRANCH = "toolkit.telemetry.";
-const PREF_ENABLED = PREF_BRANCH + "enabled";
-
 this.EXPORTED_SYMBOLS = [
   "UITelemetry",
 ];
 
 Cu.import("resource://gre/modules/Services.jsm", this);
+Cu.import("resource://gre/modules/TelemetryUtils.jsm", this);
 
 /**
  * UITelemetry is a helper JSM used to record UI specific telemetry events.
  *
  * It implements nsIUITelemetryObserver, defined in nsIAndroidBridge.idl.
  */
 this.UITelemetry = {
   _enabled: undefined,
@@ -27,37 +25,37 @@ this.UITelemetry = {
 
   // Lazily decide whether telemetry is enabled.
   get enabled() {
     if (this._enabled !== undefined) {
       return this._enabled;
     }
 
     // Set an observer to watch for changes at runtime.
-    Services.prefs.addObserver(PREF_ENABLED, this);
+    Services.prefs.addObserver(TelemetryUtils.Preferences.TelemetryEnabled, this);
     Services.obs.addObserver(this, "profile-before-change");
 
     // Pick up the current value.
-    this._enabled = Services.prefs.getBoolPref(PREF_ENABLED, false);
+    this._enabled = Services.prefs.getBoolPref(TelemetryUtils.Preferences.TelemetryEnabled, false);
 
     return this._enabled;
   },
 
   observe(aSubject, aTopic, aData) {
     if (aTopic == "profile-before-change") {
       Services.obs.removeObserver(this, "profile-before-change");
-      Services.prefs.removeObserver(PREF_ENABLED, this);
+      Services.prefs.removeObserver(TelemetryUtils.Preferences.TelemetryEnabled, this);
       this._enabled = undefined;
       return;
     }
 
     if (aTopic == "nsPref:changed") {
       switch (aData) {
-        case PREF_ENABLED:
-          let on = Services.prefs.getBoolPref(PREF_ENABLED);
+        case TelemetryUtils.Preferences.TelemetryEnabled:
+          let on = Services.prefs.getBoolPref(TelemetryUtils.Preferences.TelemetryEnabled);
           this._enabled = on;
 
           // Wipe ourselves if we were just disabled.
           if (!on) {
             this._activeSessions = {};
             this._measurements = [];
           }
           break;