Bug 1601618 - [remote] Use lazy loading of modules and delayed setting of global properties. r=remote-protocol-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D106602
This commit is contained in:
Henrik Skupin 2021-02-26 15:37:41 +00:00
Родитель c9df4a4d2c
Коммит b7893c030d
40 изменённых файлов: 342 добавлений и 265 удалений

Просмотреть файл

@ -10,15 +10,14 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { truncate } = ChromeUtils.import(
"chrome://remote/content/shared/Format.jsm"
);
const { Log } = ChromeUtils.import("chrome://remote/content/shared/Log.jsm");
const { UnknownMethodError } = ChromeUtils.import(
"chrome://remote/content/cdp/Error.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Log: "chrome://remote/content/shared/Log.jsm",
truncate: "chrome://remote/content/shared/Format.jsm",
UnknownMethodError: "chrome://remote/content/cdp/Error.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", () => Log.get());
XPCOMUtils.defineLazyGetter(this, "log", Log.get);
XPCOMUtils.defineLazyServiceGetter(
this,
"UUIDGen",

Просмотреть файл

@ -11,13 +11,17 @@ var EXPORTED_SYMBOLS = [
"UnsupportedError",
];
const { Log } = ChromeUtils.import("chrome://remote/content/shared/Log.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyGetter(this, "log", Log.get);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
Log: "chrome://remote/content/shared/Log.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", () => Log.get());
class RemoteAgentError extends Error {
constructor(message = "", cause = undefined) {

Просмотреть файл

@ -6,18 +6,19 @@
var EXPORTED_SYMBOLS = ["JSONHandler"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { HTTP_404, HTTP_505 } = ChromeUtils.import(
"chrome://remote/content/server/HTTPD.jsm"
);
const { Log } = ChromeUtils.import("chrome://remote/content/shared/Log.jsm");
const { Protocol } = ChromeUtils.import(
"chrome://remote/content/cdp/Protocol.jsm"
);
const { RemoteAgentError } = ChromeUtils.import(
"chrome://remote/content/cdp/Error.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
HTTP_404: "chrome://remote/content/server/HTTPD.jsm",
HTTP_505: "chrome://remote/content/server/HTTPD.jsm",
Log: "chrome://remote/content/shared/Log.jsm",
Protocol: "chrome://remote/content/cdp/Protocol.jsm",
RemoteAgentError: "chrome://remote/content/cdp/Error.jsm",
});
class JSONHandler {
constructor(agent) {

Просмотреть файл

@ -13,16 +13,14 @@ const { XPCOMUtils } = ChromeUtils.import(
XPCOMUtils.defineLazyModuleGetters(this, {
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
OS: "resource://gre/modules/osfile.jsm",
UnsupportedError: "chrome://remote/content/cdp/Error.jsm",
});
XPCOMUtils.defineLazyServiceGetters(this, {
uuidGen: ["@mozilla.org/uuid-generator;1", "nsIUUIDGenerator"],
});
const { UnsupportedError } = ChromeUtils.import(
"chrome://remote/content/cdp/Error.jsm"
);
class StreamRegistry {
constructor() {
// handle => stream

Просмотреть файл

@ -6,13 +6,15 @@
var EXPORTED_SYMBOLS = ["DomainCache"];
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { UnknownMethodError } = ChromeUtils.import(
"chrome://remote/content/cdp/Error.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
UnknownMethodError: "chrome://remote/content/cdp/Error.jsm",
});
/**
* Lazy domain instance cache.
*

Просмотреть файл

@ -6,10 +6,15 @@
var EXPORTED_SYMBOLS = ["DOM"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class DOM extends ContentProcessDomain {
constructor(session) {
super(session);

Просмотреть файл

@ -6,10 +6,15 @@
var EXPORTED_SYMBOLS = ["Emulation"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Emulation extends ContentProcessDomain {
// commands

Просмотреть файл

@ -6,10 +6,15 @@
var EXPORTED_SYMBOLS = ["Input"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Input extends ContentProcessDomain {
constructor(session) {
super(session);

Просмотреть файл

@ -6,10 +6,16 @@
var EXPORTED_SYMBOLS = ["Log"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
const CONSOLE_MESSAGE_LEVEL_MAP = {
[Ci.nsIConsoleMessage.debug]: "verbose",

Просмотреть файл

@ -6,10 +6,15 @@
var EXPORTED_SYMBOLS = ["Network"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Network extends ContentProcessDomain {
// commands

Просмотреть файл

@ -6,10 +6,15 @@
var EXPORTED_SYMBOLS = ["Performance"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Performance extends ContentProcessDomain {
constructor(session) {
super(session);

Просмотреть файл

@ -6,21 +6,24 @@
var EXPORTED_SYMBOLS = ["Runtime"];
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
executeSoon: "chrome://remote/content/shared/Sync.jsm",
ExecutionContext:
"chrome://remote/content/cdp/domains/content/runtime/ExecutionContext.jsm",
});
const { addDebuggerToGlobal } = ChromeUtils.import(
"resource://gre/modules/jsdebugger.jsm",
{}
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const { ExecutionContext } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/content/runtime/ExecutionContext.jsm"
);
const { executeSoon } = ChromeUtils.import(
"chrome://remote/content/shared/Sync.jsm"
);
// Import the `Debugger` constructor in the current scope
addDebuggerToGlobal(Cu.getGlobalForObject(this));

Просмотреть файл

@ -6,10 +6,15 @@
var EXPORTED_SYMBOLS = ["Security"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Security extends ContentProcessDomain {
constructor(session) {
super(session);

Просмотреть файл

@ -6,8 +6,15 @@
var EXPORTED_SYMBOLS = ["ExecutionContext"];
const uuidGen = Cc["@mozilla.org/uuid-generator;1"].getService(
Ci.nsIUUIDGenerator
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"UUIDGen",
"@mozilla.org/uuid-generator;1",
"nsIUUIDGenerator"
);
const TYPED_ARRAY_CLASSES = [
@ -23,8 +30,7 @@ const TYPED_ARRAY_CLASSES = [
];
function uuid() {
return uuidGen
.generateUUID()
return UUIDGen.generateUUID()
.toString()
.slice(1, -1);
}

Просмотреть файл

@ -6,11 +6,16 @@
var EXPORTED_SYMBOLS = ["Browser"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
class Browser extends Domain {
getVersion() {
const { isHeadless } = Cc["@mozilla.org/gfx/info;1"].getService(

Просмотреть файл

@ -6,12 +6,16 @@
var EXPORTED_SYMBOLS = ["Emulation"];
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
NetUtil: "resource://gre/modules/NetUtil.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
const MAX_WINDOW_SIZE = 10000000;
class Emulation extends Domain {

Просмотреть файл

@ -12,14 +12,10 @@ const { XPCOMUtils } = ChromeUtils.import(
XPCOMUtils.defineLazyModuleGetters(this, {
OS: "resource://gre/modules/osfile.jsm",
});
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { StreamRegistry } = ChromeUtils.import(
"chrome://remote/content/cdp/StreamRegistry.jsm"
);
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
StreamRegistry: "chrome://remote/content/cdp/StreamRegistry.jsm",
});
const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024;

Просмотреть файл

@ -6,12 +6,16 @@
var EXPORTED_SYMBOLS = ["Input"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
class Input extends Domain {
// commands

Просмотреть файл

@ -6,17 +6,16 @@
var EXPORTED_SYMBOLS = ["Network"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
const MAX_COOKIE_EXPIRY = Number.MAX_SAFE_INTEGER;

Просмотреть файл

@ -10,39 +10,23 @@ var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
clearInterval: "resource://gre/modules/Timer.jsm",
OS: "resource://gre/modules/osfile.jsm",
Services: "resource://gre/modules/Services.jsm",
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
setInterval: "resource://gre/modules/Timer.jsm",
DialogHandler:
"chrome://remote/content/cdp/domains/parent/page/DialogHandler.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
PollPromise: "chrome://remote/content/shared/Sync.jsm",
streamRegistry: "chrome://remote/content/cdp/domains/parent/IO.jsm",
TabManager: "chrome://remote/content/shared/TabManager.jsm",
UnsupportedError: "chrome://remote/content/cdp/Error.jsm",
WindowManager: "chrome://remote/content/shared/WindowManager.jsm",
});
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
const { clearInterval, setInterval } = ChromeUtils.import(
"resource://gre/modules/Timer.jsm"
);
const { DialogHandler } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/parent/page/DialogHandler.jsm"
);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { UnsupportedError } = ChromeUtils.import(
"chrome://remote/content/cdp/Error.jsm"
);
const { streamRegistry } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/parent/IO.jsm"
);
const { PollPromise } = ChromeUtils.import(
"chrome://remote/content/shared/Sync.jsm"
);
const { TabManager } = ChromeUtils.import(
"chrome://remote/content/shared/TabManager.jsm"
);
const { WindowManager } = ChromeUtils.import(
"chrome://remote/content/shared/WindowManager.jsm"
);
const MAX_CANVAS_DIMENSION = 32767;
const MAX_CANVAS_AREA = 472907776;

Просмотреть файл

@ -6,17 +6,16 @@
var EXPORTED_SYMBOLS = ["Security"];
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Preferences: "resource://gre/modules/Preferences.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
XPCOMUtils.defineLazyServiceGetters(this, {
sss: ["@mozilla.org/ssservice;1", "nsISiteSecurityService"],
certOverrideService: [

Просмотреть файл

@ -9,6 +9,19 @@ var EXPORTED_SYMBOLS = ["Target"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ContextualIdentityService:
"resource://gre/modules/ContextualIdentityService.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
MainProcessTarget:
"chrome://remote/content/cdp/targets/MainProcessTarget.jsm",
TabManager: "chrome://remote/content/shared/TabManager.jsm",
TabSession: "chrome://remote/content/cdp/sessions/TabSession.jsm",
WindowManager: "chrome://remote/content/shared/WindowManager.jsm",
});
XPCOMUtils.defineLazyServiceGetter(
this,
"UUIDGen",
@ -16,25 +29,6 @@ XPCOMUtils.defineLazyServiceGetter(
"nsIUUIDGenerator"
);
const { ContextualIdentityService } = ChromeUtils.import(
"resource://gre/modules/ContextualIdentityService.jsm"
);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { MainProcessTarget } = ChromeUtils.import(
"chrome://remote/content/cdp/targets/MainProcessTarget.jsm"
);
const { TabManager } = ChromeUtils.import(
"chrome://remote/content/shared/TabManager.jsm"
);
const { TabSession } = ChromeUtils.import(
"chrome://remote/content/cdp/sessions/TabSession.jsm"
);
const { WindowManager } = ChromeUtils.import(
"chrome://remote/content/shared/WindowManager.jsm"
);
let browserContextIds = 1;
class Target extends Domain {

Просмотреть файл

@ -6,10 +6,14 @@
var EXPORTED_SYMBOLS = ["DialogHandler"];
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
Services: "resource://gre/modules/Services.jsm",
});
const DIALOG_TYPES = {
ALERT: "alert",

Просмотреть файл

@ -4,11 +4,17 @@
"use strict";
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { ComponentUtils } = ChromeUtils.import(
"resource://gre/modules/ComponentUtils.jsm"
var EXPORTED_SYMBOLS = ["ChannelEventSinkFactory"];
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ComponentUtils: "resource://gre/modules/ComponentUtils.jsm",
Services: "resource://gre/modules/Services.jsm",
});
const Cm = Components.manager;
/**
@ -105,5 +111,4 @@ ChannelEventSinkFactory.getService = function() {
.wrappedJSObject;
};
var EXPORTED_SYMBOLS = ["ChannelEventSinkFactory"];
this.ChannelEventSinkFactory = ChannelEventSinkFactory;

Просмотреть файл

@ -25,14 +25,16 @@
var EXPORTED_SYMBOLS = ["ContextObserver"];
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { executeSoon } = ChromeUtils.import(
"chrome://remote/content/shared/Sync.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
Services: "resource://gre/modules/Services.jsm",
executeSoon: "chrome://remote/content/shared/Sync.jsm",
});
class ContextObserver {
constructor(chromeEventHandler) {

Просмотреть файл

@ -4,38 +4,20 @@
"use strict";
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { CommonUtils } = ChromeUtils.import(
"resource://services-common/utils.js"
);
const { ChannelEventSinkFactory } = ChromeUtils.import(
"chrome://remote/content/cdp/observers/ChannelEventSink.jsm"
);
const CC = Components.Constructor;
XPCOMUtils.defineLazyModuleGetters(this, {
CommonUtils: "resource://services-common/utils.js",
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
NetUtil: "resource://gre/modules/NetUtil.jsm",
Services: "resource://gre/modules/Services.jsm",
ChannelEventSinkFactory:
"chrome://remote/content/cdp/observers/ChannelEventSink.jsm",
});
const BinaryInputStream = CC(
"@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream"
);
const BinaryOutputStream = CC(
"@mozilla.org/binaryoutputstream;1",
"nsIBinaryOutputStream",
"setOutputStream"
);
const StorageStream = CC(
"@mozilla.org/storagestream;1",
"nsIStorageStream",
"init"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"gActivityDistributor",
@ -43,6 +25,28 @@ XPCOMUtils.defineLazyServiceGetter(
"nsIHttpActivityDistributor"
);
const CC = Components.Constructor;
XPCOMUtils.defineLazyGetter(this, "BinaryInputStream", () => {
return CC(
"@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream"
);
});
XPCOMUtils.defineLazyGetter(this, "BinaryOutputStream", () => {
return CC(
"@mozilla.org/binaryoutputstream;1",
"nsIBinaryOutputStream",
"setOutputStream"
);
});
XPCOMUtils.defineLazyGetter(this, "StorageStream", () => {
return CC("@mozilla.org/storagestream;1", "nsIStorageStream", "init");
});
// Cap response storage with 100Mb per tracked tab.
const MAX_RESPONSE_STORAGE_SIZE = 100 * 1024 * 1024;

Просмотреть файл

@ -6,13 +6,16 @@
var EXPORTED_SYMBOLS = ["TabObserver"];
const { EventPromise } = ChromeUtils.import(
"chrome://remote/content/shared/Sync.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
Services: "resource://gre/modules/Services.jsm",
EventPromise: "chrome://remote/content/shared/Sync.jsm",
});
// TODO(ato):
//

Просмотреть файл

@ -6,18 +6,16 @@
var EXPORTED_SYMBOLS = ["ContentProcessSession"];
const { ContentProcessDomains } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomains.jsm"
);
const { DomainCache } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/DomainCache.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"ContextObserver",
"chrome://remote/content/cdp/observers/ContextObserver.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ContentProcessDomains:
"chrome://remote/content/cdp/domains/ContentProcessDomains.jsm",
ContextObserver: "chrome://remote/content/cdp/observers/ContextObserver.jsm",
DomainCache: "chrome://remote/content/cdp/domains/DomainCache.jsm",
});
class ContentProcessSession {
constructor(messageManager, browsingContext, content, docShell) {

Просмотреть файл

@ -6,16 +6,16 @@
var EXPORTED_SYMBOLS = ["Session"];
const { ParentProcessDomains } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ParentProcessDomains.jsm"
);
const { DomainCache } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/DomainCache.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { NetworkObserver } = ChromeUtils.import(
"chrome://remote/content/cdp/observers/NetworkObserver.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
DomainCache: "chrome://remote/content/cdp/domains/DomainCache.jsm",
NetworkObserver: "chrome://remote/content/cdp/observers/NetworkObserver.jsm",
ParentProcessDomains:
"chrome://remote/content/cdp/domains/ParentProcessDomains.jsm",
});
/**
* A session represents exactly one client WebSocket connection.

Просмотреть файл

@ -6,16 +6,17 @@
var EXPORTED_SYMBOLS = ["MainProcessTarget"];
const { Target } = ChromeUtils.import(
"chrome://remote/content/cdp/targets/Target.jsm"
);
const { MainProcessSession } = ChromeUtils.import(
"chrome://remote/content/cdp/sessions/MainProcessSession.jsm"
);
const { RemoteAgent } = ChromeUtils.import(
"chrome://remote/content/components/RemoteAgent.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
MainProcessSession:
"chrome://remote/content/cdp/sessions/MainProcessSession.jsm",
RemoteAgent: "chrome://remote/content/components/RemoteAgent.jsm",
Target: "chrome://remote/content/cdp/targets/Target.jsm",
});
/**
* The main process Target.
*

Просмотреть файл

@ -6,19 +6,16 @@
var EXPORTED_SYMBOLS = ["TabTarget"];
const { Target } = ChromeUtils.import(
"chrome://remote/content/cdp/targets/Target.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { TabSession } = ChromeUtils.import(
"chrome://remote/content/cdp/sessions/TabSession.jsm"
);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { RemoteAgent } = ChromeUtils.import(
"chrome://remote/content/components/RemoteAgent.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
RemoteAgent: "chrome://remote/content/components/RemoteAgent.jsm",
TabSession: "chrome://remote/content/cdp/sessions/TabSession.jsm",
Target: "chrome://remote/content/cdp/targets/Target.jsm",
});
XPCOMUtils.defineLazyServiceGetter(
this,

Просмотреть файл

@ -6,18 +6,21 @@
var EXPORTED_SYMBOLS = ["Target"];
const { Connection } = ChromeUtils.import(
"chrome://remote/content/cdp/Connection.jsm"
);
const { WebSocketTransport } = ChromeUtils.import(
"chrome://remote/content/server/WebSocketTransport.jsm"
);
const { WebSocketHandshake } = ChromeUtils.import(
"chrome://remote/content/server/WebSocketHandshake.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const UUIDGen = Cc["@mozilla.org/uuid-generator;1"].getService(
Ci.nsIUUIDGenerator
XPCOMUtils.defineLazyModuleGetters(this, {
Connection: "chrome://remote/content/cdp/Connection.jsm",
WebSocketHandshake: "chrome://remote/content/server/WebSocketHandshake.jsm",
WebSocketTransport: "chrome://remote/content/server/WebSocketTransport.jsm",
});
XPCOMUtils.defineLazyServiceGetter(
this,
"UUIDGen",
"@mozilla.org/uuid-generator;1",
"nsIUUIDGenerator"
);
/**

Просмотреть файл

@ -6,19 +6,18 @@
var EXPORTED_SYMBOLS = ["TargetList"];
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
);
const { TabTarget } = ChromeUtils.import(
"chrome://remote/content/cdp/targets/TabTarget.jsm"
);
const { MainProcessTarget } = ChromeUtils.import(
"chrome://remote/content/cdp/targets/MainProcessTarget.jsm"
);
const { TabObserver } = ChromeUtils.import(
"chrome://remote/content/cdp/observers/TargetObserver.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
MainProcessTarget:
"chrome://remote/content/cdp/targets/MainProcessTarget.jsm",
TabObserver: "chrome://remote/content/cdp/observers/TargetObserver.jsm",
TabTarget: "chrome://remote/content/cdp/targets/TabTarget.jsm",
});
class TargetList {
constructor() {
// Target ID -> Target

Просмотреть файл

@ -20,7 +20,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
"chrome://remote/content/cdp/RecommendedPreferences.jsm",
TargetList: "chrome://remote/content/cdp/targets/TargetList.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", Log.get);
XPCOMUtils.defineLazyGetter(this, "log", () => Log.get());
const ENABLED = "remote.enabled";
const FORCE_LOCAL = "remote.force-local";

Просмотреть файл

@ -10,26 +10,28 @@ var EXPORTED_SYMBOLS = ["WebSocketHandshake"];
const CC = Components.Constructor;
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { executeSoon } = ChromeUtils.import(
"chrome://remote/content/shared/Sync.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
executeSoon: "chrome://remote/content/shared/Sync.jsm",
});
XPCOMUtils.defineLazyGetter(this, "CryptoHash", () => {
return CC("@mozilla.org/security/hash;1", "nsICryptoHash", "initWithString");
});
XPCOMUtils.defineLazyGetter(this, "threadManager", () => {
return Cc["@mozilla.org/thread-manager;1"].getService();
});
XPCOMUtils.defineLazyGetter(this, "WebSocket", () => {
return Services.appShell.hiddenDOMWindow.WebSocket;
});
const CryptoHash = CC(
"@mozilla.org/security/hash;1",
"nsICryptoHash",
"initWithString"
);
const threadManager = Cc["@mozilla.org/thread-manager;1"].getService();
// TODO(ato): Merge this with httpd.js so that we can respond to both HTTP/1.1
// as well as WebSocket requests on the same server.

Просмотреть файл

@ -8,10 +8,14 @@
var EXPORTED_SYMBOLS = ["WebSocketTransport"];
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
});
function WebSocketTransport(socket) {
EventEmitter.decorate(this);

Просмотреть файл

@ -6,14 +6,17 @@
var EXPORTED_SYMBOLS = ["pprint", "truncate"];
const { Log } = ChromeUtils.import("chrome://remote/content/shared/Log.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyGetter(this, "log", Log.get);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
Log: "chrome://remote/content/shared/Log.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", () => Log.get());
const ELEMENT_NODE = 1;
const MAX_STRING_LENGTH = 250;

Просмотреть файл

@ -6,7 +6,13 @@
var EXPORTED_SYMBOLS = ["EventPromise", "executeSoon", "PollPromise"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
});
const { TYPE_REPEATING_SLACK } = Ci.nsITimer;

Просмотреть файл

@ -6,7 +6,13 @@
var EXPORTED_SYMBOLS = ["TabManager"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
});
var TabManager = {
get gBrowser() {

Просмотреть файл

@ -6,11 +6,16 @@
var EXPORTED_SYMBOLS = ["WindowManager"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { EventPromise } = ChromeUtils.import(
"chrome://remote/content/shared/Sync.jsm"
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
EventPromise: "chrome://remote/content/shared/Sync.jsm",
});
var WindowManager = {
async focus(window) {
if (window != Services.focus.activeWindow) {