Bug 1400865 - Put tab warming prefs on tabbrowser binding instead of async tab switcher object. r?florian draft
authorMike Conley <mconley@mozilla.com>
Mon, 18 Sep 2017 13:28:26 -0400
changeset 666380 30a1652a829f2f37d05160cd2b1b028ab8f53a74
parent 666274 ffe6cc09ccf38cca6f0e727837bbc6cb722d1e71
child 732086 d5f437043b8f7a094e3bd21dca98cd8437cc4b7d
push id80388
push usermconley@mozilla.com
push dateMon, 18 Sep 2017 17:34:09 +0000
reviewersflorian
bugs1400865
milestone57.0a1
Bug 1400865 - Put tab warming prefs on tabbrowser binding instead of async tab switcher object. r?florian MozReview-Commit-ID: 6AgTRrRb2Mp
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -4368,23 +4368,16 @@
             get minimizedOrFullyOccluded() {
               return window.windowState == window.STATE_MINIMIZED ||
                      window.isFullyOccluded;
             },
 
             init() {
               this.log("START");
 
-              XPCOMUtils.defineLazyPreferenceGetter(this, "WARMING_ENABLED",
-                                                    "browser.tabs.remote.warmup.enabled", false);
-              XPCOMUtils.defineLazyPreferenceGetter(this, "MAX_WARMING_TABS",
-                                                    "browser.tabs.remote.warmup.maxTabs", 3);
-              XPCOMUtils.defineLazyPreferenceGetter(this, "WARMING_UNLOAD_DELAY" /* ms */,
-                                                    "browser.tabs.remote.warmup.unloadDelayMs", 2000);
-
               // If we minimized the window before the switcher was activated,
               // we might have set  the preserveLayers flag for the current
               // browser. Let's clear it.
               this.tabbrowser.mCurrentBrowser.preserveLayers(false);
 
               window.addEventListener("MozAfterPaint", this);
               window.addEventListener("MozLayerTreeReady", this);
               window.addEventListener("MozLayerTreeCleared", this);
@@ -4712,18 +4705,18 @@
               // handlers, which might cause finish() to already have been called.
               // Check for that before calling finish() again.
               if (!this.tabbrowser._switcher) {
                 return;
               }
 
               this.maybeFinishTabSwitch();
 
-              if (numWarming > this.MAX_WARMING_TABS) {
-                this.logState("Hit MAX_WARMING_TABS");
+              if (numWarming > this.tabbrowser.tabWarmingMax) {
+                this.logState("Hit tabWarmingMax");
                 if (this.unloadTimer) {
                   this.clearTimer(this.unloadTimer);
                 }
                 this.unloadNonRequiredTabs();
               }
 
               if (numPending == 0) {
                 this.finish();
@@ -4932,17 +4925,17 @@
             },
 
             activateBrowserForPrintPreview(browser) {
               let tab = this.tabbrowser.getTabForBrowser(browser);
               this.setTabState(tab, this.STATE_LOADING);
             },
 
             canWarmTab(tab) {
-              if (!this.WARMING_ENABLED) {
+              if (!this.tabbrowser.tabWarmingEnabled) {
                 return false;
               }
 
               // If the tab is not yet inserted, closing, not remote,
               // crashed, already visible, or already requested, warming
               // up the tab makes no sense.
               if (this.minimizedOrFullyOccluded ||
                   !tab.linkedPanel ||
@@ -4972,26 +4965,27 @@
               if (!this.canWarmTab(tab)) {
                 return;
               }
 
               this.logState("warmupTab " + this.tinfo(tab));
 
               this.warmingTabs.add(tab);
               this.setTabState(tab, this.STATE_LOADING);
-              this.suppressDisplayPortAndQueueUnload(tab, this.WARMING_UNLOAD_DELAY);
+              this.suppressDisplayPortAndQueueUnload(tab,
+                this.tabbrowser.tabWarmingUnloadDelay);
             },
 
             // Called when the user asks to switch to a given tab.
             requestTab(tab) {
               if (tab === this.requestedTab) {
                 return;
               }
 
-              if (this.WARMING_ENABLED) {
+              if (this.tabbrowser.tabWarmingEnabled) {
                 let warmingState = "disqualified";
 
                 if (this.warmingTabs.has(tab)) {
                   let tabState = this.getTabState(tab);
                   if (tabState == this.STATE_LOADING) {
                     warmingState = "stillLoading";
                   } else if (tabState == this.STATE_LOADED) {
                     warmingState = "loaded";
@@ -5876,16 +5870,22 @@
 
           // Add listeners for prerender messages
           messageManager.addMessageListener("Prerender:Request", this);
           messageManager.addMessageListener("Prerender:Cancel", this);
           messageManager.addMessageListener("Prerender:Swap", this);
 
           XPCOMUtils.defineLazyPreferenceGetter(this, "animationsEnabled",
                                                 "toolkit.cosmeticAnimations.enabled", true);
+          XPCOMUtils.defineLazyPreferenceGetter(this, "tabWarmingEnabled",
+                                                "browser.tabs.remote.warmup.enabled", false);
+          XPCOMUtils.defineLazyPreferenceGetter(this, "tabWarmingMax",
+                                                "browser.tabs.remote.warmup.maxTabs", 3);
+          XPCOMUtils.defineLazyPreferenceGetter(this, "tabWarmingUnloadDelay" /* ms */,
+                                                "browser.tabs.remote.warmup.unloadDelayMs", 2000);
         ]]>
       </constructor>
 
       <method name="_generateUniquePanelID">
         <body><![CDATA[
           if (!this._uniquePanelIDCounter) {
             this._uniquePanelIDCounter = 0;
           }