зеркало из https://github.com/mozilla/gecko-dev.git
Correctly cancel any sync triggers after starting a sync with a shared function that removes timers and idle observers.
This commit is contained in:
Родитель
13ec4c4921
Коммит
fc8b595236
|
@ -985,6 +985,23 @@ WeaveSvc.prototype = {
|
|||
return reason;
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove any timers/observers that might trigger a sync
|
||||
*/
|
||||
_clearSyncTriggers: function _clearSyncTriggers() {
|
||||
// Clear out any scheduled syncs
|
||||
if (this._syncTimer) {
|
||||
this._syncTimer.cancel();
|
||||
this._syncTimer = null;
|
||||
}
|
||||
|
||||
// Clear out a sync that's just waiting for idle if we happen to have one
|
||||
try {
|
||||
Svc.Idle.removeIdleObserver(this, IDLE_TIME);
|
||||
}
|
||||
catch(ex) {}
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if we should be syncing and schedule the next sync, if it's not scheduled
|
||||
*/
|
||||
|
@ -993,15 +1010,7 @@ WeaveSvc.prototype = {
|
|||
// if we're in backoff, we'll schedule the next sync
|
||||
let reason = this._checkSync();
|
||||
if (reason && reason != kSyncBackoffNotMet) {
|
||||
if (this._syncTimer) {
|
||||
this._syncTimer.cancel();
|
||||
this._syncTimer = null;
|
||||
}
|
||||
|
||||
try {
|
||||
Svc.Idle.removeIdleObserver(this, IDLE_TIME);
|
||||
} catch(e) {} // this throws if there isn't an observer, but that's fine
|
||||
|
||||
this._clearSyncTriggers();
|
||||
this.status.service = STATUS_DISABLED;
|
||||
return;
|
||||
}
|
||||
|
@ -1093,10 +1102,8 @@ WeaveSvc.prototype = {
|
|||
throw reason;
|
||||
}
|
||||
|
||||
if (this._autoConnectTimer) {
|
||||
this._autoConnectTimer.cancel();
|
||||
this._autoConnectTimer = null;
|
||||
}
|
||||
// Clear out any potentially pending syncs now that we're syncing
|
||||
this._clearSyncTriggers();
|
||||
|
||||
if (!(this._remoteSetup()))
|
||||
throw "aborting sync, remote setup failed";
|
||||
|
|
Загрузка…
Ссылка в новой задаче