Bug 1234522 - Remove references to the data reporting service. r=gfritzsche,smaug

This commit is contained in:
Alessio Placitelli 2016-01-05 06:29:00 +01:00
parent 441e819b1d
commit fd8a822825
10 changed files with 35 additions and 156 deletions

View File

@ -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;

View File

@ -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;

View File

@ -454,7 +454,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
<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");

View File

@ -431,7 +431,7 @@ BrowserGlue.prototype = {
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

View File

@ -7,6 +7,8 @@ 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,
@ -289,38 +291,23 @@ var gAdvancedPane = {
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

View File

@ -420,7 +420,7 @@
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,

View File

@ -12,24 +12,6 @@ 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",
@ -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);
},

View File

@ -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();
},

View File

@ -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<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:

View File

@ -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 = {