Bug 979034 - [Australis] Make CustomizationTabPreloader kick-off when the user opens the menu panel. r=ttaubert.

This commit is contained in:
Mike Conley 2014-03-04 11:48:00 -05:00
parent fc175da9d1
commit a3a9b7abb1
4 changed files with 21 additions and 41 deletions

View File

@ -154,6 +154,10 @@ const PanelUI = {
this.panel.addEventListener("popupshown", function onPopupShown() {
this.removeEventListener("popupshown", onPopupShown);
// As an optimization for the customize mode transition, we preload
// about:customizing in the background once the menu panel is first
// shown.
gCustomizationTabPreloader.ensurePreloading();
deferred.resolve();
});
});

View File

@ -269,6 +269,11 @@ CustomizeMode.prototype = {
panelContents.removeAttribute("customize-transitioning");
CustomizableUI.dispatchToolboxEvent("customizationready", {}, window);
// It's possible that we didn't enter customize mode via the menu panel,
// meaning we didn't kick off about:customizing preloading. If that's
// the case, let's kick it off for the next time we load this mode.
window.gCustomizationTabPreloader.ensurePreloading();
if (!this._wantToBeInCustomizeMode) {
this.exit();
}

View File

@ -472,7 +472,6 @@ BrowserGlue.prototype = {
PageThumbs.init();
NewTabUtils.init();
BrowserNewTabPreloader.init();
CustomizationTabPreloader.init();
SignInToWebsiteUX.init();
PdfJs.init();
#ifdef NIGHTLY_BUILD

View File

@ -21,12 +21,6 @@ const CUSTOMIZATION_URL = "about:customizing";
// The interval between swapping in a preload docShell and kicking off the
// next preload in the background.
const PRELOADER_INTERVAL_MS = 600;
// The initial delay before we start preloading our first customization page. The
// timer is started after the first 'browser-delayed-startup' has been sent.
const PRELOADER_INIT_DELAY_MS = 7000;
const TOPIC_TIMER_CALLBACK = "timer-callback";
const TOPIC_DELAYED_STARTUP = "browser-delayed-startup-finished";
function createTimer(obj, delay) {
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
@ -42,10 +36,6 @@ function clearTimer(timer) {
}
this.CustomizationTabPreloader = {
init: function() {
CustomizationTabPreloaderInternal.init();
},
uninit: function () {
CustomizationTabPreloaderInternal.uninit();
},
@ -53,28 +43,23 @@ this.CustomizationTabPreloader = {
newTab: function (aTab) {
return CustomizationTabPreloaderInternal.newTab(aTab);
},
/**
* ensurePreloading starts the preloading of the about:customizing
* content page. This function is idempotent (until a call to uninit),
* so multiple calls to it are fine.
*/
ensurePreloading: function() {
CustomizationTabPreloaderInternal.ensurePreloading();
},
};
Object.freeze(CustomizationTabPreloader);
this.CustomizationTabPreloaderInternal = {
_browser: null,
_timer: null,
_observing: false,
init: function () {
Services.obs.addObserver(this, TOPIC_DELAYED_STARTUP, false);
this._observing = true;
},
uninit: function () {
this._timer = clearTimer(this._timer);
if (this._observing) {
Services.obs.removeObserver(this, TOPIC_DELAYED_STARTUP);
this._observing = false;
}
HostFrame.destroy();
if (this._browser) {
@ -92,23 +77,10 @@ this.CustomizationTabPreloaderInternal = {
return false;
},
observe: function (aSubject, aTopic, aData) {
if (aTopic == TOPIC_DELAYED_STARTUP) {
Services.obs.removeObserver(this, TOPIC_DELAYED_STARTUP);
this._observing = false;
this._startTimer();
} else if (aTopic == TOPIC_TIMER_CALLBACK) {
this._timer = null;
this._startPreloader();
ensurePreloading: function () {
if (!this._browser) {
this._browser = new HiddenBrowser();
}
},
_startTimer: function () {
this._timer = createTimer(this, PRELOADER_INIT_DELAY_MS);
},
_startPreloader: function () {
this._browser = new HiddenBrowser();
}
};