Skip to content

Commit

Permalink
Bug 1064132 - Listen for wake_notification to evaluate whether to syn…
Browse files Browse the repository at this point in the history
…c. r=markh
  • Loading branch information
Richard Newman committed Sep 10, 2014
1 parent bbc795a commit fc94bb9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions services/sync/modules/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ SyncScheduler.prototype = {
Svc.Obs.add("FxA:hawk:backoff:interval", this);

if (Status.checkSetup() == STATUS_OK) {
Svc.Obs.add("wake_notification", this);
Svc.Idle.addIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
}
},
Expand Down Expand Up @@ -213,6 +214,7 @@ SyncScheduler.prototype = {
case "weave:service:setup-complete":
Services.prefs.savePrefFile(null);
Svc.Idle.addIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
Svc.Obs.add("wake_notification", this);
break;
case "weave:service:start-over":
this.setDefaults();
Expand Down Expand Up @@ -248,6 +250,16 @@ SyncScheduler.prototype = {
}
}, IDLE_OBSERVER_BACK_DELAY, this, "idleDebouncerTimer");
break;
case "wake_notification":
this._log.debug("Woke from sleep.");
Utils.nextTick(() => {
// Trigger a sync if we have multiple clients.
if (this.numClients > 1) {
this._log.debug("More than 1 client. Syncing.");
this.scheduleNextSync(0);
}
});
break;
}
},

Expand Down

0 comments on commit fc94bb9

Please sign in to comment.