mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1816934 - Convert most of services/settings to ES modules. r=leplatrem
Convert everything apart from items used in workers. Differential Revision: https://phabricator.services.mozilla.com/D169933
This commit is contained in:
parent
ca64899a91
commit
33aca634e1
@ -2,11 +2,8 @@
|
||||
* 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/. */
|
||||
|
||||
var EXPORTED_SYMBOLS = ["Downloader"];
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
const lazy = {};
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
RemoteSettingsWorker: "resource://services-settings/RemoteSettingsWorker.jsm",
|
||||
@ -92,7 +89,7 @@ class LazyRecordAndBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
class Downloader {
|
||||
export class Downloader {
|
||||
static get DownloadError() {
|
||||
return DownloadError;
|
||||
}
|
@ -2,9 +2,7 @@
|
||||
* 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/. */
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -20,14 +18,12 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
});
|
||||
XPCOMUtils.defineLazyGetter(lazy, "console", () => lazy.Utils.log);
|
||||
|
||||
var EXPORTED_SYMBOLS = ["Database"];
|
||||
|
||||
/**
|
||||
* Database is a tiny wrapper with the objective
|
||||
* of providing major kinto-offline-client collection API.
|
||||
* (with the objective of getting rid of kinto-offline-client)
|
||||
*/
|
||||
class Database {
|
||||
export class Database {
|
||||
static destroy() {
|
||||
return destroyIDB();
|
||||
}
|
@ -2,16 +2,9 @@
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["RemoteSettingsClient"];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
const { AppConstants } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/AppConstants.sys.mjs"
|
||||
);
|
||||
const { Downloader } = ChromeUtils.import(
|
||||
"resource://services-settings/Attachments.jsm"
|
||||
);
|
||||
@ -267,7 +260,7 @@ class AttachmentDownloader extends Downloader {
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteSettingsClient extends EventEmitter {
|
||||
export class RemoteSettingsClient extends EventEmitter {
|
||||
static get APIError() {
|
||||
return APIError;
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
/* 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/. */
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["RemoteSettingsTimer"];
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -13,7 +10,7 @@ ChromeUtils.defineModuleGetter(
|
||||
"resource://services-settings/remote-settings.js"
|
||||
);
|
||||
|
||||
var RemoteSettingsTimer = function() {};
|
||||
export var RemoteSettingsTimer = function() {};
|
||||
RemoteSettingsTimer.prototype = {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsITimerCallback"]),
|
||||
classID: Components.ID("{5e756573-234a-49ea-bbe4-59ec7a70657d}"),
|
@ -2,19 +2,12 @@
|
||||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Interface to a dedicated thread handling for Remote Settings heavy operations.
|
||||
*/
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
const { setTimeout, clearTimeout } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/Timer.sys.mjs"
|
||||
);
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["RemoteSettingsWorker"];
|
||||
import { setTimeout, clearTimeout } from "resource://gre/modules/Timer.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -240,6 +233,6 @@ try {
|
||||
gShutdown = true;
|
||||
}
|
||||
|
||||
var RemoteSettingsWorker = new Worker(
|
||||
export var RemoteSettingsWorker = new Worker(
|
||||
"resource://services-settings/RemoteSettingsWorker.js"
|
||||
);
|
@ -2,9 +2,7 @@
|
||||
* 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/. */
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -12,8 +10,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
KeyValueService: "resource://gre/modules/kvstore.jsm",
|
||||
});
|
||||
|
||||
var EXPORTED_SYMBOLS = ["SyncHistory"];
|
||||
|
||||
/**
|
||||
* A helper to keep track of synchronization statuses.
|
||||
*
|
||||
@ -21,7 +17,7 @@ var EXPORTED_SYMBOLS = ["SyncHistory"];
|
||||
* because the eventual goal is to be able to detect `IndexedDB` issues and act
|
||||
* accordingly.
|
||||
*/
|
||||
class SyncHistory {
|
||||
export class SyncHistory {
|
||||
// Internal reference to underlying rkv store.
|
||||
#store;
|
||||
|
@ -8,7 +8,7 @@ Classes = [
|
||||
{
|
||||
'cid': '{5e756573-234a-49ea-bbe4-59ec7a70657d}',
|
||||
'contract_ids': ['@mozilla.org/services/settings;1'],
|
||||
'jsm': 'resource://services-settings/RemoteSettingsComponents.jsm',
|
||||
'esModule': 'resource://services-settings/RemoteSettingsComponents.sys.mjs',
|
||||
'constructor': 'RemoteSettingsTimer',
|
||||
},
|
||||
]
|
||||
|
@ -15,16 +15,16 @@ EXTRA_COMPONENTS += [
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES["services-settings"] += [
|
||||
"Attachments.jsm",
|
||||
"Database.jsm",
|
||||
"Attachments.sys.mjs",
|
||||
"Database.sys.mjs",
|
||||
"IDBHelpers.jsm",
|
||||
"remote-settings.js",
|
||||
"RemoteSettingsClient.jsm",
|
||||
"RemoteSettingsComponents.jsm",
|
||||
"remote-settings.sys.mjs",
|
||||
"RemoteSettingsClient.sys.mjs",
|
||||
"RemoteSettingsComponents.sys.mjs",
|
||||
"RemoteSettingsWorker.js",
|
||||
"RemoteSettingsWorker.jsm",
|
||||
"RemoteSettingsWorker.sys.mjs",
|
||||
"SharedUtils.jsm",
|
||||
"SyncHistory.jsm",
|
||||
"SyncHistory.sys.mjs",
|
||||
"Utils.jsm",
|
||||
]
|
||||
|
||||
|
@ -2,22 +2,8 @@
|
||||
* 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/. */
|
||||
|
||||
/* global __URI__ */
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = [
|
||||
"RemoteSettings",
|
||||
"jexlFilterFunc",
|
||||
"remoteSettingsBroadcastHandler",
|
||||
];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
const { AppConstants } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/AppConstants.sys.mjs"
|
||||
);
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
@ -84,7 +70,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
||||
* @param {ClientEnvironment} environment Information about version, language, platform etc.
|
||||
* @returns {?Object} the entry or null if excluded.
|
||||
*/
|
||||
async function jexlFilterFunc(entry, environment) {
|
||||
export async function jexlFilterFunc(entry, environment) {
|
||||
const { filter_expression } = entry;
|
||||
if (!filter_expression) {
|
||||
return entry;
|
||||
@ -583,7 +569,10 @@ function remoteSettingsFunction() {
|
||||
'"0"'
|
||||
);
|
||||
const moduleInfo = {
|
||||
moduleURI: __URI__,
|
||||
// TODO: This should be `import.meta.url`, however the push service
|
||||
// does not currently support ES modules, so use the old URI which still
|
||||
// works for ChromeUtils.import. See bug 1817460.
|
||||
moduleURI: "resource://services-settings/remote-settings.js",
|
||||
symbolName: "remoteSettingsBroadcastHandler",
|
||||
};
|
||||
lazy.pushBroadcastService.addListener(
|
||||
@ -596,9 +585,9 @@ function remoteSettingsFunction() {
|
||||
return remoteSettings;
|
||||
}
|
||||
|
||||
var RemoteSettings = remoteSettingsFunction();
|
||||
export var RemoteSettings = remoteSettingsFunction();
|
||||
|
||||
var remoteSettingsBroadcastHandler = {
|
||||
export var remoteSettingsBroadcastHandler = {
|
||||
async receivedBroadcastMessage(version, broadcastID, context) {
|
||||
const { phase } = context;
|
||||
const isStartup = [
|
Loading…
Reference in New Issue
Block a user