mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 783005 - delete ping files that have been around for too long; r=taras
This commit is contained in:
parent
7c6bbae312
commit
ec722c7eef
@ -23,6 +23,8 @@ const PREF_ENABLED = "toolkit.telemetry.enabled";
|
||||
const TELEMETRY_INTERVAL = 60000;
|
||||
// Delay before intializing telemetry (ms)
|
||||
const TELEMETRY_DELAY = 60000;
|
||||
// Delete ping files that have been lying around for longer than this.
|
||||
const MAX_PING_FILE_AGE = 7 * 24 * 60 * 60 * 1000; // 1 week
|
||||
// Constants from prio.h for nsIFileOutputStream.init
|
||||
const PR_WRONLY = 0x2;
|
||||
const PR_CREATE_FILE = 0x8;
|
||||
@ -747,6 +749,13 @@ TelemetryPing.prototype = {
|
||||
},
|
||||
|
||||
loadHistograms: function loadHistograms(file, sync) {
|
||||
let now = new Date();
|
||||
if (now - file.lastModifiedTime > MAX_PING_FILE_AGE) {
|
||||
// We haven't had much luck in sending this file; delete it.
|
||||
file.remove(true);
|
||||
return;
|
||||
}
|
||||
|
||||
this._pingsLoaded++;
|
||||
if (sync) {
|
||||
let stream = Cc["@mozilla.org/network/file-input-stream;1"]
|
||||
|
@ -291,6 +291,8 @@ function checkPersistedHistogramsAsync(request, response) {
|
||||
checkPayload(request, "saved-session", 3);
|
||||
|
||||
gFinished = true;
|
||||
|
||||
runOldPingFileTest();
|
||||
}
|
||||
|
||||
function checkHistogramsAsync(request, response) {
|
||||
@ -308,6 +310,18 @@ function runInvalidJSONTest() {
|
||||
do_check_false(histogramsFile.exists());
|
||||
}
|
||||
|
||||
function runOldPingFileTest() {
|
||||
let histogramsFile = getSavedHistogramsFile("old-histograms.dat");
|
||||
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver);
|
||||
TelemetryPing.observe(histogramsFile, "test-save-histograms", null);
|
||||
do_check_true(histogramsFile.exists());
|
||||
|
||||
let mtime = histogramsFile.lastModifiedTime;
|
||||
histogramsFile.lastModifiedTime = mtime - 8 * 24 * 60 * 60 * 1000; // 8 days.
|
||||
TelemetryPing.observe(histogramsFile, "test-load-histograms", null);
|
||||
do_check_false(histogramsFile.exists());
|
||||
}
|
||||
|
||||
// copied from toolkit/mozapps/extensions/test/xpcshell/head_addons.js
|
||||
const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
|
||||
const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
|
||||
|
Loading…
Reference in New Issue
Block a user