mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out bug 517109 due to Ts regression.
This commit is contained in:
commit
ec274be2d3
@ -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");
|
||||
|
||||
*/
|
||||
// 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);
|
||||
|
Loading…
Reference in New Issue
Block a user