From 0ca9853f5cfdda6d93402ca85574cb280261eb2c Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Tue, 5 Jan 2016 06:29:00 +0100 Subject: [PATCH] Bug 1234522 - Remove references to the data reporting service. r=gfritzsche,smaug --- .../content/abouthealthreport/abouthealth.js | 16 ----- browser/base/content/browser.js | 64 +++++++------------ browser/base/content/urlbarBindings.xml | 2 +- browser/components/nsBrowserGlue.js | 2 +- .../preferences/in-content/advanced.js | 25 ++------ browser/components/search/content/search.xml | 2 +- .../selfsupport/SelfSupportService.js | 50 --------------- browser/modules/ContentSearch.jsm | 4 +- dom/webidl/MozSelfSupport.webidl | 20 ------ services/healthreport/healthreporter.jsm | 6 +- 10 files changed, 35 insertions(+), 156 deletions(-) diff --git a/browser/base/content/abouthealthreport/abouthealth.js b/browser/base/content/abouthealthreport/abouthealth.js index 55669edc473e..f90f6742d5d9 100644 --- a/browser/base/content/abouthealthreport/abouthealth.js +++ b/browser/base/content/abouthealthreport/abouthealth.js @@ -23,10 +23,6 @@ var healthReportWrapper = { 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); }, @@ -103,15 +99,6 @@ var healthReportWrapper = { }); }, - 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(); @@ -139,9 +126,6 @@ var healthReportWrapper = { case "RequestCurrentPrefs": this.updatePrefState(); break; - case "RequestCurrentPayload": - this.refreshPayload(); - break; case "RequestTelemetryPingList": this.sendTelemetryPingList(); break; diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index f8469accfe70..1f097bd4b09d 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3633,7 +3633,7 @@ const BrowserSearch = { loadSearchFromContext: function (terms) { let engine = BrowserSearch._loadSearch(terms, true, "contextmenu"); if (engine) { - BrowserSearch.recordSearchInHealthReport(engine, "contextmenu"); + BrowserSearch.recordSearchInTelemetry(engine, "contextmenu"); } }, @@ -3657,10 +3657,26 @@ const BrowserSearch = { 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. @@ -3672,45 +3688,7 @@ const BrowserSearch = { * 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", @@ -3719,6 +3697,8 @@ const BrowserSearch = { "urlbar", ]; + BrowserUITelemetry.countSearchEvent(source, null, selection); + if (SOURCES.indexOf(source) == -1) { Cu.reportError("Unknown source for search: " + source); return; diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 37eeaab95e92..6b9650ff2061 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -454,7 +454,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. { - 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", @@ -53,45 +35,13 @@ MozSelfSupportInterface.prototype = { }, 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); }, diff --git a/browser/modules/ContentSearch.jsm b/browser/modules/ContentSearch.jsm index 77c41de449cb..86074b77a871 100644 --- a/browser/modules/ContentSearch.jsm +++ b/browser/modules/ContentSearch.jsm @@ -303,8 +303,8 @@ this.ContentSearch = { }; 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(); }, diff --git a/dom/webidl/MozSelfSupport.webidl b/dom/webidl/MozSelfSupport.webidl index b5ce70e6434f..d13aa112ce13 100644 --- a/dom/webidl/MozSelfSupport.webidl +++ b/dom/webidl/MozSelfSupport.webidl @@ -20,26 +20,6 @@ interface MozSelfSupport */ 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 - * Resolved when the FHR payload data has been collected. - */ - Promise getHealthReportPayload(); - /** * Retrieve a list of the archived Telemetry pings. * This contains objects with ping info, which are of the form: diff --git a/services/healthreport/healthreporter.jsm b/services/healthreport/healthreporter.jsm index 569e4079be4a..9aaca06b97c9 100644 --- a/services/healthreport/healthreporter.jsm +++ b/services/healthreport/healthreporter.jsm @@ -20,6 +20,7 @@ Cu.import("resource://services-common/bagheeraclient.js"); 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"); @@ -132,10 +133,7 @@ HealthReporterState.prototype = Object.freeze({ 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 = {