mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-04-01 03:43:34 +02:00
Get rid of old rehash code and add timeout before nuking sandboxes. Closes issue #1130.
This commit is contained in:
26
common/bootstrap.js
vendored
26
common/bootstrap.js
vendored
@@ -21,6 +21,8 @@ var { AddonManager } = module("resource://gre/modules/AddonManager.jsm");
|
|||||||
var { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.jsm");
|
var { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
var { Services } = module("resource://gre/modules/Services.jsm");
|
var { Services } = module("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
var Timer = Components.Constructor("@mozilla.org/timer;1", "nsITimer", "initWithCallback");
|
||||||
|
|
||||||
const resourceProto = Services.io.getProtocolHandler("resource")
|
const resourceProto = Services.io.getProtocolHandler("resource")
|
||||||
.QueryInterface(Ci.nsIResProtocolHandler);
|
.QueryInterface(Ci.nsIResProtocolHandler);
|
||||||
const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
||||||
@@ -179,10 +181,8 @@ let JSMLoader = {
|
|||||||
get loadSubScript() bootstrap_jsm.loadSubScript,
|
get loadSubScript() bootstrap_jsm.loadSubScript,
|
||||||
|
|
||||||
cleanup: function cleanup() {
|
cleanup: function cleanup() {
|
||||||
for (let factory of this.factories.splice(0)) {
|
for (let factory of this.factories.splice(0))
|
||||||
debug("bootstrap: unregister factory: " + factory.classID);
|
|
||||||
manager.unregisterFactory(factory.classID, factory);
|
manager.unregisterFactory(factory.classID, factory);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Factory: function Factory(class_) ({
|
Factory: function Factory(class_) ({
|
||||||
@@ -204,7 +204,6 @@ let JSMLoader = {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
registerFactory: function registerFactory(factory) {
|
registerFactory: function registerFactory(factory) {
|
||||||
debug("bootstrap: register factory: " + factory.classID + " " + factory.contractID);
|
|
||||||
manager.registerFactory(factory.classID,
|
manager.registerFactory(factory.classID,
|
||||||
String(factory.classID),
|
String(factory.classID),
|
||||||
factory.contractID,
|
factory.contractID,
|
||||||
@@ -394,6 +393,7 @@ FactoryProxy.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var timer;
|
||||||
function shutdown(data, reason) {
|
function shutdown(data, reason) {
|
||||||
let strReason = reasonToString(reason);
|
let strReason = reasonToString(reason);
|
||||||
debug("bootstrap: shutdown " + strReason);
|
debug("bootstrap: shutdown " + strReason);
|
||||||
@@ -408,18 +408,20 @@ function shutdown(data, reason) {
|
|||||||
JSMLoader.atexit(strReason);
|
JSMLoader.atexit(strReason);
|
||||||
JSMLoader.cleanup(strReason);
|
JSMLoader.cleanup(strReason);
|
||||||
|
|
||||||
bootstrap_jsm.require = null;
|
|
||||||
if (JSMLoader.SANDBOX)
|
|
||||||
Cu.nukeSandbox(bootstrap);
|
|
||||||
else
|
|
||||||
Cu.unload(BOOTSTRAP);
|
|
||||||
bootstrap = null;
|
|
||||||
bootstrap_jsm = null;
|
|
||||||
|
|
||||||
for each (let [category, entry] in JSMLoader.config.categories)
|
for each (let [category, entry] in JSMLoader.config.categories)
|
||||||
categoryManager.deleteCategoryEntry(category, entry, false);
|
categoryManager.deleteCategoryEntry(category, entry, false);
|
||||||
for (let resource in JSMLoader.config.resources)
|
for (let resource in JSMLoader.config.resources)
|
||||||
resourceProto.setSubstitution(resource, null);
|
resourceProto.setSubstitution(resource, null);
|
||||||
|
|
||||||
|
timer = Timer(() => {
|
||||||
|
bootstrap_jsm.require = null;
|
||||||
|
if (JSMLoader.SANDBOX)
|
||||||
|
Cu.nukeSandbox(bootstrap);
|
||||||
|
else
|
||||||
|
Cu.unload(BOOTSTRAP);
|
||||||
|
bootstrap = null;
|
||||||
|
bootstrap_jsm = null;
|
||||||
|
}, 5000, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1173,26 +1173,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
util.dump("cleanup: " + module.constructor.className);
|
util.dump("cleanup: " + module.constructor.className);
|
||||||
util.trapErrors(module.cleanup, module, reason);
|
util.trapErrors(module.cleanup, module, reason);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!this.rehashing)
|
|
||||||
services.observer.addObserver(this, "dactyl-rehash", true);
|
|
||||||
},
|
|
||||||
"dactyl-rehash": function dactylRehash() {
|
|
||||||
services.observer.removeObserver(this, "dactyl-rehash");
|
|
||||||
|
|
||||||
defineModule.loadLog.push("dactyl: util: observe: dactyl-rehash");
|
|
||||||
if (!this.rehashing)
|
|
||||||
for (let module in values(defineModule.modules)) {
|
|
||||||
defineModule.loadLog.push("dactyl: util: init(" + module + ")");
|
|
||||||
if (module.reinit)
|
|
||||||
module.reinit();
|
|
||||||
else
|
|
||||||
module.init();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dactyl-purge": function dactylPurge() {
|
|
||||||
this.rehashing = 1;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1371,7 +1352,6 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
this.timeout(function () {
|
this.timeout(function () {
|
||||||
this.flushCache();
|
this.flushCache();
|
||||||
cache.flush(bind("test", /^literal:/));
|
cache.flush(bind("test", /^literal:/));
|
||||||
this.rehashing = true;
|
|
||||||
let addon = config.addon;
|
let addon = config.addon;
|
||||||
addon.userDisabled = true;
|
addon.userDisabled = true;
|
||||||
addon.userDisabled = false;
|
addon.userDisabled = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user