Bug 1362774 - return early from willOverrideHomepage if we know we won't override again, r?mikedeboer
This is a small performance optimization for callers of willOverrideHomepage.
They want to know if the URL the window was passed will be overridden. Once
we finish restoring windows, that'll never happen again, and we can return
without waiting for a promise.
MozReview-Commit-ID: NhKDHT6rBX
--- a/browser/components/sessionstore/nsSessionStartup.js
+++ b/browser/components/sessionstore/nsSessionStartup.js
@@ -261,16 +261,17 @@ SessionStartup.prototype = {
Services.obs.removeObserver(this, "quit-application");
if (this._sessionType != Ci.nsISessionStartup.NO_SESSION)
Services.obs.removeObserver(this, "browser:purge-session-history");
break;
case "sessionstore-windows-restored":
Services.obs.removeObserver(this, "sessionstore-windows-restored");
// free _initialState after nsSessionStore is done with it
this._initialState = null;
+ this._didRestore = true;
break;
case "browser:purge-session-history":
Services.obs.removeObserver(this, "browser:purge-session-history");
// reset all state on sanitization
this._sessionType = Ci.nsISessionStartup.NO_SESSION;
break;
}
},
@@ -334,16 +335,20 @@ SessionStartup.prototype = {
// If the session file hasn't been read yet and resuming the session isn't
// enabled via prefs, go ahead and load the homepage. We may still replace
// it when recovering from a crash, which we'll only know after reading the
// session file, but waiting for that would delay loading the homepage in
// the non-crash case.
if (!this._initialState && !this._resumeSessionEnabled) {
return false;
}
+ // If we've already restored the session, we won't override again.
+ if (this._didRestore) {
+ return false;
+ }
return new Promise(resolve => {
this.onceInitialized.then(() => {
// If there are valid windows with not only pinned tabs, signal that we
// will override the default homepage by restoring a session.
resolve(this._willRestore() &&
this._initialState &&
this._initialState.windows &&