Bug 1708193 - Remove mozapps/extensions/internal/Content.js r=rpl

Use Extension:FlushJarCache listener in ExtensionProcessScript.jsm instead,
it's already loaded everywhere and early enough from AddonManager.jsm.

Differential Revision: https://phabricator.services.mozilla.com/D129952
This commit is contained in:
Tomislav Jovanovic 2021-11-20 13:10:58 +00:00
parent d880340507
commit 3f442e7f66
6 changed files with 5 additions and 44 deletions

View File

@ -51,9 +51,6 @@ const known_scripts = {
frameScripts: new Set([
// Test related
"chrome://mochikit/content/shutdown-leaks-collector.js",
// Extensions
"resource://gre/modules/addons/Content.js",
]),
processScripts: new Set([
"chrome://global/content/process-content.js",

View File

@ -362,16 +362,13 @@ class nsScriptCacheCleaner final : public nsIObserver {
nsCOMPtr<nsIObserverService> obsSvc =
mozilla::services::GetObserverService();
if (obsSvc) {
obsSvc->AddObserver(this, "message-manager-flush-caches", false);
obsSvc->AddObserver(this, "xpcom-shutdown", false);
}
}
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) override {
if (strcmp("message-manager-flush-caches", aTopic) == 0) {
nsMessageManagerScriptExecutor::PurgeCache();
} else if (strcmp("xpcom-shutdown", aTopic) == 0) {
if (strcmp("xpcom-shutdown", aTopic) == 0) {
nsMessageManagerScriptExecutor::Shutdown();
}
return NS_OK;

View File

@ -45,8 +45,6 @@ const MSG_INSTALL_CLEANUP = "WebAPICleanup";
const MSG_ADDON_EVENT_REQ = "WebAPIAddonEventRequest";
const MSG_ADDON_EVENT = "WebAPIAddonEvent";
const CHILD_SCRIPT = "resource://gre/modules/addons/Content.js";
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var gSingleton = null;
@ -57,7 +55,6 @@ function amManager() {
"resource://gre/modules/AddonManager.jsm"
));
Services.mm.loadFrameScript(CHILD_SCRIPT, true, true);
Services.mm.addMessageListener(MSG_INSTALL_ENABLED, this);
Services.mm.addMessageListener(MSG_PROMISE_REQUEST, this);
Services.mm.addMessageListener(MSG_INSTALL_CLEANUP, this);

View File

@ -1,31 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals addMessageListener*/
"use strict";
(function() {
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const MSG_JAR_FLUSH = "AddonJarFlush";
const MSG_MESSAGE_MANAGER_CACHES_FLUSH = "AddonMessageManagerCachesFlush";
try {
if (
Services.appinfo.processType !== Services.appinfo.PROCESS_TYPE_DEFAULT
) {
// Propagate JAR cache flush notifications across process boundaries.
addMessageListener(MSG_JAR_FLUSH, function(message) {
Services.obs.notifyObservers(null, "flush-cache-entry", message.data);
});
// Propagate message manager caches flush notifications across processes.
addMessageListener(MSG_MESSAGE_MANAGER_CACHES_FLUSH, function() {
Services.obs.notifyObservers(null, "message-manager-flush-caches");
});
}
} catch (e) {
Cu.reportError(e);
}
})();

View File

@ -172,7 +172,9 @@ function getFile(path, base = null) {
*/
function flushJarCache(aJarFile) {
Services.obs.notifyObservers(aJarFile, "flush-cache-entry");
Services.mm.broadcastAsyncMessage(MSG_JAR_FLUSH, aJarFile.path);
Services.ppmm.broadcastAsyncMessage(MSG_JAR_FLUSH, {
path: aJarFile.path,
});
}
const PREF_EM_UPDATE_BACKGROUND_URL = "extensions.update.background.url";
@ -189,7 +191,7 @@ const TEMP_INSTALL_ID_GEN_SESSION = new Uint8Array(
Float64Array.of(Math.random()).buffer
);
const MSG_JAR_FLUSH = "AddonJarFlush";
const MSG_JAR_FLUSH = "Extension:FlushJarCache";
/**
* Valid IDs fit this pattern.

View File

@ -8,7 +8,6 @@ EXTRA_JS_MODULES.addons += [
"AddonRepository.jsm",
"AddonSettings.jsm",
"AddonUpdateChecker.jsm",
"Content.js",
"ProductAddonChecker.jsm",
"XPIDatabase.jsm",
"XPIInstall.jsm",