зеркало из https://github.com/mozilla/pjs.git
Backed out changeset 899023a9fbb0 due to Ts regression (was bug 517109)
This commit is contained in:
Родитель
c76fd24f65
Коммит
8c9233da26
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil; -*- */
|
||||
/* -*- Mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil; -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -45,54 +45,22 @@ const Timer = Components.Constructor("@mozilla.org/timer;1", "nsITimer", "initWi
|
|||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const RESTART_ENV_VAR = "FASTSTART_INITIATED_RESTART";
|
||||
|
||||
function setenv(key, value) {
|
||||
let env = Cc["@mozilla.org/process/environment;1"].
|
||||
getService(Components.interfaces.nsIEnvironment);
|
||||
env.set(key, value);
|
||||
}
|
||||
|
||||
function getenv(key) {
|
||||
let env = Cc["@mozilla.org/process/environment;1"].
|
||||
getService(Components.interfaces.nsIEnvironment);
|
||||
return env.get(key);
|
||||
}
|
||||
|
||||
function nsFastStartupObserver() {
|
||||
let _browserWindowCount = 0;
|
||||
let _memCleanupTimer;
|
||||
let _restartTimer;
|
||||
let _isShuttingDown;
|
||||
let _memCleanupTimer = 0;
|
||||
|
||||
function stopMemoryCleanup() {
|
||||
if (_memCleanupTimer) {
|
||||
_memCleanupTimer.cancel();
|
||||
_memCleanupTimer = null;
|
||||
}
|
||||
|
||||
if (_restartTimer) {
|
||||
_restartTimer.cancel();
|
||||
_restartTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleMemoryCleanup() {
|
||||
if (_isShuttingDown)
|
||||
return;
|
||||
|
||||
stopMemoryCleanup();
|
||||
|
||||
function restart() {
|
||||
setenv(RESTART_ENV_VAR, "1");
|
||||
let appstartup = Cc["@mozilla.org/toolkit/app-startup;1"].
|
||||
getService(Ci.nsIAppStartup);
|
||||
appstartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
|
||||
|
||||
_restartTimer = null;
|
||||
}
|
||||
|
||||
function memoryCleanup() {
|
||||
/* XXX Disabling due to crashiness
|
||||
var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
|
||||
// Do this 3 times, because of a comment in TestGtkEmbed that says this
|
||||
|
@ -100,16 +68,14 @@ function nsFastStartupObserver() {
|
|||
os.notifyObservers(null, "memory-pressure", "heap-minimize");
|
||||
os.notifyObservers(null, "memory-pressure", "heap-minimize");
|
||||
os.notifyObservers(null, "memory-pressure", "heap-minimize");
|
||||
|
||||
_memCleanupTimer = null;
|
||||
*/
|
||||
// XXX start our long (15 min?) stub restart timer here
|
||||
_memCleanupTimer = null;
|
||||
}
|
||||
|
||||
// wait 30s until firing off the memory cleanup, in case the user
|
||||
// opens another window right away
|
||||
_memCleanupTimer = new Timer(memoryCleanup, 30000, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
|
||||
// Also, begin a countdown to restart the stub in 15 minutes
|
||||
_restartTimer = new Timer(restart, 60000 * 15, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -130,8 +96,6 @@ function nsFastStartupObserver() {
|
|||
if (_browserWindowCount == 0)
|
||||
scheduleMemoryCleanup();
|
||||
} else if (topic == "quit-application-granted") {
|
||||
stopMemoryCleanup();
|
||||
_isShuttingDown = true;
|
||||
let appstartup = Cc["@mozilla.org/toolkit/app-startup;1"].
|
||||
getService(Ci.nsIAppStartup);
|
||||
appstartup.exitLastWindowClosingSurvivalArea();
|
||||
|
@ -154,7 +118,7 @@ nsFastStartupCLH.prototype = {
|
|||
//
|
||||
handle: function fs_handle(cmdLine) {
|
||||
// the rest of this only handles -faststart here
|
||||
if (cmdLine.handleFlag("faststart-hidden", false) || (getenv(RESTART_ENV_VAR) == "1"))
|
||||
if (cmdLine.handleFlag("faststart-hidden", false))
|
||||
cmdLine.preventDefault = true;
|
||||
|
||||
try {
|
||||
|
@ -165,19 +129,17 @@ nsFastStartupCLH.prototype = {
|
|||
|
||||
this.inited = true;
|
||||
|
||||
// Clear this environment variable for subsequent runs
|
||||
setenv(RESTART_ENV_VAR, "0");
|
||||
|
||||
let fsobs = new nsFastStartupObserver();
|
||||
let wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
wwatch.registerNotification(fsobs);
|
||||
|
||||
let appstartup = Cc["@mozilla.org/toolkit/app-startup;1"].
|
||||
getService(Ci.nsIAppStartup);
|
||||
|
||||
let obsService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
obsService.addObserver(fsobs, "quit-application-granted", true);
|
||||
|
||||
let appstartup = Cc["@mozilla.org/toolkit/app-startup;1"].
|
||||
getService(Ci.nsIAppStartup);
|
||||
appstartup.enterLastWindowClosingSurvivalArea();
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
|
|
Загрузка…
Ссылка в новой задаче