Persist sync intervals because we only update it when changing the number of clients.
authorEdward Lee <edilee@mozilla.com>
Fri, 25 Sep 2009 15:41:27 -0700
changeset 45781 785d2be209b54dd1e49f9207294fbe1f37d42cde
parent 45780 fbc731e748d4ab404edc78d66f4a4db96c8d1a54
child 45782 e5836deaeacabef9d9f0f03d64a00f50698921d9
push idunknown
push userunknown
push dateunknown
Persist sync intervals because we only update it when changing the number of clients.
services/sync/modules/service.js
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -163,17 +163,16 @@ function WeaveSvc() {
 WeaveSvc.prototype = {
 
   _lock: Utils.lock,
   _catch: Utils.catch,
   _isQuitting: false,
   _loggedIn: false,
   _syncInProgress: false,
   _keyGenEnabled: true,
-  _syncInterval: SINGLE_USER_SYNC,
 
   // the status object
   _status: null,
 
   // object for caching public and private keys
   _keyPair: {},
 
   get username() {
@@ -242,16 +241,19 @@ WeaveSvc.prototype = {
 
   get enabled() { return Svc.Prefs.get("enabled"); },
   set enabled(value) { Svc.Prefs.set("enabled", value); },
 
   // nextSync is in milliseconds, but prefs can't hold that much
   get nextSync() Svc.Prefs.get("nextSync", 0) * 1000,
   set nextSync(value) Svc.Prefs.set("nextSync", Math.floor(value / 1000)),
 
+  get syncInterval() Svc.Prefs.get("syncInterval", SINGLE_USER_SYNC),
+  set syncInterval(value) Svc.Prefs.set("syncInterval", value),
+
   get numClients() Svc.Prefs.get("numClients", 0),
   set numClients(value) Svc.Prefs.set("numClients", value),
 
   get status() { return this._status; },
 
   get locked() { return this._locked; },
   lock: function Svc_lock() {
     if (this._locked)
@@ -1028,17 +1030,17 @@ WeaveSvc.prototype = {
       // Make sure we backoff we we need to
       if (this.status.backoffInterval != 0)
         interval = this.status.backoffInterval;
       // Check if we had a pending sync from last time
       else if (this.nextSync != 0)
         interval = this.nextSync - Date.now();
       // Use the default sync interval
       else 
-        interval = this._syncInterval;
+        interval = this.syncInterval;
     }
 
     // Start the sync right away if we're already late
     if (interval <= 0) {
       this.syncOnIdle();
       return;
     }
 
@@ -1214,24 +1216,24 @@ WeaveSvc.prototype = {
     if (this.numClients == numClients)
       return;
 
     this._log.debug("Client count: " + this.numClients + " -> " + numClients);
     this.numClients = numClients;
 
     let tabEngine = Engines.get("tabs");
     if (numClients == 1) {
-      this._syncInterval = SINGLE_USER_SYNC;
+      this.syncInterval = SINGLE_USER_SYNC;
 
       // Disable tabs sync for single client, but store the original value
       Svc.Prefs.set("engine.tabs.backup", tabEngine.enabled);
       tabEngine.enabled = false;
     }
     else {
-      this._syncInterval = hasMobile ? MULTI_MOBILE_SYNC : MULTI_DESKTOP_SYNC;
+      this.syncInterval = hasMobile ? MULTI_MOBILE_SYNC : MULTI_DESKTOP_SYNC;
 
       // Restore the original tab enabled value
       tabEngine.enabled = Svc.Prefs.get("engine.tabs.backup", true);
       Svc.Prefs.reset("engine.tabs.backup");
     }
   },
 
   // returns true if sync should proceed