Bug 881049 - Switch SessionStore to Promise.jsm; r=ttaubert

X-Git-Commit-ID: 39b42be125f8b40a52350ed7cf9c39082356118f
This commit is contained in:
Steven MacLeod 2013-07-25 21:50:15 +02:00
parent 5088103657
commit 8b8e6fd89d
6 changed files with 30 additions and 19 deletions

View File

@ -1040,7 +1040,6 @@ var gBrowserInit = {
OfflineApps.init();
IndexedDBPromptHelper.init();
gFormSubmitObserver.init();
SocialUI.init();
AddonManager.addAddonListener(AddonsMgrListener);
WebrtcIndicator.init();
@ -1101,12 +1100,7 @@ var gBrowserInit = {
// initialize the session-restore service (in case it's not already running)
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
ss.init(window);
// Enable the Restore Last Session command if needed
if (ss.canRestoreLastSession &&
!PrivateBrowsingUtils.isWindowPrivate(window))
goSetCommandEnabled("Browser:RestoreLastSession", true);
let ssPromise = ss.init(window);
PlacesToolbarHelper.init();
@ -1169,7 +1163,6 @@ var gBrowserInit = {
#endif
gBrowserThumbnails.init();
TabView.init();
setUrlAndSearchBarWidthForConditionalForwardButton();
window.addEventListener("resize", function resizeHandler(event) {
@ -1284,8 +1277,19 @@ var gBrowserInit = {
#endif
#endif
ssPromise.then(() =>{
// Enable the Restore Last Session command if needed
if (ss.canRestoreLastSession &&
!PrivateBrowsingUtils.isWindowPrivate(window))
goSetCommandEnabled("Browser:RestoreLastSession", true);
TabView.init();
SocialUI.init();
setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0);
});
Services.obs.notifyObservers(window, "browser-delayed-startup-finished", "");
setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0);
TelemetryTimestamps.add("delayedStartupFinished");
},

View File

@ -17,6 +17,7 @@ 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...
@ -26,8 +27,12 @@ function openWindowAndWaitForInit(callback) {
Services.obs.addObserver(function providerSet(subject, topic, data) {
Services.obs.removeObserver(providerSet, topic);
info(topic + " observer was notified - continuing test");
// executeSoon to let the browser UI observers run first
executeSoon(function() {callback(w)});
// 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);});
});
}, topic, false);
}

View File

@ -25,13 +25,13 @@ interface nsIDOMNode;
* |gBrowser.tabContainer| such as e.g. |gBrowser.selectedTab|.
*/
[scriptable, uuid(0aa5492c-15ad-4376-8eac-28895796826e)]
[scriptable, uuid(092fa0cc-e99b-11e2-a2a3-a25b4f45d8e2)]
interface nsISessionStore : nsISupports
{
/**
* Initialize the service
*/
void init(in nsIDOMWindow aWindow);
jsval init(in nsIDOMWindow aWindow);
/**
* Is it possible to restore the previous session. Will always be false when

View File

@ -79,7 +79,7 @@ Cu.import("resource://gre/modules/TelemetryTimestamps.jsm", this);
Cu.import("resource://gre/modules/TelemetryStopwatch.jsm", this);
Cu.import("resource://gre/modules/osfile.jsm", this);
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm", this);
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", this);
Cu.import("resource://gre/modules/Promise.jsm", this);
Cu.import("resource://gre/modules/Task.jsm", this);
XPCOMUtils.defineLazyServiceGetter(this, "gSessionStartup",
@ -139,7 +139,7 @@ this.SessionStore = {
},
init: function ss_init(aWindow) {
SessionStoreInternal.init(aWindow);
return SessionStoreInternal.init(aWindow);
},
getBrowserState: function ss_getBrowserState() {
@ -579,9 +579,11 @@ let SessionStoreInternal = {
let self = this;
this.initService();
this._promiseInitialization.promise.then(
return this._promiseInitialization.promise.then(
function onSuccess() {
self.onLoad(aWindow);
if (!aWindow.closed) {
self.onLoad(aWindow);
}
}
);
},

View File

@ -33,7 +33,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/osfile/_PromiseWorker.jsm", this);
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
"resource://gre/modules/TelemetryStopwatch.jsm");

View File

@ -39,7 +39,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/TelemetryStopwatch.jsm");
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "_SessionFile",
"resource:///modules/sessionstore/_SessionFile.jsm");