Bug 1416321 - Do a sync after we successfully connect to a captive portal. r=markh
authorEdouard Oger <eoger@fastmail.com>
Fri, 10 Nov 2017 14:55:19 -0500
changeset 436111 2af71f8e9ca31859edc5dae64bbffa856d00194f
parent 436110 983664f404549a4aaabab09a12a4cf458f1c6f55
child 436112 ca5529c5b2324352734feddb9c928192b8350a56
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersmarkh
bugs1416321
milestone59.0a1
Bug 1416321 - Do a sync after we successfully connect to a captive portal. r=markh MozReview-Commit-ID: HuXyJ8IrNwA
services/sync/modules/policies.js
--- 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;