Backed out changeset 23fbfd83e957 (bug 1416320) for ESlint failure at gecko/services/sync/modules/policies.js:558:71 on a CLOSED TREE

This commit is contained in:
Cosmin Sabou 2017-11-21 07:26:51 +02:00
parent b957047e49
commit 959009f1a8
3 changed files with 19 additions and 32 deletions

View File

@ -177,7 +177,6 @@ SyncScheduler.prototype = {
if (Status.checkSetup() == STATUS_OK) {
Svc.Obs.add("wake_notification", this);
Svc.Obs.add("captive-portal-login-success", this);
Svc.Obs.add("sleep_notification", this);
IdleService.addIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
}
},
@ -329,7 +328,6 @@ SyncScheduler.prototype = {
IdleService.addIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
Svc.Obs.add("wake_notification", this);
Svc.Obs.add("captive-portal-login-success", this);
Svc.Obs.add("sleep_notification", this);
break;
case "weave:service:start-over":
this.setDefaults();
@ -391,9 +389,6 @@ SyncScheduler.prototype = {
CommonUtils.nextTick(() => {
this.scheduleNextSync(3000);
});
case "sleep_notification":
this._log.debug("Going to sleep, doing a quick sync.");
this.scheduleNextSync(0, ["tabs"], "sleep");
break;
}
},
@ -495,7 +490,7 @@ SyncScheduler.prototype = {
*
* Otherwise, reschedule a sync for later.
*/
syncIfMPUnlocked(engines, why) {
syncIfMPUnlocked: function syncIfMPUnlocked() {
// No point if we got kicked out by the master password dialog.
if (Status.login == MASTER_PASSWORD_LOCKED &&
Utils.mpLocked()) {
@ -511,15 +506,13 @@ SyncScheduler.prototype = {
this._log.debug("Not initiating sync: app is shutting down");
return;
}
Services.tm.dispatchToMainThread(() => {
this.service.sync({engines, why});
});
CommonUtils.nextTick(this.service.sync, this.service);
},
/**
* Set a timer for the next sync
*/
scheduleNextSync(interval, engines = null, why = null) {
scheduleNextSync: function scheduleNextSync(interval) {
// If no interval was specified, use the current sync interval.
if (interval == null) {
interval = this.syncInterval;
@ -550,13 +543,12 @@ SyncScheduler.prototype = {
// Start the sync right away if we're already late.
if (interval <= 0) {
this._log.trace("Requested sync should happen right away.");
this.syncIfMPUnlocked(engines, why);
this.syncIfMPUnlocked();
return;
}
this._log.debug("Next sync in " + interval + " ms.");
CommonUtils.namedTimer(() => { this.syncIfMPUnlocked(engines, why) },
interval, this, "syncTimer");
CommonUtils.namedTimer(this.syncIfMPUnlocked, interval, this, "syncTimer");
// Save the next sync time in-case sync is disabled (logout/offline/etc.)
this.nextSync = Date.now() + interval;

View File

@ -908,8 +908,8 @@ Sync11Service.prototype = {
// Stuff we need to do after login, before we can really do
// anything (e.g. key setup).
async _remoteSetup(infoResponse, fetchConfig = true) {
if (fetchConfig && !(await this._fetchServerConfiguration())) {
async _remoteSetup(infoResponse) {
if (!(await this._fetchServerConfiguration())) {
return false;
}
@ -1112,7 +1112,7 @@ Sync11Service.prototype = {
histogram.add(1);
let synchronizer = new EngineSynchronizer(this);
await synchronizer.sync(engineNamesToSync, why); // Might throw!
await synchronizer.sync(engineNamesToSync); // Might throw!
histogram = Services.telemetry.getHistogramById("WEAVE_COMPLETE_SUCCESS_COUNT");
histogram.add(1);

View File

@ -31,8 +31,7 @@ this.EngineSynchronizer = function EngineSynchronizer(service) {
};
EngineSynchronizer.prototype = {
async sync(engineNamesToSync, why) {
let fastSync = why && why == "sleep";
async sync(engineNamesToSync) {
let startTime = Date.now();
this.service.status.resetSync();
@ -76,19 +75,17 @@ EngineSynchronizer.prototype = {
engine.lastModified = info.obj[engine.name] || 0;
}
if (!(await this.service._remoteSetup(info, !fastSync))) {
if (!(await this.service._remoteSetup(info))) {
throw new Error("Aborting sync, remote setup failed");
}
if (!fastSync) {
// Make sure we have an up-to-date list of clients before sending commands
this._log.debug("Refreshing client list.");
if (!(await this._syncEngine(this.service.clientsEngine))) {
// Clients is an engine like any other; it can fail with a 401,
// and we can elect to abort the sync.
this._log.warn("Client engine sync failed. Aborting.");
return;
}
// Make sure we have an up-to-date list of clients before sending commands
this._log.debug("Refreshing client list.");
if (!(await this._syncEngine(this.service.clientsEngine))) {
// Clients is an engine like any other; it can fail with a 401,
// and we can elect to abort the sync.
this._log.warn("Client engine sync failed. Aborting.");
return;
}
// We only honor the "hint" of what engines to Sync if this isn't
@ -110,7 +107,7 @@ EngineSynchronizer.prototype = {
break;
}
if (!fastSync && this.service.clientsEngine.localCommands) {
if (this.service.clientsEngine.localCommands) {
try {
if (!(await this.service.clientsEngine.processIncomingCommands())) {
this.service.status.sync = ABORT_SYNC_COMMAND;
@ -182,9 +179,7 @@ EngineSynchronizer.prototype = {
}
}
if (!fastSync) {
await Doctor.consult(enginesToValidate);
}
await Doctor.consult(enginesToValidate);
// If there were no sync engine failures
if (this.service.status.service != SYNC_FAILED_PARTIAL) {