зеркало из https://github.com/mozilla/gecko-dev.git
Bug 898308 - Clean up SessionStore initialization; f=smacleod, r=dao
This commit is contained in:
Родитель
d5c51c0a29
Коммит
16e45525b3
|
@ -137,6 +137,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "SitePermissions",
|
XPCOMUtils.defineLazyModuleGetter(this, "SitePermissions",
|
||||||
"resource:///modules/SitePermissions.jsm");
|
"resource:///modules/SitePermissions.jsm");
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
|
||||||
|
"resource:///modules/sessionstore/SessionStore.jsm");
|
||||||
|
|
||||||
let gInitialPages = [
|
let gInitialPages = [
|
||||||
"about:blank",
|
"about:blank",
|
||||||
"about:newtab",
|
"about:newtab",
|
||||||
|
@ -1033,6 +1036,7 @@ var gBrowserInit = {
|
||||||
OfflineApps.init();
|
OfflineApps.init();
|
||||||
IndexedDBPromptHelper.init();
|
IndexedDBPromptHelper.init();
|
||||||
gFormSubmitObserver.init();
|
gFormSubmitObserver.init();
|
||||||
|
SocialUI.init();
|
||||||
AddonManager.addAddonListener(AddonsMgrListener);
|
AddonManager.addAddonListener(AddonsMgrListener);
|
||||||
WebrtcIndicator.init();
|
WebrtcIndicator.init();
|
||||||
|
|
||||||
|
@ -1091,10 +1095,6 @@ var gBrowserInit = {
|
||||||
NP.trackBrowserWindow(window);
|
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();
|
PlacesToolbarHelper.init();
|
||||||
|
|
||||||
ctrlTab.readPref();
|
ctrlTab.readPref();
|
||||||
|
@ -1270,14 +1270,13 @@ var gBrowserInit = {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssPromise.then(() =>{
|
SessionStore.promiseInitialized.then(() => {
|
||||||
// Enable the Restore Last Session command if needed
|
// Enable the Restore Last Session command if needed
|
||||||
if (ss.canRestoreLastSession &&
|
if (SessionStore.canRestoreLastSession &&
|
||||||
!PrivateBrowsingUtils.isWindowPrivate(window))
|
!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||||
goSetCommandEnabled("Browser:RestoreLastSession", true);
|
goSetCommandEnabled("Browser:RestoreLastSession", true);
|
||||||
|
|
||||||
TabView.init();
|
TabView.init();
|
||||||
SocialUI.init();
|
|
||||||
|
|
||||||
setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0);
|
setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0);
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,6 @@ function resetSocial() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let createdWindows = [];
|
let createdWindows = [];
|
||||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
|
||||||
|
|
||||||
function openWindowAndWaitForInit(callback) {
|
function openWindowAndWaitForInit(callback) {
|
||||||
// this notification tells us SocialUI.init() has been run...
|
// 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.addObserver(function providerSet(subject, topic, data) {
|
||||||
Services.obs.removeObserver(providerSet, topic);
|
Services.obs.removeObserver(providerSet, topic);
|
||||||
info(topic + " observer was notified - continuing test");
|
info(topic + " observer was notified - continuing test");
|
||||||
// We need to wait for the SessionStore as well, since
|
executeSoon(() => callback(w));
|
||||||
// SocialUI.init() is also waiting on it.
|
|
||||||
ss.init(w).then(function () {
|
|
||||||
executeSoon(function() {callback(w);});
|
|
||||||
});
|
|
||||||
|
|
||||||
}, topic, false);
|
}, topic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesBackups",
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "OS",
|
XPCOMUtils.defineLazyModuleGetter(this, "OS",
|
||||||
"resource://gre/modules/osfile.jsm");
|
"resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
|
||||||
|
"resource:///modules/sessionstore/SessionStore.jsm");
|
||||||
|
|
||||||
const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
|
const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
|
||||||
const PREF_PLUGINS_UPDATEURL = "plugins.update.url";
|
const PREF_PLUGINS_UPDATEURL = "plugins.update.url";
|
||||||
|
|
||||||
|
@ -173,7 +176,7 @@ BrowserGlue.prototype = {
|
||||||
this._finalUIStartup();
|
this._finalUIStartup();
|
||||||
break;
|
break;
|
||||||
case "browser-delayed-startup-finished":
|
case "browser-delayed-startup-finished":
|
||||||
this._onFirstWindowLoaded();
|
this._onFirstWindowLoaded(subject);
|
||||||
Services.obs.removeObserver(this, "browser-delayed-startup-finished");
|
Services.obs.removeObserver(this, "browser-delayed-startup-finished");
|
||||||
break;
|
break;
|
||||||
case "sessionstore-windows-restored":
|
case "sessionstore-windows-restored":
|
||||||
|
@ -579,7 +582,7 @@ BrowserGlue.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// the first browser window has finished initializing
|
// the first browser window has finished initializing
|
||||||
_onFirstWindowLoaded: function BG__onFirstWindowLoaded() {
|
_onFirstWindowLoaded: function BG__onFirstWindowLoaded(aWindow) {
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
// For windows seven, initialize the jump list module.
|
// For windows seven, initialize the jump list module.
|
||||||
const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
|
const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
|
||||||
|
@ -591,6 +594,7 @@ BrowserGlue.prototype = {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SessionStore.init(aWindow);
|
||||||
this._trackSlowStartup();
|
this._trackSlowStartup();
|
||||||
|
|
||||||
// Offer to reset a user's profile if it hasn't been used for 60 days.
|
// 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|.
|
* |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
|
interface nsISessionStore : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Initialize the service
|
|
||||||
*/
|
|
||||||
jsval init(in nsIDOMWindow aWindow);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is it possible to restore the previous session. Will always be false when
|
* Is it possible to restore the previous session. Will always be false when
|
||||||
* in Private Browsing mode.
|
* in Private Browsing mode.
|
||||||
|
|
|
@ -142,7 +142,7 @@ function debug(aMsg) {
|
||||||
|
|
||||||
this.SessionStore = {
|
this.SessionStore = {
|
||||||
get promiseInitialized() {
|
get promiseInitialized() {
|
||||||
return SessionStoreInternal.promiseInitialized.promise;
|
return SessionStoreInternal.promiseInitialized;
|
||||||
},
|
},
|
||||||
|
|
||||||
get canRestoreLastSession() {
|
get canRestoreLastSession() {
|
||||||
|
@ -154,7 +154,7 @@ this.SessionStore = {
|
||||||
},
|
},
|
||||||
|
|
||||||
init: function ss_init(aWindow) {
|
init: function ss_init(aWindow) {
|
||||||
return SessionStoreInternal.init(aWindow);
|
SessionStoreInternal.init(aWindow);
|
||||||
},
|
},
|
||||||
|
|
||||||
getBrowserState: function ss_getBrowserState() {
|
getBrowserState: function ss_getBrowserState() {
|
||||||
|
@ -340,7 +340,7 @@ let SessionStoreInternal = {
|
||||||
_deferredInitialState: null,
|
_deferredInitialState: null,
|
||||||
|
|
||||||
// A promise resolved once initialization is complete
|
// A promise resolved once initialization is complete
|
||||||
_promiseInitialization: Promise.defer(),
|
_deferredInitialized: Promise.defer(),
|
||||||
|
|
||||||
// Whether session has been initialized
|
// Whether session has been initialized
|
||||||
_sessionInitialized: false,
|
_sessionInitialized: false,
|
||||||
|
@ -363,7 +363,7 @@ let SessionStoreInternal = {
|
||||||
* A promise fulfilled once initialization is complete.
|
* A promise fulfilled once initialization is complete.
|
||||||
*/
|
*/
|
||||||
get promiseInitialized() {
|
get promiseInitialized() {
|
||||||
return this._promiseInitialization;
|
return this._deferredInitialized.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
/* ........ Public Getters .............. */
|
/* ........ Public Getters .............. */
|
||||||
|
@ -378,31 +378,44 @@ let SessionStoreInternal = {
|
||||||
this._lastSessionState = null;
|
this._lastSessionState = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
/* ........ Global Event Handlers .............. */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the component
|
* Initialize the sessionstore service.
|
||||||
*/
|
*/
|
||||||
initService: function ssi_initService() {
|
init: function (aWindow) {
|
||||||
if (this._sessionInitialized) {
|
if (this._initialized) {
|
||||||
return;
|
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");
|
TelemetryTimestamps.add("sessionRestoreInitialized");
|
||||||
OBSERVING.forEach(function(aTopic) {
|
OBSERVING.forEach(function(aTopic) {
|
||||||
Services.obs.addObserver(this, aTopic, true);
|
Services.obs.addObserver(this, aTopic, true);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this._initPrefs();
|
this._initPrefs();
|
||||||
|
this._initialized = true;
|
||||||
this._disabledForMultiProcess = this._prefBranch.getBoolPref("tabs.remote");
|
this._disabledForMultiProcess = this._prefBranch.getBoolPref("tabs.remote");
|
||||||
|
|
||||||
// this pref is only read at startup, so no need to observe it
|
// this pref is only read at startup, so no need to observe it
|
||||||
this._sessionhistory_max_entries =
|
this._sessionhistory_max_entries =
|
||||||
this._prefBranch.getIntPref("sessionhistory.max_entries");
|
this._prefBranch.getIntPref("sessionhistory.max_entries");
|
||||||
|
|
||||||
gSessionStartup.onceInitialized.then(
|
// Wait until nsISessionStartup has finished reading the session data.
|
||||||
this.initSession.bind(this)
|
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() {
|
initSession: function ssi_initSession() {
|
||||||
|
@ -492,7 +505,6 @@ let SessionStoreInternal = {
|
||||||
this._performUpgradeBackup();
|
this._performUpgradeBackup();
|
||||||
|
|
||||||
this._sessionInitialized = true;
|
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:
|
* Called on application shutdown, after notifications:
|
||||||
* quit-application-granted, quit-application
|
* quit-application-granted, quit-application
|
||||||
*/
|
*/
|
||||||
_uninit: function ssi_uninit() {
|
_uninit: function ssi_uninit() {
|
||||||
|
if (!this._initialized) {
|
||||||
|
throw new Error("SessionStore is not initialized.");
|
||||||
|
}
|
||||||
|
|
||||||
// save all data for session resuming
|
// save all data for session resuming
|
||||||
if (this._sessionInitialized)
|
if (this._sessionInitialized) {
|
||||||
this.saveState(true);
|
this.saveState(true);
|
||||||
|
}
|
||||||
|
|
||||||
// clear out priority queue in case it's still holding refs
|
// clear out priority queue in case it's still holding refs
|
||||||
TabRestoreQueue.reset();
|
TabRestoreQueue.reset();
|
||||||
|
|
|
@ -382,13 +382,11 @@ let TestRunner = {
|
||||||
run: function () {
|
run: function () {
|
||||||
waitForExplicitFinish();
|
waitForExplicitFinish();
|
||||||
|
|
||||||
SessionStore.promiseInitialized.then(function () {
|
SessionStore.promiseInitialized.then(() => {
|
||||||
executeSoon(function () {
|
|
||||||
this.backupState = JSON.parse(ss.getBrowserState());
|
this.backupState = JSON.parse(ss.getBrowserState());
|
||||||
this._iter = runTests();
|
this._iter = runTests();
|
||||||
this.next();
|
this.next();
|
||||||
}.bind(this));
|
});
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче