Bug 1381843 - Use the prefs defined in TelemetryUtils.jsm in TelemetrySend.jsm. r=dexter
authorAlejandro Rodriguez Salamanca <alexrs95>
Wed, 19 Jul 2017 02:12:00 +0200
changeset 418684 4194f4a318defa521543768acf09e19efba899ac
parent 418683 4ff87819abe8f08ca86c3ca81c39cfcdb338ad57
child 418685 c72f79ecb0dda81850fd2434db9f58b60da51d29
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
bugs1381843
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 1381843 - Use the prefs defined in TelemetryUtils.jsm in TelemetrySend.jsm. r=dexter
toolkit/components/telemetry/TelemetrySend.jsm
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -40,32 +40,25 @@ XPCOMUtils.defineLazyServiceGetter(this,
                                    "@mozilla.org/base/telemetry;1",
                                    "nsITelemetry");
 
 const Utils = TelemetryUtils;
 
 const LOGGER_NAME = "Toolkit.Telemetry";
 const LOGGER_PREFIX = "TelemetrySend::";
 
-const PREF_BRANCH = "toolkit.telemetry.";
-const PREF_SERVER = PREF_BRANCH + "server";
-const PREF_UNIFIED = PREF_BRANCH + "unified";
-const PREF_ENABLED = PREF_BRANCH + "enabled";
-const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
-const PREF_OVERRIDE_OFFICIAL_CHECK = PREF_BRANCH + "send.overrideOfficialCheck";
-
 const TOPIC_IDLE_DAILY = "idle-daily";
 // The following topics are notified when Firefox is closing
 // because the OS is shutting down.
 const TOPIC_QUIT_APPLICATION_GRANTED = "quit-application-granted";
 const TOPIC_QUIT_APPLICATION_FORCED = "quit-application-forced";
 
 // Whether the FHR/Telemetry unification features are enabled.
 // Changing this pref requires a restart.
-const IS_UNIFIED_TELEMETRY = Preferences.get(PREF_UNIFIED, false);
+const IS_UNIFIED_TELEMETRY = Preferences.get(TelemetryUtils.Preferences.Unified, false);
 
 const PING_FORMAT_VERSION = 4;
 
 const MS_IN_A_MINUTE = 60 * 1000;
 
 const PING_TYPE_DELETION = "deletion";
 
 // We try to spread "midnight" pings out over this interval.
@@ -601,23 +594,23 @@ var TelemetrySendImpl = {
 
   OBSERVER_TOPICS: [
     TOPIC_IDLE_DAILY,
     TOPIC_QUIT_APPLICATION_GRANTED,
     TOPIC_QUIT_APPLICATION_FORCED,
   ],
 
   OBSERVED_PREFERENCES: [
-    PREF_ENABLED,
-    PREF_FHR_UPLOAD_ENABLED,
+    TelemetryUtils.Preferences.TelemetryEnabled,
+    TelemetryUtils.Preferences.FhrUploadEnabled,
   ],
 
   // Whether sending pings has been overridden.
   get _overrideOfficialCheck() {
-    return Preferences.get(PREF_OVERRIDE_OFFICIAL_CHECK, false);
+    return Preferences.get(TelemetryUtils.Preferences.OverrideOfficialCheck, false);
   },
 
   get _log() {
     if (!this._logger) {
       this._logger = Log.repository.getLoggerWithMessagePrefix(LOGGER_NAME, LOGGER_PREFIX);
     }
 
     return this._logger;
@@ -651,17 +644,17 @@ var TelemetrySendImpl = {
   async setup(testing) {
     this._log.trace("setup");
 
     this._testMode = testing;
     this._sendingEnabled = true;
 
     Services.obs.addObserver(this, TOPIC_IDLE_DAILY);
 
-    this._server = Preferences.get(PREF_SERVER, undefined);
+    this._server = Preferences.get(TelemetryUtils.Preferences.Server, undefined);
 
     // Annotate crash reports so that crash pings are sent correctly and listen
     // to pref changes to adjust the annotations accordingly.
     for (let pref of this.OBSERVED_PREFERENCES) {
       Preferences.observe(pref, this._annotateCrashReport, this);
     }
     this._annotateCrashReport();
 
@@ -688,17 +681,17 @@ var TelemetrySendImpl = {
    */
   _annotateCrashReport() {
     try {
       const cr = Cc["@mozilla.org/toolkit/crash-reporter;1"];
       if (cr) {
         const crs = cr.getService(Ci.nsICrashReporter);
 
         let clientId = ClientID.getCachedClientID();
-        let server = this._server || Preferences.get(PREF_SERVER, undefined);
+        let server = this._server || Preferences.get(TelemetryUtils.Preferences.Server, undefined);
 
         if (!this.sendingEnabled() || !TelemetryReportingPolicy.canUpload()) {
           // If we cannot send pings then clear the crash annotations
           crs.annotateCrashReport("TelemetryClientId", "");
           crs.annotateCrashReport("TelemetryServerURL", "");
         } else {
           crs.annotateCrashReport("TelemetryClientId", clientId);
           crs.annotateCrashReport("TelemetryServerURL", server);
@@ -1232,17 +1225,17 @@ var TelemetrySendImpl = {
 
     // With unified Telemetry, the FHR upload setting controls whether we can send pings.
     // The Telemetry pref enables sending extended data sets instead.
     if (IS_UNIFIED_TELEMETRY) {
       // Deletion pings are sent even if the upload is disabled.
       if (ping && isDeletionPing(ping)) {
         return true;
       }
-      return Preferences.get(PREF_FHR_UPLOAD_ENABLED, false);
+      return Preferences.get(TelemetryUtils.Preferences.FhrUploadEnabled, false);
     }
 
     // Without unified Telemetry, the Telemetry enabled pref controls ping sending.
     return Utils.isTelemetryEnabled;
   },
 
   /**
    * Track any pending ping send and save tasks through the promise passed here.