зеркало из https://github.com/mozilla/gecko-dev.git
Bug 701092 - Limit session restore attempts. r=mfinkle
This commit is contained in:
Родитель
9eed9ad660
Коммит
852d8048cb
|
@ -150,6 +150,8 @@ pref("browser.sessionstore.resume_from_crash", true);
|
|||
pref("browser.sessionstore.resume_from_crash_timeout", 60); // minutes
|
||||
pref("browser.sessionstore.interval", 10000); // milliseconds
|
||||
pref("browser.sessionstore.max_tabs_undo", 1);
|
||||
pref("browser.sessionstore.max_resumed_crashes", 1);
|
||||
pref("browser.sessionstore.recent_crashes", 0);
|
||||
|
||||
/* these should help performance */
|
||||
pref("mozilla.widget.force-24bpp", true);
|
||||
|
|
|
@ -269,12 +269,12 @@ var BrowserApp = {
|
|||
Cc["@mozilla.org/satchel/form-history;1"].getService(Ci.nsIFormHistory2);
|
||||
|
||||
let url = "about:home";
|
||||
let restoreSession = false;
|
||||
let forceRestore = false;
|
||||
if ("arguments" in window) {
|
||||
if (window.arguments[0])
|
||||
url = window.arguments[0];
|
||||
if (window.arguments[1])
|
||||
restoreSession = window.arguments[1];
|
||||
forceRestore = window.arguments[1];
|
||||
if (window.arguments[2])
|
||||
gScreenWidth = window.arguments[2];
|
||||
if (window.arguments[3])
|
||||
|
@ -291,7 +291,7 @@ var BrowserApp = {
|
|||
|
||||
// restore the previous session
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||
if (restoreSession || ss.shouldRestore()) {
|
||||
if (forceRestore || ss.shouldRestore()) {
|
||||
// A restored tab should not be active if we are loading a URL
|
||||
let restoreToFront = false;
|
||||
|
||||
|
@ -301,20 +301,22 @@ var BrowserApp = {
|
|||
} else {
|
||||
// Let the session make a restored tab active
|
||||
restoreToFront = true;
|
||||
|
||||
// Be ready to handle any restore failures by making sure we have a valid tab opened
|
||||
let restoreCleanup = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(restoreCleanup, "sessionstore-windows-restored");
|
||||
if (aData == "fail")
|
||||
BrowserApp.addTab("about:home");
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(restoreCleanup, "sessionstore-windows-restored", false);
|
||||
}
|
||||
|
||||
// Be ready to handle any restore failures by making sure we have a valid tab opened
|
||||
let restoreCleanup = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(restoreCleanup, "sessionstore-windows-restored");
|
||||
if (aData == "fail") {
|
||||
let params = { selected: restoreToFront };
|
||||
BrowserApp.addTab("about:home");
|
||||
}
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(restoreCleanup, "sessionstore-windows-restored", false);
|
||||
|
||||
// Start the restore
|
||||
ss.restoreLastSession(restoreToFront);
|
||||
ss.restoreLastSession(restoreToFront, forceRestore);
|
||||
} else {
|
||||
this.addTab(url);
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ interface nsISessionStore : nsISupports
|
|||
/**
|
||||
* Restores the previous browser session using a fast, lightweight strategy
|
||||
* @param aBringToFront should a restored tab be brought to the foreground?
|
||||
* @param aForceRestore whether we need to force a restore, regardless of the recent crash situation
|
||||
*/
|
||||
void restoreLastSession(in boolean aBringToFront);
|
||||
void restoreLastSession(in boolean aBringToFront, in boolean aForceRestore);
|
||||
};
|
||||
|
|
|
@ -914,16 +914,28 @@ SessionStore.prototype = {
|
|||
return this._shouldRestore;
|
||||
},
|
||||
|
||||
restoreLastSession: function ss_restoreLastSession(aBringToFront) {
|
||||
restoreLastSession: function ss_restoreLastSession(aBringToFront, aForceRestore) {
|
||||
let self = this;
|
||||
function notifyObservers(aMessage) {
|
||||
self._clearCache();
|
||||
Services.obs.notifyObservers(null, "sessionstore-windows-restored", aMessage || "");
|
||||
}
|
||||
|
||||
if (!aForceRestore) {
|
||||
let maxCrashes = Services.prefs.getIntPref("browser.sessionstore.max_resumed_crashes");
|
||||
let recentCrashes = Services.prefs.getIntPref("browser.sessionstore.recent_crashes") + 1;
|
||||
Services.prefs.setIntPref("browser.sessionstore.recent_crashes", recentCrashes);
|
||||
Services.prefs.savePrefFile(null);
|
||||
|
||||
if (recentCrashes > maxCrashes) {
|
||||
notifyObservers("fail");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The previous session data has already been renamed to the backup file
|
||||
if (!this._sessionFileBackup.exists()) {
|
||||
notifyObservers("fail")
|
||||
notifyObservers("fail");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -386,6 +386,12 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
|||
// of flushing data
|
||||
nsIPrefService* prefs = Preferences::GetService();
|
||||
if (prefs) {
|
||||
// reset the crash loop state
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
prefs->GetBranch("browser.sessionstore.", getter_AddRefs(prefBranch));
|
||||
if (prefBranch)
|
||||
prefBranch->SetIntPref("recent_crashes", 0);
|
||||
|
||||
prefs->SavePrefFile(nsnull);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче