mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 898308 - Clean up SessionStore initialization; f=smacleod, r=dao
This commit is contained in:
parent
f4c62a2b63
commit
749254b0b6
@ -137,6 +137,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SitePermissions",
|
||||
"resource:///modules/SitePermissions.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
|
||||
"resource:///modules/sessionstore/SessionStore.jsm");
|
||||
|
||||
let gInitialPages = [
|
||||
"about:blank",
|
||||
"about:newtab",
|
||||
@ -1033,6 +1036,7 @@ var gBrowserInit = {
|
||||
OfflineApps.init();
|
||||
IndexedDBPromptHelper.init();
|
||||
gFormSubmitObserver.init();
|
||||
SocialUI.init();
|
||||
AddonManager.addAddonListener(AddonsMgrListener);
|
||||
WebrtcIndicator.init();
|
||||
|
||||
@ -1091,10 +1095,6 @@ var gBrowserInit = {
|
||||
NP.trackBrowserWindow(window);
|
||||
}
|
||||
|
||||
// initialize the session-restore service (in case it's not already running)
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||
let ssPromise = ss.init(window);
|
||||
|
||||
PlacesToolbarHelper.init();
|
||||
|
||||
ctrlTab.readPref();
|
||||
@ -1270,14 +1270,13 @@ var gBrowserInit = {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ssPromise.then(() =>{
|
||||
SessionStore.promiseInitialized.then(() => {
|
||||
// Enable the Restore Last Session command if needed
|
||||
if (ss.canRestoreLastSession &&
|
||||
if (SessionStore.canRestoreLastSession &&
|
||||
!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
goSetCommandEnabled("Browser:RestoreLastSession", true);
|
||||
|
||||
TabView.init();
|
||||
SocialUI.init();
|
||||
|
||||
setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0);
|
||||
});
|
||||
|
@ -17,7 +17,6 @@ function resetSocial() {
|
||||
}
|
||||
|
||||
let createdWindows = [];
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||
|
||||
function openWindowAndWaitForInit(callback) {
|
||||
// this notification tells us SocialUI.init() has been run...
|
||||
@ -27,12 +26,7 @@ function openWindowAndWaitForInit(callback) {
|
||||
Services.obs.addObserver(function providerSet(subject, topic, data) {
|
||||
Services.obs.removeObserver(providerSet, topic);
|
||||
info(topic + " observer was notified - continuing test");
|
||||
// We need to wait for the SessionStore as well, since
|
||||
// SocialUI.init() is also waiting on it.
|
||||
ss.init(w).then(function () {
|
||||
executeSoon(function() {callback(w);});
|
||||
});
|
||||
|
||||
executeSoon(() => callback(w));
|
||||
}, topic, false);
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesBackups",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "OS",
|
||||
"resource://gre/modules/osfile.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
|
||||
"resource:///modules/sessionstore/SessionStore.jsm");
|
||||
|
||||
const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
|
||||
const PREF_PLUGINS_UPDATEURL = "plugins.update.url";
|
||||
|
||||
@ -173,7 +176,7 @@ BrowserGlue.prototype = {
|
||||
this._finalUIStartup();
|
||||
break;
|
||||
case "browser-delayed-startup-finished":
|
||||
this._onFirstWindowLoaded();
|
||||
this._onFirstWindowLoaded(subject);
|
||||
Services.obs.removeObserver(this, "browser-delayed-startup-finished");
|
||||
break;
|
||||
case "sessionstore-windows-restored":
|
||||
@ -579,7 +582,7 @@ BrowserGlue.prototype = {
|
||||
},
|
||||
|
||||
// the first browser window has finished initializing
|
||||
_onFirstWindowLoaded: function BG__onFirstWindowLoaded() {
|
||||
_onFirstWindowLoaded: function BG__onFirstWindowLoaded(aWindow) {
|
||||
#ifdef XP_WIN
|
||||
// For windows seven, initialize the jump list module.
|
||||
const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
|
||||
@ -591,6 +594,7 @@ BrowserGlue.prototype = {
|
||||
}
|
||||
#endif
|
||||
|
||||
SessionStore.init(aWindow);
|
||||
this._trackSlowStartup();
|
||||
|
||||
// Offer to reset a user's profile if it hasn't been used for 60 days.
|
||||
|
@ -25,14 +25,9 @@ interface nsIDOMNode;
|
||||
* |gBrowser.tabContainer| such as e.g. |gBrowser.selectedTab|.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(092fa0cc-e99b-11e2-a2a3-a25b4f45d8e2)]
|
||||
[scriptable, uuid(700756cc-f5c7-11e2-b842-59d9dc830245)]
|
||||
interface nsISessionStore : nsISupports
|
||||
{
|
||||
/**
|
||||
* Initialize the service
|
||||
*/
|
||||
jsval init(in nsIDOMWindow aWindow);
|
||||
|
||||
/**
|
||||
* Is it possible to restore the previous session. Will always be false when
|
||||
* in Private Browsing mode.
|
||||
|
@ -142,7 +142,7 @@ function debug(aMsg) {
|
||||
|
||||
this.SessionStore = {
|
||||
get promiseInitialized() {
|
||||
return SessionStoreInternal.promiseInitialized.promise;
|
||||
return SessionStoreInternal.promiseInitialized;
|
||||
},
|
||||
|
||||
get canRestoreLastSession() {
|
||||
@ -154,7 +154,7 @@ this.SessionStore = {
|
||||
},
|
||||
|
||||
init: function ss_init(aWindow) {
|
||||
return SessionStoreInternal.init(aWindow);
|
||||
SessionStoreInternal.init(aWindow);
|
||||
},
|
||||
|
||||
getBrowserState: function ss_getBrowserState() {
|
||||
@ -340,7 +340,7 @@ let SessionStoreInternal = {
|
||||
_deferredInitialState: null,
|
||||
|
||||
// A promise resolved once initialization is complete
|
||||
_promiseInitialization: Promise.defer(),
|
||||
_deferredInitialized: Promise.defer(),
|
||||
|
||||
// Whether session has been initialized
|
||||
_sessionInitialized: false,
|
||||
@ -363,7 +363,7 @@ let SessionStoreInternal = {
|
||||
* A promise fulfilled once initialization is complete.
|
||||
*/
|
||||
get promiseInitialized() {
|
||||
return this._promiseInitialization;
|
||||
return this._deferredInitialized.promise;
|
||||
},
|
||||
|
||||
/* ........ Public Getters .............. */
|
||||
@ -378,31 +378,44 @@ let SessionStoreInternal = {
|
||||
this._lastSessionState = null;
|
||||
},
|
||||
|
||||
/* ........ Global Event Handlers .............. */
|
||||
|
||||
/**
|
||||
* Initialize the component
|
||||
* Initialize the sessionstore service.
|
||||
*/
|
||||
initService: function ssi_initService() {
|
||||
if (this._sessionInitialized) {
|
||||
return;
|
||||
init: function (aWindow) {
|
||||
if (this._initialized) {
|
||||
throw new Error("SessionStore.init() must only be called once!");
|
||||
}
|
||||
|
||||
if (!aWindow) {
|
||||
throw new Error("SessionStore.init() must be called with a valid window.");
|
||||
}
|
||||
|
||||
TelemetryTimestamps.add("sessionRestoreInitialized");
|
||||
OBSERVING.forEach(function(aTopic) {
|
||||
Services.obs.addObserver(this, aTopic, true);
|
||||
}, this);
|
||||
|
||||
this._initPrefs();
|
||||
|
||||
this._initialized = true;
|
||||
this._disabledForMultiProcess = this._prefBranch.getBoolPref("tabs.remote");
|
||||
|
||||
// this pref is only read at startup, so no need to observe it
|
||||
this._sessionhistory_max_entries =
|
||||
this._prefBranch.getIntPref("sessionhistory.max_entries");
|
||||
|
||||
gSessionStartup.onceInitialized.then(
|
||||
this.initSession.bind(this)
|
||||
);
|
||||
// Wait until nsISessionStartup has finished reading the session data.
|
||||
gSessionStartup.onceInitialized.then(() => {
|
||||
// Parse session data and start restoring.
|
||||
this.initSession();
|
||||
|
||||
// Start tracking the given (initial) browser window.
|
||||
if (!aWindow.closed) {
|
||||
this.onLoad(aWindow);
|
||||
}
|
||||
|
||||
// Let everyone know we're done.
|
||||
this._deferredInitialized.resolve();
|
||||
});
|
||||
},
|
||||
|
||||
initSession: function ssi_initSession() {
|
||||
@ -492,7 +505,6 @@ let SessionStoreInternal = {
|
||||
this._performUpgradeBackup();
|
||||
|
||||
this._sessionInitialized = true;
|
||||
this._promiseInitialization.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -565,36 +577,19 @@ let SessionStoreInternal = {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Start tracking a window.
|
||||
*
|
||||
* This function also initializes the component if it is not
|
||||
* initialized yet.
|
||||
*/
|
||||
init: function ssi_init(aWindow) {
|
||||
if (!aWindow) {
|
||||
throw new Error("init() must be called with a valid window.");
|
||||
}
|
||||
|
||||
let self = this;
|
||||
this.initService();
|
||||
return this._promiseInitialization.promise.then(
|
||||
function onSuccess() {
|
||||
if (!aWindow.closed) {
|
||||
self.onLoad(aWindow);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called on application shutdown, after notifications:
|
||||
* quit-application-granted, quit-application
|
||||
*/
|
||||
_uninit: function ssi_uninit() {
|
||||
if (!this._initialized) {
|
||||
throw new Error("SessionStore is not initialized.");
|
||||
}
|
||||
|
||||
// save all data for session resuming
|
||||
if (this._sessionInitialized)
|
||||
if (this._sessionInitialized) {
|
||||
this.saveState(true);
|
||||
}
|
||||
|
||||
// clear out priority queue in case it's still holding refs
|
||||
TabRestoreQueue.reset();
|
||||
|
@ -382,13 +382,11 @@ let TestRunner = {
|
||||
run: function () {
|
||||
waitForExplicitFinish();
|
||||
|
||||
SessionStore.promiseInitialized.then(function () {
|
||||
executeSoon(function () {
|
||||
this.backupState = JSON.parse(ss.getBrowserState());
|
||||
this._iter = runTests();
|
||||
this.next();
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
SessionStore.promiseInitialized.then(() => {
|
||||
this.backupState = JSON.parse(ss.getBrowserState());
|
||||
this._iter = runTests();
|
||||
this.next();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user