diff options
author | Moonchild <moonchild@palemoon.org> | 2019-11-25 14:43:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-25 14:43:21 +0000 |
commit | e8c40b0bc2aa25b9f85ddbe3949c296311cc0f3f (patch) | |
tree | be107ecc56d803de2597442814663f5a51b38902 | |
parent | 1a8fdf3c7faeaeee59df58bdcc108d0ab9354c33 (diff) | |
parent | f703f61eab881eb97a2c835b3803959f53d15d97 (diff) | |
download | UXP-e8c40b0bc2aa25b9f85ddbe3949c296311cc0f3f.tar UXP-e8c40b0bc2aa25b9f85ddbe3949c296311cc0f3f.tar.gz UXP-e8c40b0bc2aa25b9f85ddbe3949c296311cc0f3f.tar.lz UXP-e8c40b0bc2aa25b9f85ddbe3949c296311cc0f3f.tar.xz UXP-e8c40b0bc2aa25b9f85ddbe3949c296311cc0f3f.zip |
Merge pull request #1301 from JustOff/PR_mm_script_cache
Clear the message manager script cache when updating and removing add-ons
-rw-r--r-- | toolkit/mozapps/extensions/internal/XPIProvider.jsm | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index 99a121da4..600ec2ff5 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -220,6 +220,7 @@ const COMPATIBLE_BY_DEFAULT_TYPES = { }; const MSG_JAR_FLUSH = "AddonJarFlush"; +const MSG_MESSAGE_MANAGER_CACHES_FLUSH = "AddonMessageManagerCachesFlush"; var gGlobalScope = this; @@ -1199,13 +1200,16 @@ function buildJarURI(aJarfile, aPath) { */ function flushJarCache(aJarFile) { Services.obs.notifyObservers(aJarFile, "flush-cache-entry", null); - Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageBroadcaster) - .broadcastAsyncMessage(MSG_JAR_FLUSH, aJarFile.path); + Services.mm.broadcastAsyncMessage(MSG_JAR_FLUSH, aJarFile.path); } -function flushStartupCache() { +function flushChromeCaches() { // Init this, so it will get the notification. Services.obs.notifyObservers(null, "startupcache-invalidate", null); + // Flush message manager cached scripts + Services.obs.notifyObservers(null, "message-manager-flush-caches", null); + // Also dispatch this event to child processes + Services.mm.broadcastAsyncMessage(MSG_MESSAGE_MANAGER_CACHES_FLUSH, null); } /** @@ -2129,7 +2133,7 @@ this.XPIProvider = { } if (flushCaches) { - flushStartupCache(); + Services.obs.notifyObservers(null, "startupcache-invalidate", null); // UI displayed early in startup (like the compatibility UI) may have // caused us to cache parts of the skin or locale in memory. These must // be flushed to allow extension provided skins and locales to take full @@ -2665,7 +2669,7 @@ this.XPIProvider = { existingAddon, "uninstall", uninstallReason, { newVersion: newVersion }); this.unloadBootstrapScope(existingAddonID); - flushStartupCache(); + flushChromeCaches(); } } catch (e) { @@ -2939,7 +2943,7 @@ this.XPIProvider = { // If the new add-on is bootstrapped and active then call its install method if (newDBAddon.active && newDBAddon.bootstrap) { // Startup cache must be flushed before calling the bootstrap script - flushStartupCache(); + flushChromeCaches(); let installReason = Services.vc.compare(aOldAddon.version, newDBAddon.version) < 0 ? BOOTSTRAP_REASONS.ADDON_UPGRADE : @@ -3344,7 +3348,7 @@ this.XPIProvider = { // If the new add-on is bootstrapped then we must flush the caches // before calling the new bootstrap script if (newDBAddon.bootstrap) - flushStartupCache(); + flushChromeCaches(); } if (!newDBAddon.bootstrap) @@ -4746,7 +4750,7 @@ this.XPIProvider = { this.callBootstrapMethod(aAddon, file, "uninstall", BOOTSTRAP_REASONS.ADDON_UNINSTALL); this.unloadBootstrapScope(aAddon.id); - flushStartupCache(); + flushChromeCaches(); } aAddon._installLocation.uninstallAddon(aAddon.id); XPIDatabase.removeAddonMetadata(aAddon); @@ -5876,7 +5880,7 @@ AddonInstall.prototype = { "uninstall", reason, { newVersion: this.addon.version }); XPIProvider.unloadBootstrapScope(this.existingAddon.id); - flushStartupCache(); + flushChromeCaches(); } if (!isUpgrade && this.existingAddon.active) { |