Bug 1666545 - Move Places telemetry collection to the first idle. r=jaws

Differential Revision: https://phabricator.services.mozilla.com/D96479
This commit is contained in:
Micah Tigley 2020-11-10 17:05:34 +00:00
Родитель fff551e1dd
Коммит ec6b6d8b57
3 изменённых файлов: 19 добавлений и 5 удалений

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

@ -1281,6 +1281,9 @@ BrowserGlue.prototype = {
if (AppConstants.platform == "win") {
JawsScreenReaderVersionCheck.init();
}
// This value is to limit collecting Places telemetry once per session.
this._placesTelemetryGathered = false;
},
// cleanup (called on application shutdown)
@ -1908,6 +1911,13 @@ BrowserGlue.prototype = {
this._collectFirstPartyIsolationTelemetry();
if (!this._placesTelemetryGathered) {
Cc["@mozilla.org/places/categoriesStarter;1"]
.getService(Ci.nsIObserver)
.observe(null, "gather-places-telemetry", null);
this._placesTelemetryGathered = true;
}
// Set the default favicon size for UI views that use the page-icon protocol.
PlacesUtils.favicons.setDefaultIconURIPreferredSize(
16 * aWindow.devicePixelRatio

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

@ -4,8 +4,9 @@
* 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/. */
// Fired by TelemetryController when async telemetry data should be collected.
const TOPIC_GATHER_TELEMETRY = "gather-telemetry";
// Fired by BrowserGlue._onFirstWindowLoaded when async telemetry data should
// be collected.
const TOPIC_GATHER_TELEMETRY = "gather-places-telemetry";
// Seconds between maintenance runs.
const MAINTENANCE_INTERVAL_SECONDS = 7 * 86400;
@ -42,7 +43,10 @@ PlacesCategoriesStarter.prototype = {
}
break;
case TOPIC_GATHER_TELEMETRY:
PlacesDBUtils.telemetry();
// Collect Places telemetry on the first idle.
Services.tm.idleDispatchToMainThread(() => {
PlacesDBUtils.telemetry();
});
break;
case "idle-daily":
// Once a week run places.sqlite maintenance tasks.

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

@ -99,10 +99,10 @@ add_task(async function test_execute() {
annotations: new Map([["test-anno", content]]),
});
// Request to gather telemetry data.
// Request to gather Places telemetry data.
Cc["@mozilla.org/places/categoriesStarter;1"]
.getService(Ci.nsIObserver)
.observe(null, "gather-telemetry", null);
.observe(null, "gather-places-telemetry", null);
await PlacesTestUtils.promiseAsyncUpdates();