Bug 1234522 - Remove references to the data reporting service. r=gfritzsche,smaug
☠☠ backed out by 19a2342819e4 ☠ ☠
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Tue, 05 Jan 2016 06:29:00 +0100
changeset 320135 c3b6bf176f86b0167f008fbf87e5a2aa39061584
parent 320134 3e7dc6d87325ce8f6d817e7f0bad096152cc8aef
child 320136 96e0326e798579fda3e4babf0a253b43e19e2635
push id9143
push userahunt@mozilla.com
push dateFri, 08 Jan 2016 21:30:53 +0000
reviewersgfritzsche, smaug
bugs1234522
milestone46.0a1
Bug 1234522 - Remove references to the data reporting service. r=gfritzsche,smaug
browser/base/content/abouthealthreport/abouthealth.js
browser/base/content/browser.js
browser/base/content/urlbarBindings.xml
browser/components/nsBrowserGlue.js
browser/components/preferences/in-content/advanced.js
browser/components/search/content/search.xml
browser/components/selfsupport/SelfSupportService.js
browser/modules/ContentSearch.jsm
dom/webidl/MozSelfSupport.webidl
services/healthreport/healthreporter.jsm
--- a/browser/base/content/abouthealthreport/abouthealth.js
+++ b/browser/base/content/abouthealthreport/abouthealth.js
@@ -18,20 +18,16 @@ const PREF_UNIFIED_OPTIN = "toolkit.tele
 const IS_V4 = Preferences.get(PREF_UNIFIED, false) &&
               !Preferences.get(PREF_UNIFIED_OPTIN, false);
 
 var healthReportWrapper = {
   init: function () {
     let iframe = document.getElementById("remote-report");
     iframe.addEventListener("load", healthReportWrapper.initRemotePage, false);
     iframe.src = this._getReportURI().spec;
-    iframe.onload = () => {
-      MozSelfSupport.getHealthReportPayload().then(this.updatePayload,
-                                                   this.handleInitFailure);
-    };
     prefs.observe("uploadEnabled", this.updatePrefState, healthReportWrapper);
   },
 
   uninit: function () {
     prefs.ignore("uploadEnabled", this.updatePrefState, healthReportWrapper);
   },
 
   _getReportURI: function () {
@@ -98,25 +94,16 @@ var healthReportWrapper = {
     console.log("AboutHealthReport: Sending current Telemetry ping data.");
     MozSelfSupport.getCurrentTelemetrySubsessionPing().then((ping) => {
       this.injectData("telemetry-current-ping-data", ping);
     }).catch((ex) => {
       console.log("AboutHealthReport: Collecting current ping data failed: " + ex);
     });
   },
 
-  refreshPayload: function () {
-    MozSelfSupport.getHealthReportPayload().then(this.updatePayload,
-                                                 this.handlePayloadFailure);
-  },
-
-  updatePayload: function (payload) {
-    healthReportWrapper.injectData("payload", JSON.stringify(payload));
-  },
-
   injectData: function (type, content) {
     let report = this._getReportURI();
 
     // file URIs can't be used for targetOrigin, so we use "*" for this special case
     // in all other cases, pass in the URL to the report so we properly restrict the message dispatch
     let reportUrl = report.scheme == "file" ? "*" : report.spec;
 
     let data = {
@@ -134,19 +121,16 @@ var healthReportWrapper = {
         this.setDataSubmission(false);
         break;
       case "EnableDataSubmission":
         this.setDataSubmission(true);
         break;
       case "RequestCurrentPrefs":
         this.updatePrefState();
         break;
-      case "RequestCurrentPayload":
-        this.refreshPayload();
-        break;
       case "RequestTelemetryPingList":
         this.sendTelemetryPingList();
         break;
       case "RequestTelemetryPingData":
         this.sendTelemetryPingData(evt.detail.id);
         break;
       case "RequestCurrentEnvironment":
         this.sendCurrentEnvironment();
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3628,17 +3628,17 @@ const BrowserSearch = {
    * Perform a search initiated from the context menu.
    *
    * This should only be called from the context menu. See
    * BrowserSearch.loadSearch for the preferred API.
    */
   loadSearchFromContext: function (terms) {
     let engine = BrowserSearch._loadSearch(terms, true, "contextmenu");
     if (engine) {
-      BrowserSearch.recordSearchInHealthReport(engine, "contextmenu");
+      BrowserSearch.recordSearchInTelemetry(engine, "contextmenu");
     }
   },
 
   pasteAndSearch: function (event) {
     BrowserSearch.searchBar.select();
     goDoCommand("cmd_paste");
     BrowserSearch.searchBar.handleSearchCommand(event);
   },
@@ -3652,78 +3652,58 @@ const BrowserSearch = {
 
   loadAddEngines: function BrowserSearch_loadAddEngines() {
     var newWindowPref = gPrefService.getIntPref("browser.link.open_newwindow");
     var where = newWindowPref == 3 ? "tab" : "window";
     var searchEnginesURL = formatURL("browser.search.searchEnginesURL", true);
     openUILinkIn(searchEnginesURL, where);
   },
 
+  _getSearchEngineId: function (engine) {
+    if (!engine) {
+      return "other";
+    }
+
+    if (engine.identifier) {
+      return engine.identifier;
+    }
+
+    if (!("name" in engine) || engine.name === undefined) {
+      return "other";
+    }
+
+    return "other-" + engine.name;
+  },
+
   /**
-   * Helper to record a search with Firefox Health Report.
+   * Helper to record a search with Telemetry.
    *
-   * FHR records only search counts and nothing pertaining to the search itself.
+   * Telemetry records only search counts and nothing pertaining to the search itself.
    *
    * @param engine
    *        (nsISearchEngine) The engine handling the search.
    * @param source
    *        (string) Where the search originated from. See the FHR
    *        SearchesProvider for allowed values.
    * @param selection [optional]
    *        ({index: The selected index, kind: "key" or "mouse"}) If
    *        the search was a suggested search, this indicates where the
    *        item was in the suggestion list and how the user selected it.
    */
-  recordSearchInHealthReport: function (engine, source, selection) {
-    BrowserUITelemetry.countSearchEvent(source, null, selection);
-    this.recordSearchInTelemetry(engine, source);
-
-    let reporter = AppConstants.MOZ_SERVICES_HEALTHREPORT
-                   ? Cc["@mozilla.org/datareporting/service;1"]
-                     .getService()
-                     .wrappedJSObject
-                     .healthReporter
-                   : null;
-
-    // This can happen if the FHR component of the data reporting service is
-    // disabled. This is controlled by a pref that most will never use.
-    if (!reporter) {
-      return;
-    }
-
-    reporter.onInit().then(function record() {
-      try {
-        reporter.getProvider("org.mozilla.searches").recordSearch(engine, source);
-      } catch (ex) {
-        Cu.reportError(ex);
-      }
-    });
-  },
-
-  _getSearchEngineId: function (engine) {
-    if (!engine) {
-      return "other";
-    }
-
-    if (engine.identifier) {
-      return engine.identifier;
-    }
-
-    return "other-" + engine.name;
-  },
-
-  recordSearchInTelemetry: function (engine, source) {
+  recordSearchInTelemetry: function (engine, source, selection) {
     const SOURCES = [
       "abouthome",
       "contextmenu",
       "newtab",
       "searchbar",
       "urlbar",
     ];
 
+    BrowserUITelemetry.countSearchEvent(source, null, selection);
+
     if (SOURCES.indexOf(source) == -1) {
       Cu.reportError("Unknown source for search: " + source);
       return;
     }
 
     let countId = this._getSearchEngineId(engine) + "." + source;
 
     let count = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS");
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -449,17 +449,17 @@ file, You can obtain one at http://mozil
         ]]></body>
       </method>
 
       <method name="_parseAndRecordSearchEngineAction">
         <parameter name="action"/>
         <body><![CDATA[
           let engine =
             Services.search.getEngineByName(action.params.engineName);
-          BrowserSearch.recordSearchInHealthReport(engine, "urlbar");
+          BrowserSearch.recordSearchInTelemetry(engine, "urlbar");
           let query = action.params.searchSuggestion ||
                       action.params.searchQuery;
           let submission = engine.getSubmission(query, null, "keyword");
           return [submission.uri.spec, submission.postData];
         ]]></body>
       </method>
 
       <method name="_canonizeURL">
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -426,17 +426,17 @@ BrowserGlue.prototype = {
         // URI that it's been asked to load into a keyword search.
         let engine = null;
         try {
           engine = subject.QueryInterface(Ci.nsISearchEngine);
         } catch (ex) {
           Cu.reportError(ex);
         }
         let win = RecentWindow.getMostRecentBrowserWindow();
-        win.BrowserSearch.recordSearchInHealthReport(engine, "urlbar");
+        win.BrowserSearch.recordSearchInTelemetry(engine, "urlbar");
         break;
       case "browser-search-engine-modified":
         // Ensure we cleanup the hiddenOneOffs pref when removing
         // an engine, and that newly added engines are visible.
         if (data == "engine-added" || data == "engine-removed") {
           let engineName = subject.QueryInterface(Ci.nsISearchEngine).name;
           let Preferences =
             Cu.import("resource://gre/modules/Preferences.jsm", {}).Preferences;
--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -2,16 +2,18 @@
  * 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/. */
 
 // Load DownloadUtils module for convertByteUnits
 Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
 Components.utils.import("resource://gre/modules/LoadContextInfo.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
+const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
+
 var gAdvancedPane = {
   _inited: false,
 
   /**
    * Brings the appropriate tab to the front and initializes various bits of UI.
    */
   init: function ()
   {
@@ -284,48 +286,33 @@ var gAdvancedPane = {
 
 #ifdef MOZ_SERVICES_HEALTHREPORT
   /**
    * Initialize the health report service reference and checkbox.
    */
   initSubmitHealthReport: function () {
     this._setupLearnMoreLink("datareporting.healthreport.infoURL", "FHRLearnMore");
 
-    let policy = Components.classes["@mozilla.org/datareporting/service;1"]
-                                   .getService(Components.interfaces.nsISupports)
-                                   .wrappedJSObject
-                                   .policy;
-
     let checkbox = document.getElementById("submitHealthReportBox");
 
-    if (!policy || policy.healthReportUploadLocked) {
+    if (Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED)) {
       checkbox.setAttribute("disabled", "true");
       return;
     }
 
-    checkbox.checked = policy.healthReportUploadEnabled;
+    checkbox.checked = Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED);
     this.setTelemetrySectionEnabled(checkbox.checked);
   },
 
   /**
-   * Update the health report policy acceptance with state from checkbox.
+   * Update the health report preference with state from checkbox.
    */
   updateSubmitHealthReport: function () {
-    let policy = Components.classes["@mozilla.org/datareporting/service;1"]
-                                   .getService(Components.interfaces.nsISupports)
-                                   .wrappedJSObject
-                                   .policy;
-
-    if (!policy) {
-      return;
-    }
-
     let checkbox = document.getElementById("submitHealthReportBox");
-    policy.recordHealthReportUploadEnabled(checkbox.checked,
-                                           "Checkbox from preferences pane");
+    Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked);
     this.setTelemetrySectionEnabled(checkbox.checked);
   },
 #endif
 
   // NETWORK TAB
 
   /*
    * Preferences:
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -415,17 +415,17 @@
 
           let engine = aEngine || this.currentEngine;
           var submission = engine.getSubmission(aData, null, "searchbar");
           let telemetrySearchDetails = this.telemetrySearchDetails;
           this.telemetrySearchDetails = null;
           if (telemetrySearchDetails && telemetrySearchDetails.index == -1) {
             telemetrySearchDetails = null;
           }
-          BrowserSearch.recordSearchInHealthReport(engine, "searchbar", telemetrySearchDetails);
+          BrowserSearch.recordSearchInTelemetry(engine, "searchbar", telemetrySearchDetails);
           // null parameter below specifies HTML response for search
           let params = {
             postData: submission.postData,
             inBackground: aWhere == "tab-background"
           };
           openUILinkIn(submission.uri.spec,
                        aWhere == "tab-background" ? "tab" : aWhere,
                        params);
--- a/browser/components/selfsupport/SelfSupportService.js
+++ b/browser/components/selfsupport/SelfSupportService.js
@@ -7,34 +7,16 @@
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Preferences.jsm");
 
 const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
 
-XPCOMUtils.defineLazyGetter(this, "gPolicy", () => {
-  try {
-    return Cc["@mozilla.org/datareporting/service;1"]
-             .getService(Ci.nsISupports)
-             .wrappedJSObject
-             .policy;
-  } catch (e) {
-    return undefined;
-  }
-});
-
-XPCOMUtils.defineLazyGetter(this, "reporter", () => {
-  return Cc["@mozilla.org/datareporting/service;1"]
-           .getService(Ci.nsISupports)
-           .wrappedJSObject
-           .healthReporter;
-});
-
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryArchive",
                                   "resource://gre/modules/TelemetryArchive.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryEnvironment",
                                   "resource://gre/modules/TelemetryEnvironment.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryController",
                                   "resource://gre/modules/TelemetryController.jsm");
 
 function MozSelfSupportInterface() {
@@ -48,55 +30,23 @@ MozSelfSupportInterface.prototype = {
 
   _window: null,
 
   init: function (window) {
     this._window = window;
   },
 
   get healthReportDataSubmissionEnabled() {
-    if (gPolicy) {
-      return gPolicy.healthReportUploadEnabled;
-    }
-
-    // The datareporting service is unavailable or disabled.
     return Preferences.get(PREF_FHR_UPLOAD_ENABLED, false);
   },
 
   set healthReportDataSubmissionEnabled(enabled) {
-    if (gPolicy) {
-      let reason = "Self-support interface sent " +
-                   (enabled ? "opt-in" : "opt-out") +
-                   " command.";
-      gPolicy.recordHealthReportUploadEnabled(enabled, reason);
-      return;
-    }
-
-    // The datareporting service is unavailable or disabled.
     Preferences.set(PREF_FHR_UPLOAD_ENABLED, enabled);
   },
 
-  getHealthReportPayload: function () {
-    return new this._window.Promise(function (aResolve, aReject) {
-      if (reporter) {
-        let resolvePayload = function () {
-          reporter.collectAndObtainJSONPayload(true).then(aResolve, aReject);
-        };
-
-        if (reporter.initialized) {
-          resolvePayload();
-        } else {
-          reporter.onInit().then(resolvePayload, aReject);
-        }
-      } else {
-        aReject(new Error("No reporter"));
-      }
-    }.bind(this));
-  },
-
   resetPref: function(name) {
     Services.prefs.clearUserPref(name);
   },
 
   resetSearchEngines: function() {
     Services.search.restoreDefaultEngines();
     Services.search.resetToOriginalDefaultEngine();
   },
--- a/browser/modules/ContentSearch.jsm
+++ b/browser/modules/ContentSearch.jsm
@@ -298,18 +298,18 @@ this.ContentSearch = {
                                submission.postData);
     } else {
       let params = {
         postData: submission.postData,
         inBackground: Services.prefs.getBoolPref("browser.tabs.loadInBackground"),
       };
       win.openUILinkIn(submission.uri.spec, where, params);
     }
-    win.BrowserSearch.recordSearchInHealthReport(engine, data.healthReportKey,
-                                                 data.selection || null);
+    win.BrowserSearch.recordSearchInTelemetry(engine, data.healthReportKey,
+                                              data.selection || null);
     return Promise.resolve();
   },
 
   _onMessageSetCurrentEngine: function (msg, data) {
     Services.search.currentEngine = Services.search.getEngineByName(data);
     return Promise.resolve();
   },
 
--- a/dom/webidl/MozSelfSupport.webidl
+++ b/dom/webidl/MozSelfSupport.webidl
@@ -16,36 +16,16 @@
 interface MozSelfSupport
 {
   /**
    * Controls whether uploading FHR data is allowed.
    */
   attribute boolean healthReportDataSubmissionEnabled;
 
   /**
-   * Retrieves the FHR payload object, which is of the form:
-   *
-   * {
-   *   version: Number,
-   *   clientID: String,
-   *   clientIDVersion: Number,
-   *   thisPingDate: String,
-   *   geckoAppInfo: Object,
-   *   data: Object
-   * }
-   *
-   * Refer to the getJSONPayload function in healthreporter.jsm for more
-   * information.
-   *
-   * @return Promise<Object>
-   *         Resolved when the FHR payload data has been collected.
-   */
-  Promise<object> getHealthReportPayload();
-
-  /**
    * Retrieve a list of the archived Telemetry pings.
    * This contains objects with ping info, which are of the form:
    * {
    *   type: <string>, // The pings type, e.g. "main", "environment-change", ...
    *   timestampCreated: <number>, // The time the ping was created (ms since unix epoch).
    *   id: <string>, // The pings UUID.
    * }
    *
--- a/services/healthreport/healthreporter.jsm
+++ b/services/healthreport/healthreporter.jsm
@@ -15,16 +15,17 @@ const MILLISECONDS_PER_DAY = 24 * 60 * 6
 Cu.import("resource://gre/modules/Metrics.jsm");
 Cu.import("resource://services-common/async.js");
 
 Cu.import("resource://services-common/bagheeraclient.js");
 #endif
 
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://services-common/utils.js");
+Cu.import("resource://gre/modules/ClientID.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource://gre/modules/osfile.jsm");
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/TelemetryStopwatch.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
@@ -127,20 +128,17 @@ HealthReporterState.prototype = Object.f
   get _lastPayloadPath() {
     return OS.Path.join(this._stateDir, "lastpayload.json");
   },
 
   init: function () {
     return Task.spawn(function* init() {
       yield OS.File.makeDir(this._stateDir);
 
-      let drs = Cc["@mozilla.org/datareporting/service;1"]
-                  .getService(Ci.nsISupports)
-                  .wrappedJSObject;
-      let drsClientID = yield drs.getClientID();
+      let drsClientID = yield ClientID.getClientID();
 
       let resetObjectState = function () {
         this._s = {
           // The payload version. This is bumped whenever there is a
           // backwards-incompatible change.
           v: 1,
           // The persistent client identifier.
           clientID: drsClientID,