Bug 668760 - Refactor get desktop tabs to receive weave engine as argument (r=mbrubeck)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 23 Aug 2011 09:16:09 -0700
changeset 75751 4a130dda0ed837fafe3555f32aee1737d4e419b4
parent 75750 f532be24c7c85950dd1bdaf8d0a38d5909da7b56
child 75752 4a4b93a6a7341fd1e88af8ad51dfc726dbe12e8e
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmbrubeck
bugs668760
milestone9.0a1
Bug 668760 - Refactor get desktop tabs to receive weave engine as argument (r=mbrubeck) This is necessary to be able to know whether we're loading sync desktop tabs from a functional/configured sync process or not.
mobile/chrome/content/bindings.xml
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -1410,18 +1410,24 @@
       </method>
 
       <method name="_loadChildren">
         <body><![CDATA[
           let children = this._children;
           while (children.lastChild)
             children.removeChild(children.lastChild);
 
-          let items = this._getRemoteTabs();
-          children.setItems(items.map(this.createItem));
+          let engine = this._getWeaveEngine();
+
+          // Only load items if the tabs engine is ready
+          if (engine) {
+            let items = this._getRemoteTabs(engine);
+            children.setItems(items.map(this.createItem));
+          }
+
           this.removeAttribute("loading");
         ]]></body>
       </method>
 
       <field name="_children">
         document.getAnonymousElementByAttribute(this, "anonid", "child-items");
       </field>
 
@@ -1435,35 +1441,31 @@
           if (Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED)
             return null;
 
           return Weave.Engines.get("tabs");
         ]]></body>
       </method>
 
       <method name="_getRemoteTabs">
+        <parameter name="aEngine"/>
         <body><![CDATA[
-          // Don't do anything if the tabs engine isn't ready
-          let engine = this._getWeaveEngine();
-          if (!engine)
-            return [];
-
           // Don't bother refetching tabs if we already did so recently
           let lastFetch = Weave.Svc.Prefs.get("lastTabFetch", 0);
           let now = Math.floor(Date.now() / 1000);
           if (now - lastFetch >= Services.prefs.getIntPref("browser.display.remotetabs.timeout")) {
             // Force a sync only for the tabs engine
-            engine.lastModified = null;
-            engine.sync();
+            aEngine.lastModified = null;
+            aEngine.sync();
             Weave.Svc.Prefs.set("lastTabFetch", now);
           };
 
           // Generate the list of tabs
           let tabs = [];
-          for (let [guid, client] in Iterator(engine.getAllClients())) {
+          for (let [guid, client] in Iterator(aEngine.getAllClients())) {
             if (!client.tabs.length)
               continue;
 
             tabs.push({ name: client.clientName });
 
             client.tabs.forEach(function({title, urlHistory, icon}) {
               let pageURL = urlHistory[0];