mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 909270 - Queue PushService alarms. r=jlebar
This commit is contained in:
parent
8072b982b6
commit
7c8b6a0105
@ -625,9 +625,20 @@ this.PushService = {
|
||||
|
||||
/** |delay| should be in milliseconds. */
|
||||
_setAlarm: function(delay) {
|
||||
// Bug 909270: Since calls to AlarmService.add() are async, calls must be
|
||||
// 'queued' to ensure only one alarm is ever active.
|
||||
if (this._settingAlarm) {
|
||||
// onSuccess will handle the set. Overwriting the variable enforces the
|
||||
// last-writer-wins semantics.
|
||||
this._queuedAlarmDelay = delay;
|
||||
this._waitingForAlarmSet = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop any existing alarm.
|
||||
this._stopAlarm();
|
||||
|
||||
this._settingAlarm = true;
|
||||
AlarmService.add(
|
||||
{
|
||||
date: new Date(Date.now() + delay),
|
||||
@ -637,6 +648,12 @@ this.PushService = {
|
||||
function onSuccess(alarmID) {
|
||||
this._alarmID = alarmID;
|
||||
debug("Set alarm " + delay + " in the future " + this._alarmID);
|
||||
this._settingAlarm = false;
|
||||
|
||||
if (this._waitingForAlarmSet) {
|
||||
this._waitingForAlarmSet = false;
|
||||
this._setAlarm(this._queuedAlarmDelay);
|
||||
}
|
||||
}.bind(this)
|
||||
)
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user