Bug 1416321 - Do a sync after we successfully connect to a captive portal. r?markh
MozReview-Commit-ID: HuXyJ8IrNwA
--- a/services/sync/modules/policies.js
+++ b/services/sync/modules/policies.js
@@ -129,16 +129,17 @@ SyncScheduler.prototype = {
Svc.Obs.add("weave:service:ready", this);
Svc.Obs.add("weave:engine:sync:applied", this);
Svc.Obs.add("weave:service:setup-complete", this);
Svc.Obs.add("weave:service:start-over", this);
Svc.Obs.add("FxA:hawk:backoff:interval", this);
if (Status.checkSetup() == STATUS_OK) {
Svc.Obs.add("wake_notification", this);
+ Svc.Obs.add("captive-portal-login-success", this);
IdleService.addIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
}
},
// eslint-disable-next-line complexity
observe: function observe(subject, topic, data) {
this._log.trace("Handling " + topic);
switch (topic) {
@@ -270,16 +271,17 @@ SyncScheduler.prototype = {
if (subject.newFailed) {
this._log.error(`Engine ${data} found ${subject.newFailed} new records that failed to apply`);
}
break;
case "weave:service:setup-complete":
Services.prefs.savePrefFile(null);
IdleService.addIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
Svc.Obs.add("wake_notification", this);
+ Svc.Obs.add("captive-portal-login-success", this);
break;
case "weave:service:start-over":
this.setDefaults();
try {
IdleService.removeIdleObserver(this, Svc.Prefs.get("scheduler.idleTime"));
} catch (ex) {
if (ex.result != Cr.NS_ERROR_FAILURE) {
throw ex;
@@ -319,16 +321,22 @@ SyncScheduler.prototype = {
// Trigger a sync if we have multiple clients. We give it 5 seconds
// incase the network is still in the process of coming back up.
if (this.numClients > 1) {
this._log.debug("More than 1 client. Will sync in 5s.");
this.scheduleNextSync(5000);
}
});
break;
+ case "captive-portal-login-success":
+ this._log.debug("Captive portal login success. Scheduling a sync.");
+ CommonUtils.nextTick(() => {
+ this.scheduleNextSync(3000);
+ });
+ break;
}
},
adjustSyncInterval: function adjustSyncInterval() {
if (Status.eol) {
this._log.debug("Server status is EOL; using eolInterval.");
this.syncInterval = this.eolInterval;
return;