Bug 1448102 - Move tabWarmingEnabled, tabWarmingMax, tabWarmingUnloadDelay properties from gBrowser to AsyncTabSwitcher.jsm. r?mconley draft
authorDão Gottwald <dao@mozilla.com>
Thu, 22 Mar 2018 19:36:00 +0100
changeset 771200 ee58d4f0962c23edb209560d17330a72eb387155
parent 771195 ed8bd12b78191fb19bca8c38558f5b7a9e4da2ae
push id103610
push userdgottwald@mozilla.com
push dateThu, 22 Mar 2018 18:37:12 +0000
reviewersmconley
bugs1448102
milestone61.0a1
Bug 1448102 - Move tabWarmingEnabled, tabWarmingMax, tabWarmingUnloadDelay properties from gBrowser to AsyncTabSwitcher.jsm. r?mconley MozReview-Commit-ID: 2pI1aDUxWFw
browser/base/content/tabbrowser.js
browser/modules/AsyncTabSwitcher.jsm
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -54,25 +54,19 @@ window._gBrowser = {
 
     // To correctly handle keypresses for potential FindAsYouType, while
     // the tab's find bar is not yet initialized.
     this._findAsYouType = Services.prefs.getBoolPref("accessibility.typeaheadfind");
     Services.prefs.addObserver("accessibility.typeaheadfind", this);
     messageManager.addMessageListener("Findbar:Keypress", this);
 
     XPCOMUtils.defineLazyPreferenceGetter(this, "animationsEnabled",
-      "toolkit.cosmeticAnimations.enabled", true);
+      "toolkit.cosmeticAnimations.enabled");
     XPCOMUtils.defineLazyPreferenceGetter(this, "schedulePressureDefaultCount",
-      "browser.schedulePressure.defaultCount", 3);
-    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);
+      "browser.schedulePressure.defaultCount");
 
     this._setupEventListeners();
   },
 
   ownerGlobal: window,
 
   ownerDocument: document,
 
--- a/browser/modules/AsyncTabSwitcher.jsm
+++ b/browser/modules/AsyncTabSwitcher.jsm
@@ -9,16 +9,23 @@ var EXPORTED_SYMBOLS = ["AsyncTabSwitche
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 XPCOMUtils.defineLazyModuleGetters(this, {
   AppConstants: "resource://gre/modules/AppConstants.jsm",
   Services: "resource://gre/modules/Services.jsm",
   TelemetryStopwatch: "resource://gre/modules/TelemetryStopwatch.jsm",
 });
 
+XPCOMUtils.defineLazyPreferenceGetter(this, "gTabWarmingEnabled",
+  "browser.tabs.remote.warmup.enabled");
+XPCOMUtils.defineLazyPreferenceGetter(this, "gTabWarmingMax",
+  "browser.tabs.remote.warmup.maxTabs");
+XPCOMUtils.defineLazyPreferenceGetter(this, "gTabWarmingUnloadDelayMs",
+  "browser.tabs.remote.warmup.unloadDelayMs");
+
 /**
  * The tab switcher is responsible for asynchronously switching
  * tabs in e10s. It waits until the new tab is ready (i.e., the
  * layer tree is available) before switching to it. Then it
  * unloads the layer tree for the old tab.
  *
  * The tab switcher is a state machine. For each tab, it
  * maintains state about whether the layer tree for the tab is
@@ -596,17 +603,17 @@ class AsyncTabSwitcher {
     // 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.tabbrowser.tabWarmingMax) {
+    if (numWarming > gTabWarmingMax) {
       this.logState("Hit tabWarmingMax");
       if (this.unloadTimer) {
         this.clearTimer(this.unloadTimer);
       }
       this.unloadNonRequiredTabs();
     }
 
     if (numPending == 0) {
@@ -816,17 +823,17 @@ class AsyncTabSwitcher {
     if (state != this.STATE_LOADING &&
         state != this.STATE_LOADED) {
       this.setTabState(tab, this.STATE_LOADING);
       this.logState("Activated browser " + this.tinfo(tab) + " for print preview");
     }
   }
 
   canWarmTab(tab) {
-    if (!this.tabbrowser.tabWarmingEnabled) {
+    if (!gTabWarmingEnabled) {
       return false;
     }
 
     if (!tab) {
       return false;
     }
 
     // If the tab is not yet inserted, closing, not remote,
@@ -865,27 +872,26 @@ class AsyncTabSwitcher {
     if (!this.shouldWarmTab(tab)) {
       return;
     }
 
     this.logState("warmupTab " + this.tinfo(tab));
 
     this.warmingTabs.add(tab);
     this.setTabState(tab, this.STATE_LOADING);
-    this.suppressDisplayPortAndQueueUnload(tab,
-      this.tabbrowser.tabWarmingUnloadDelay);
+    this.suppressDisplayPortAndQueueUnload(tab, gTabWarmingUnloadDelayMs);
   }
 
   // Called when the user asks to switch to a given tab.
   requestTab(tab) {
     if (tab === this.requestedTab) {
       return;
     }
 
-    if (this.tabbrowser.tabWarmingEnabled) {
+    if (gTabWarmingEnabled) {
       let warmingState = "disqualified";
 
       if (this.canWarmTab(tab)) {
         let tabState = this.getTabState(tab);
         if (tabState == this.STATE_LOADING) {
           warmingState = "stillLoading";
         } else if (tabState == this.STATE_LOADED) {
           warmingState = "loaded";