Bug 1244766 - Remove optional Health Report callback parameter from Places telemetry. r=gfritzsche

This commit is contained in:
Eric Hu 2016-02-04 01:25:55 +07:00
Родитель 2779dbcc01
Коммит 683bcc97c5
2 изменённых файлов: 3 добавлений и 48 удалений

Просмотреть файл

@ -854,27 +854,15 @@ this.PlacesDBUtils = {
},
/**
* Collects telemetry data.
*
* There are essentially two modes of collection and the mode is
* determined by the presence of aHealthReportCallback. If
* aHealthReportCallback is not defined (the default) then we are in
* "Telemetry" mode. Results will be reported to Telemetry. If we are
* in "Health Report" mode only the probes with a true healthreport
* flag will be collected and the results will be reported to the
* aHealthReportCallback.
* Collects telemetry data and reports it to Telemetry.
*
* @param [optional] aTasks
* Tasks object to execute.
* @param [optional] aHealthReportCallback
* Function to receive data relevant for Firefox Health Report.
*/
telemetry: function PDBU_telemetry(aTasks, aHealthReportCallback=null)
telemetry: function PDBU_telemetry(aTasks)
{
let tasks = new Tasks(aTasks);
let isTelemetry = !aHealthReportCallback;
// This will be populated with one integer property for each probe result,
// using the histogram name as key.
let probeValues = {};
@ -891,19 +879,15 @@ this.PlacesDBUtils = {
// histogram. If a query is also present, its result is passed
// as the first argument of the function. If the function
// raises an exception, no data is added to the histogram.
// healthreport: Boolean indicating whether this probe is relevant
// to Firefox Health Report.
//
// Since all queries are executed in order by the database backend, the
// callbacks can also use the result of previous queries stored in the
// probeValues object.
let probes = [
{ histogram: "PLACES_PAGES_COUNT",
healthreport: true,
query: "SELECT count(*) FROM moz_places" },
{ histogram: "PLACES_BOOKMARKS_COUNT",
healthreport: true,
query: `SELECT count(*) FROM moz_bookmarks b
JOIN moz_bookmarks t ON t.id = b.parent
AND t.parent <> :tags_folder
@ -989,15 +973,9 @@ this.PlacesDBUtils = {
places_root: PlacesUtils.placesRootId
};
let outstandingProbes = [];
for (let i = 0; i < probes.length; i++) {
let probe = probes[i];
if (!isTelemetry && !probe.healthreport) {
continue;
}
let promiseDone = new Promise((resolve, reject) => {
if (!("query" in probe)) {
resolve([probe]);
@ -1027,7 +1005,7 @@ this.PlacesDBUtils = {
// Report the result of the probe through Telemetry.
// The resulting promise cannot reject.
promiseDone = promiseDone.then(
promiseDone.then(
// On success
([aProbe, aValue]) => {
let value = aValue;
@ -1045,14 +1023,6 @@ this.PlacesDBUtils = {
},
// On failure
this._handleError);
outstandingProbes.push(promiseDone);
}
if (aHealthReportCallback) {
Promise.all(outstandingProbes).then(() =>
aHealthReportCallback(probeValues)
);
}
PlacesDBUtils._executeTasks(tasks);

Просмотреть файл

@ -124,18 +124,3 @@ add_task(function* test_execute()
do_check_true(snapshot.counts.reduce((a, b) => a + b) > 0);
}
});
add_test(function test_healthreport_callback() {
Services.prefs.clearUserPref("places.database.lastMaintenance");
PlacesDBUtils.telemetry(null, function onResult(data) {
do_check_neq(data, null);
do_check_eq(Object.keys(data).length, 2);
do_check_eq(data.PLACES_PAGES_COUNT, 1);
do_check_eq(data.PLACES_BOOKMARKS_COUNT, 1);
do_check_true(!Services.prefs.prefHasUserValue("places.database.lastMaintenance"));
run_next_test();
});
});