зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1143796 - Increase TelemetryScheduler ticking interval when user is not active. r=gfritzsche
This commit is contained in:
Родитель
5a66040c78
Коммит
94132eab13
|
@ -86,6 +86,8 @@ const TELEMETRY_DELAY = 60000;
|
|||
const TELEMETRY_TEST_DELAY = 100;
|
||||
// Execute a scheduler tick every 5 minutes.
|
||||
const SCHEDULER_TICK_INTERVAL_MS = 5 * 60 * 1000;
|
||||
// When user is idle, execute a scheduler tick every 60 minutes.
|
||||
const SCHEDULER_TICK_IDLE_INTERVAL_MS = 60 * 60 * 1000;
|
||||
// The maximum number of times a scheduled operation can fail.
|
||||
const SCHEDULER_RETRY_ATTEMPTS = 3;
|
||||
|
||||
|
@ -416,6 +418,8 @@ let TelemetryScheduler = {
|
|||
|
||||
// The timer which drives the scheduler.
|
||||
_schedulerTimer: null,
|
||||
// The interval used by the scheduler timer.
|
||||
_schedulerInterval: 0,
|
||||
_shuttingDown: true,
|
||||
|
||||
/**
|
||||
|
@ -430,14 +434,16 @@ let TelemetryScheduler = {
|
|||
let now = Policy.now();
|
||||
this._lastDailyPingTime = now.getTime();
|
||||
this._lastSessionCheckpointTime = now.getTime();
|
||||
this._schedulerInterval = SCHEDULER_TICK_INTERVAL_MS;
|
||||
this._rescheduleTimeout();
|
||||
idleService.addIdleObserver(this, IDLE_TIMEOUT_SECONDS);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reschedules the tick timer.
|
||||
*/
|
||||
_rescheduleTimeout: function() {
|
||||
this._log.trace("_rescheduleTimeout");
|
||||
this._log.trace("_rescheduleTimeout - timeout: " + this._schedulerInterval);
|
||||
if (this._shuttingDown) {
|
||||
this._log.warn("_rescheduleTimeout - already shutdown");
|
||||
return;
|
||||
|
@ -448,7 +454,7 @@ let TelemetryScheduler = {
|
|||
}
|
||||
|
||||
this._schedulerTimer =
|
||||
Policy.setSchedulerTickTimeout(() => this._onSchedulerTick(), SCHEDULER_TICK_INTERVAL_MS);
|
||||
Policy.setSchedulerTickTimeout(() => this._onSchedulerTick(), this._schedulerInterval);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -498,6 +504,25 @@ let TelemetryScheduler = {
|
|||
.catch(e => this._log.error("_saveAbortedPing - Failed", e));
|
||||
},
|
||||
|
||||
/**
|
||||
* The notifications handler.
|
||||
*/
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
this._log.trace("observe - aTopic: " + aTopic);
|
||||
switch(aTopic) {
|
||||
case "idle":
|
||||
// If the user is idle, increase the tick interval.
|
||||
this._schedulerInterval = SCHEDULER_TICK_IDLE_INTERVAL_MS;
|
||||
this._rescheduleTimeout();
|
||||
break;
|
||||
case "active":
|
||||
// User is back to work, restore the original tick interval.
|
||||
this._schedulerInterval = SCHEDULER_TICK_INTERVAL_MS;
|
||||
this._rescheduleTimeout();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Performs a scheduler tick. This function manages Telemetry recurring operations.
|
||||
* @return {Promise} A promise, only used when testing, resolved when the scheduled
|
||||
|
@ -650,6 +675,8 @@ let TelemetryScheduler = {
|
|||
this._schedulerTimer = null;
|
||||
}
|
||||
|
||||
idleService.removeIdleObserver(this, IDLE_TIMEOUT_SECONDS);
|
||||
|
||||
this._shuttingDown = true;
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче