Bug 1317587 - don't start scheduled sync after shutdown. r=rnewman

MozReview-Commit-ID: GSyWAUa1qyr

--HG--
extra : rebase_source : 45d0dfd5c686803f017230ab6152d0204a3d4c8e
This commit is contained in:
Mark Hammond 2016-11-15 15:28:52 +11:00
Родитель 8304bb1bd5
Коммит 9c1b1b298b
2 изменённых файлов: 21 добавлений и 1 удалений

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

@ -112,7 +112,8 @@ this.Async = {
},
/**
* Check if the app is still ready (not quitting).
* Check if the app is still ready (not quitting). Returns true, or throws an
* exception if not ready.
*/
checkAppReady: function checkAppReady() {
// Watch for app-quit notification to stop any sync calls
@ -128,6 +129,21 @@ this.Async = {
return (Async.checkAppReady = function() { return true; })();
},
/**
* Check if the app is still ready (not quitting). Returns true if the app
* is ready, or false if it is being shut down.
*/
isAppReady() {
try {
return Async.checkAppReady()
} catch (ex) {
if (!Async.isShutdownException(ex)) {
throw ex;
}
}
return false;
},
/**
* Check if the passed exception is one raised by checkAppReady. Typically
* this will be used in exception handlers to allow such exceptions to

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

@ -401,6 +401,10 @@ SyncScheduler.prototype = {
return;
}
if (!Async.isAppReady()) {
this._log.debug("Not initiating sync: app is shutting down");
return;
}
Utils.nextTick(this.service.sync, this.service);
},