mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-19 21:57:30 +09:00
Issue #1300 - Clear the message manager script cache when updating and removing add-ons
This commit is contained in:
parent
b8f4a7fd8b
commit
c12890f12c
1 changed files with 13 additions and 9 deletions
|
|
@ -220,6 +220,7 @@ const COMPATIBLE_BY_DEFAULT_TYPES = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const MSG_JAR_FLUSH = "AddonJarFlush";
|
const MSG_JAR_FLUSH = "AddonJarFlush";
|
||||||
|
const MSG_MESSAGE_MANAGER_CACHES_FLUSH = "AddonMessageManagerCachesFlush";
|
||||||
|
|
||||||
var gGlobalScope = this;
|
var gGlobalScope = this;
|
||||||
|
|
||||||
|
|
@ -1199,13 +1200,16 @@ function buildJarURI(aJarfile, aPath) {
|
||||||
*/
|
*/
|
||||||
function flushJarCache(aJarFile) {
|
function flushJarCache(aJarFile) {
|
||||||
Services.obs.notifyObservers(aJarFile, "flush-cache-entry", null);
|
Services.obs.notifyObservers(aJarFile, "flush-cache-entry", null);
|
||||||
Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageBroadcaster)
|
Services.mm.broadcastAsyncMessage(MSG_JAR_FLUSH, aJarFile.path);
|
||||||
.broadcastAsyncMessage(MSG_JAR_FLUSH, aJarFile.path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushStartupCache() {
|
function flushChromeCaches() {
|
||||||
// Init this, so it will get the notification.
|
// Init this, so it will get the notification.
|
||||||
Services.obs.notifyObservers(null, "startupcache-invalidate", null);
|
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) {
|
if (flushCaches) {
|
||||||
flushStartupCache();
|
Services.obs.notifyObservers(null, "startupcache-invalidate", null);
|
||||||
// UI displayed early in startup (like the compatibility UI) may have
|
// 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
|
// 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
|
// be flushed to allow extension provided skins and locales to take full
|
||||||
|
|
@ -2665,7 +2669,7 @@ this.XPIProvider = {
|
||||||
existingAddon, "uninstall", uninstallReason,
|
existingAddon, "uninstall", uninstallReason,
|
||||||
{ newVersion: newVersion });
|
{ newVersion: newVersion });
|
||||||
this.unloadBootstrapScope(existingAddonID);
|
this.unloadBootstrapScope(existingAddonID);
|
||||||
flushStartupCache();
|
flushChromeCaches();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
@ -2939,7 +2943,7 @@ this.XPIProvider = {
|
||||||
// If the new add-on is bootstrapped and active then call its install method
|
// If the new add-on is bootstrapped and active then call its install method
|
||||||
if (newDBAddon.active && newDBAddon.bootstrap) {
|
if (newDBAddon.active && newDBAddon.bootstrap) {
|
||||||
// Startup cache must be flushed before calling the bootstrap script
|
// Startup cache must be flushed before calling the bootstrap script
|
||||||
flushStartupCache();
|
flushChromeCaches();
|
||||||
|
|
||||||
let installReason = Services.vc.compare(aOldAddon.version, newDBAddon.version) < 0 ?
|
let installReason = Services.vc.compare(aOldAddon.version, newDBAddon.version) < 0 ?
|
||||||
BOOTSTRAP_REASONS.ADDON_UPGRADE :
|
BOOTSTRAP_REASONS.ADDON_UPGRADE :
|
||||||
|
|
@ -3344,7 +3348,7 @@ this.XPIProvider = {
|
||||||
// If the new add-on is bootstrapped then we must flush the caches
|
// If the new add-on is bootstrapped then we must flush the caches
|
||||||
// before calling the new bootstrap script
|
// before calling the new bootstrap script
|
||||||
if (newDBAddon.bootstrap)
|
if (newDBAddon.bootstrap)
|
||||||
flushStartupCache();
|
flushChromeCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newDBAddon.bootstrap)
|
if (!newDBAddon.bootstrap)
|
||||||
|
|
@ -4746,7 +4750,7 @@ this.XPIProvider = {
|
||||||
this.callBootstrapMethod(aAddon, file, "uninstall",
|
this.callBootstrapMethod(aAddon, file, "uninstall",
|
||||||
BOOTSTRAP_REASONS.ADDON_UNINSTALL);
|
BOOTSTRAP_REASONS.ADDON_UNINSTALL);
|
||||||
this.unloadBootstrapScope(aAddon.id);
|
this.unloadBootstrapScope(aAddon.id);
|
||||||
flushStartupCache();
|
flushChromeCaches();
|
||||||
}
|
}
|
||||||
aAddon._installLocation.uninstallAddon(aAddon.id);
|
aAddon._installLocation.uninstallAddon(aAddon.id);
|
||||||
XPIDatabase.removeAddonMetadata(aAddon);
|
XPIDatabase.removeAddonMetadata(aAddon);
|
||||||
|
|
@ -5876,7 +5880,7 @@ AddonInstall.prototype = {
|
||||||
"uninstall", reason,
|
"uninstall", reason,
|
||||||
{ newVersion: this.addon.version });
|
{ newVersion: this.addon.version });
|
||||||
XPIProvider.unloadBootstrapScope(this.existingAddon.id);
|
XPIProvider.unloadBootstrapScope(this.existingAddon.id);
|
||||||
flushStartupCache();
|
flushChromeCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUpgrade && this.existingAddon.active) {
|
if (!isUpgrade && this.existingAddon.active) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue