1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-07 03:15:46 +01:00

Get rid of old rehash code and add timeout before nuking sandboxes. Closes issue #1130.

This commit is contained in:
Kris Maglione
2014-03-14 23:22:39 -07:00
parent cb11523659
commit 7f91a7eb7f
2 changed files with 15 additions and 33 deletions

26
common/bootstrap.js vendored
View File

@@ -21,6 +21,8 @@ var { AddonManager } = module("resource://gre/modules/AddonManager.jsm");
var { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.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")
.QueryInterface(Ci.nsIResProtocolHandler);
const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
@@ -179,10 +181,8 @@ let JSMLoader = {
get loadSubScript() bootstrap_jsm.loadSubScript,
cleanup: function cleanup() {
for (let factory of this.factories.splice(0)) {
debug("bootstrap: unregister factory: " + factory.classID);
for (let factory of this.factories.splice(0))
manager.unregisterFactory(factory.classID, factory);
}
},
Factory: function Factory(class_) ({
@@ -204,7 +204,6 @@ let JSMLoader = {
}),
registerFactory: function registerFactory(factory) {
debug("bootstrap: register factory: " + factory.classID + " " + factory.contractID);
manager.registerFactory(factory.classID,
String(factory.classID),
factory.contractID,
@@ -394,6 +393,7 @@ FactoryProxy.prototype = {
}
}
var timer;
function shutdown(data, reason) {
let strReason = reasonToString(reason);
debug("bootstrap: shutdown " + strReason);
@@ -408,18 +408,20 @@ function shutdown(data, reason) {
JSMLoader.atexit(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)
categoryManager.deleteCategoryEntry(category, entry, false);
for (let resource in JSMLoader.config.resources)
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);
}
}

View File

@@ -1173,26 +1173,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
util.dump("cleanup: " + module.constructor.className);
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.flushCache();
cache.flush(bind("test", /^literal:/));
this.rehashing = true;
let addon = config.addon;
addon.userDisabled = true;
addon.userDisabled = false;