Bug 1486182: Part 2b - Update XPCOMUtils.enumerateCategoryEntries callers to use the category manager directly. r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D4279

--HG--
extra : rebase_source : f57e09927871a23ed3c105325369e5c35ffd3d93
This commit is contained in:
Kris Maglione 2018-08-24 17:05:41 -07:00
parent 53f96aa226
commit b821d119a0
8 changed files with 17 additions and 26 deletions

View File

@ -176,11 +176,11 @@ add_test(function test_categoryRegistration()
]);
// Verify the correct entries are registered in the "test-cat" category.
for (let [name, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_NAME)) {
for (let {entry, value} of Services.catMan.enumerateCategory(CATEGORY_NAME)) {
print("Verify that the name/value pair exists in the expected entries.");
ok(EXPECTED_ENTRIES.has(name));
Assert.equal(EXPECTED_ENTRIES.get(name), value);
EXPECTED_ENTRIES.delete(name);
ok(EXPECTED_ENTRIES.has(entry));
Assert.equal(EXPECTED_ENTRIES.get(entry), value);
EXPECTED_ENTRIES.delete(entry);
}
print("Check that all of the expected entries have been deleted.");
Assert.equal(EXPECTED_ENTRIES.size, 0);

View File

@ -263,9 +263,7 @@ SpecialPowersObserverAPI.prototype = {
let observers = [];
for (let {data: entry} of Services.catMan.enumerateCategory(topic)) {
let contractID = Services.catMan.getCategoryEntry(topic, entry);
for (let {value: contractID} of Services.catMan.enumerateCategory(topic)) {
let factoryFunction;
if (contractID.substring(0, serviceMarker.length) == serviceMarker) {
contractID = contractID.substring(serviceMarker.length);

View File

@ -81,7 +81,7 @@ var apiManager = new class extends SchemaAPIManager {
if (!this.initialized) {
this.initialized = true;
this.initGlobal();
for (let [/* name */, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCRIPTS_CONTENT)) {
for (let {value} of Services.catMan.enumerateCategory(CATEGORY_EXTENSION_SCRIPTS_CONTENT)) {
this.loadScript(value);
}
}

View File

@ -103,7 +103,7 @@ var apiManager = new class extends SchemaAPIManager {
if (!this.initialized) {
this.initialized = true;
this.initGlobal();
for (let [/* name */, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCRIPTS_ADDON)) {
for (let {value} of Services.catMan.enumerateCategory(CATEGORY_EXTENSION_SCRIPTS_ADDON)) {
this.loadScript(value);
}
}
@ -120,7 +120,7 @@ var devtoolsAPIManager = new class extends SchemaAPIManager {
if (!this.initialized) {
this.initialized = true;
this.initGlobal();
for (let [/* name */, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCRIPTS_DEVTOOLS)) {
for (let {value} of Services.catMan.enumerateCategory(CATEGORY_EXTENSION_SCRIPTS_DEVTOOLS)) {
this.loadScript(value);
}
}

View File

@ -110,8 +110,8 @@ let apiManager = new class extends SchemaAPIManager {
}
getModuleJSONURLs() {
return Array.from(XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_MODULES),
([name, url]) => url);
return Array.from(Services.catMan.enumerateCategory(CATEGORY_EXTENSION_MODULES),
({value}) => value);
}
// Loads all the ext-*.js scripts currently registered.
@ -125,7 +125,7 @@ let apiManager = new class extends SchemaAPIManager {
() => this.loadModuleJSON(this.getModuleJSONURLs()));
let scriptURLs = [];
for (let [/* name */, value] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCRIPTS)) {
for (let {value} of Services.catMan.enumerateCategory(CATEGORY_EXTENSION_SCRIPTS)) {
scriptURLs.push(value);
}
@ -143,8 +143,8 @@ let apiManager = new class extends SchemaAPIManager {
// extended by other schemas, so needs to be loaded first.
return Schemas.load(BASE_SCHEMA).then(() => {
let promises = [];
for (let [/* name */, url] of XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCHEMAS)) {
promises.push(Schemas.load(url));
for (let {value} of Services.catMan.enumerateCategory(CATEGORY_EXTENSION_SCHEMAS)) {
promises.push(Schemas.load(value));
}
for (let [url, {content}] of this.schemaURLs) {
promises.push(Schemas.load(url, content));

View File

@ -466,8 +466,8 @@ class ProxyScriptAPIManager extends SchemaAPIManager {
lazyInit() {
if (!this.initialized) {
this.initGlobal();
let entries = XPCOMUtils.enumerateCategoryEntries(CATEGORY_EXTENSION_SCRIPTS_CONTENT);
for (let [/* name */, value] of entries) {
let entries = Services.catMan.enumerateCategory(CATEGORY_EXTENSION_SCRIPTS_CONTENT);
for (let {value} of entries) {
this.loadScript(value);
}
this.initialized = true;

View File

@ -151,10 +151,7 @@ TimerManager.prototype = {
}
}
var catMan = Cc["@mozilla.org/categorymanager;1"].
getService(Ci.nsICategoryManager);
for (let {data: entry} of catMan.enumerateCategory(CATEGORY_UPDATE_TIMER)) {
let value = catMan.getCategoryEntry(CATEGORY_UPDATE_TIMER, entry);
for (let {value} of Services.catMan.enumerateCategory(CATEGORY_UPDATE_TIMER)) {
let [cid, method, timerID, prefInterval, defaultInterval, maxInterval] = value.split(",");
defaultInterval = parseInt(defaultInterval);

View File

@ -783,11 +783,7 @@ var AddonManagerInternal = {
}
// Load any providers registered in the category manager
let catman = Cc["@mozilla.org/categorymanager;1"].
getService(Ci.nsICategoryManager);
for (let {data: entry} of catman.enumerateCategory(CATEGORY_PROVIDER_MODULE)) {
let url = catman.getCategoryEntry(CATEGORY_PROVIDER_MODULE, entry);
for (let {entry, value: url} of Services.catMan.enumerateCategory(CATEGORY_PROVIDER_MODULE)) {
try {
ChromeUtils.import(url, {});
logger.debug(`Loaded provider scope for ${url}`);