Bug 604437 - [Regression] Remote Tab badging slows down awesome bar panning [r=vingtetun]
authorMark Finkle <mfinkle@mozilla.com>
Fri, 15 Oct 2010 08:39:27 -0400
changeset 66837 2cbc42743401709b017e3f95547bba3064e38b58
parent 66836 e5b8400187b04b8e7ab3d81c50abe55bac932481
child 66838 62cd6c6c7e9e98f680e3e6c324ff63bbdc951a83
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs604437
Bug 604437 - [Regression] Remote Tab badging slows down awesome bar panning [r=vingtetun]
mobile/chrome/content/bindings.xml
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -425,41 +425,71 @@
       <method name="unregisterBagdeHandler">
         <parameter name="aURL"/>
         <body><![CDATA[
           if (this._badges[aURL])
             delete this._badges[aURL];
         ]]></body>
       </method>
 
+      <method name="_getRemoteTabs">
+        <body><![CDATA[
+          // This method does as little as possible to retrieve data about remote
+          // tabs. Only the raw data is returned. Nothing is post-processed, which
+          // could happen in the remotetabs-list binding method of the same name.
+
+          // Don't do anything if the Weave isn't ready
+          if (document.getElementById("cmd_remoteTabs").getAttribute("disabled") == "true")
+            return [];
+
+          // Don't do anything if the tabs engine isn't ready
+          let engine = Weave.Engines.get("tabs");
+          if (!engine)
+            return [];
+
+          // Generate the list of tabs we already have locally. Do not force a
+          // tab engine sync.
+          let tabs = [];
+          for (let [guid, client] in Iterator(engine.getAllClients())) {
+            client.tabs.forEach(function({ title, urlHistory, icon }) {
+              let pageURL = urlHistory[0];
+
+              tabs.push({
+                title: title || pageURL,
+                uri: pageURL,
+                icon: icon
+              });
+            });
+          };
+
+          return tabs;
+        ]]></body>
+      </method>
+
       <method name="_invalidateBadges">
         <body><![CDATA[
           window.clearTimeout(this._badgesTimeout);
 
           this._badgesTimeout = window.setTimeout(function(self) {
 #ifdef MOZ_SERVICES_SYNC
-            let remoteItems = RemoteTabsList.panel._getRemoteTabs();
+            let remoteItems = self._getRemoteTabs();
 #endif
             for (let i = 0; i < self._items.childNodes.length; i++) {
               let item = self._items.childNodes[i];
               if (!item.hasAttribute("url"))
                 continue;
 
               let itemURL = item.getAttribute("url");
-              let itemURI = Services.io.newURI(itemURL, null, null);
 
 #ifdef MOZ_SERVICES_SYNC
               // check if the tab is in the remote list
               for (let i = 0; i < remoteItems.length; i++) {
                 let remoteURL = remoteItems[i].uri;
-                if (remoteURL) {
-                  let remoteURI = Services.io.newURI(remoteURL, null, null);
-                  if (itemURI.equals(remoteURI))
-                    item.setAttribute("remote", "true");
-                }
+                if (remoteURL == itemURL)
+                  item.setAttribute("remote", "true");
               }
 #endif
 
               for (let badgeURL in self._badges) {
                 if (itemURL.indexOf(badgeURL) == 0) {
                   // wrap the item to prevent setting a badge on a wrong item
                   let wrapper = {
                     set: function(aBadge) {
@@ -1307,20 +1337,16 @@
           // Generate the list of tabs
           let tabs = [];
           for (let [guid, client] in Iterator(engine.getAllClients())) {
             tabs.push({ name: client.clientName });
 
             client.tabs.forEach(function({title, urlHistory, icon}) {
               let pageURL = urlHistory[0];
 
-              // Skip tabs that are already open
-              if (engine.locallyOpenTabMatchesURL(pageURL))
-                return;
-
               tabs.push({
                 title: title || pageURL,
                 uri: pageURL,
                 icon: Weave.Utils.getIcon(icon, "chrome://browser/skin/images/tab.png")
               });
             });
           };