Bug 868545 - Avoid syncing early in startup. r=mbrubeck
authorJim Mathies <jmathies@mozilla.com>
Tue, 07 May 2013 15:55:51 -0500
changeset 142133 8939cbc62b399c46216f055bbcf64dffeda41aaf
parent 142132 616f2609c29454ee9f34c7d35a098ec06f9c6c98
child 142134 86b2e2f3789c8a4e2b22e46333bbf2aebf389364
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs868545
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 868545 - Avoid syncing early in startup. r=mbrubeck
browser/metro/base/content/RemoteTabs.js
browser/metro/base/content/sync.js
browser/metro/profile/metro.js
--- a/browser/metro/base/content/RemoteTabs.js
+++ b/browser/metro/base/content/RemoteTabs.js
@@ -5,35 +5,36 @@
 
 'use strict';
 Components.utils.import("resource://services-sync/main.js");
 
 /**
  * Wraps a list/grid control implementing nsIDOMXULSelectControlElement and
  * fills it with the user's synced tabs.
  *
+ * Note, the Sync module takes care of initializing the sync service. We should
+ * not make calls that start sync or sync tabs since this module loads really
+ * early during startup.
+ *
  * @param    aSet         Control implementing nsIDOMXULSelectControlElement.
  * @param    aSetUIAccess The UI element that should be hidden when Sync is
  *                          disabled. Must sanely support 'hidden' attribute.
  *                          You may only have one UI access point at this time.
  */
 function RemoteTabsView(aSet, aSetUIAccess) {
   this._set = aSet;
   this._set.controller = this;
   this._uiAccessElement = aSetUIAccess;
 
   // Sync uses special voodoo observers.
   // If you want to change this code, talk to the fx-si team
-  Weave.Svc.Obs.add("weave:service:setup-complete", this);
   Weave.Svc.Obs.add("weave:service:sync:finish", this);
   Weave.Svc.Obs.add("weave:service:start-over", this);
   if (this.isSyncEnabled() ) {
-    this.populateTabs();
     this.populateGrid();
-    this.setUIAccessVisible(true);
   }
   else {
     this.setUIAccessVisible(false);
   }
 }
 
 RemoteTabsView.prototype = {
   _set: null,
@@ -41,20 +42,16 @@ RemoteTabsView.prototype = {
 
   handleItemClick: function tabview_handleItemClick(aItem) {
     let url = aItem.getAttribute("value");
     BrowserUI.goToURI(url);
   },
 
   observe: function(subject, topic, data) {
     switch (topic) {
-      case "weave:service:setup-complete":
-        this.populateTabs();
-        this.setUIAccessVisible(true);
-        break;
       case "weave:service:sync:finish":
         this.populateGrid();
         break;
       case "weave:service:start-over":
         this.setUIAccessVisible(false);
         break;
     }
   },
@@ -67,42 +64,39 @@ RemoteTabsView.prototype = {
 
     let tabsEngine = Weave.Service.engineManager.get("tabs");
     let list = this._set;
     let seenURLs = new Set();
 
     // Clear grid, We don't know what has happened to tabs since last sync
     // Also can result in duplicate tabs(bug 864614)
     this._set.clearAll();
-
+    let show = false;
     for (let [guid, client] in Iterator(tabsEngine.getAllClients())) {
       client.tabs.forEach(function({title, urlHistory, icon}) {
         let url = urlHistory[0];
         if (tabsEngine.locallyOpenTabMatchesURL(url) || seenURLs.has(url)) {
           return;
         }
         seenURLs.add(url);
+        show = true;
 
         // If we wish to group tabs by client, we should be looking for records
         //  of {type:client, clientName, class:{mobile, desktop}} and will
         //  need to readd logic to reset seenURLs for each client.
 
         let item = this._set.appendItem((title || url), url);
         item.setAttribute("iconURI", Weave.Utils.getIcon(icon));
 
       }, this);
     }
-  },
-
-  populateTabs: function populateTabs() {
-    Weave.Service.scheduler.scheduleNextSync(0);
+    this.setUIAccessVisible(show);
   },
 
   destruct: function destruct() {
-    Weave.Svc.Obs.remove("weave:service:setup-complete", this);
     Weave.Svc.Obs.remove("weave:engine:sync:finish", this);
     Weave.Svc.Obs.remove("weave:service:logout:start-over", this);
   },
 
   isSyncEnabled: function isSyncEnabled() {
     return (Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED);
   }
 
--- a/browser/metro/base/content/sync.js
+++ b/browser/metro/base/content/sync.js
@@ -34,16 +34,17 @@ let Sync = {
     }
 
     let service = Components.classes["@mozilla.org/weave/service;1"]
                                     .getService(Components.interfaces.nsISupports)
                                     .wrappedJSObject;
 
     if (service.ready) {
       this._init();
+      Weave.Service.scheduler.scheduleNextSync(10*1000); // ten seconds after we startup
     } else {
       Services.obs.addObserver(this, "weave:service:ready", false);
       service.ensureLoaded();
     }
   },
 
 #ifdef XP_WIN
   _securelySetupFromMetro: function() {
--- a/browser/metro/profile/metro.js
+++ b/browser/metro/profile/metro.js
@@ -411,17 +411,16 @@ pref("app.update.showInstalledUI", false
 pref("app.update.incompatible.mode", 0);
 
 // replace newlines with spaces on paste into single-line text boxes
 pref("editor.singleLine.pasteNewlines", 2);
 
 #ifdef MOZ_SERVICES_SYNC
 // sync service
 pref("services.sync.registerEngines", "Tab,Bookmarks,Form,History,Password,Prefs");
-pref("services.sync.autoconnectDelay", 5);
 
 // prefs to sync by default
 pref("services.sync.prefs.sync.browser.startup.sessionRestore", true);
 pref("services.sync.prefs.sync.browser.tabs.warnOnClose", true);
 pref("services.sync.prefs.sync.devtools.errorconsole.enabled", true);
 pref("services.sync.prefs.sync.lightweightThemes.isThemeSelected", true);
 pref("services.sync.prefs.sync.lightweightThemes.usedThemes", true);
 pref("services.sync.prefs.sync.privacy.donottrackheader.enabled", true);