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 77062 4a130dda0ed837fafe3555f32aee1737d4e419b4
parent 77061 f532be24c7c85950dd1bdaf8d0a38d5909da7b56
child 77063 4a4b93a6a7341fd1e88af8ad51dfc726dbe12e8e
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs668760
milestone9.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 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];