зеркало из https://github.com/mozilla/gecko-dev.git
bug 1523104: remote: remove unused modules; r=ato
This commit is contained in:
Родитель
cbe8f61b5b
Коммит
c9dfbc96b8
|
@ -1,72 +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/. */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = [
|
|
||||||
"MessageChannelActorChild",
|
|
||||||
"RemoteAgentActorChild",
|
|
||||||
];
|
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
|
||||||
const {Log} = ChromeUtils.import("chrome://remote/content/Log.jsm");
|
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGetter(this, "log", Log.get);
|
|
||||||
|
|
||||||
// TODO(ato):
|
|
||||||
// This used to have more stuff on it, but now only really does logging,
|
|
||||||
// and I'm sure there's a better way to get the message manager logs.
|
|
||||||
class RemoteAgentActorChild extends ActorChild {
|
|
||||||
get browsingContext() {
|
|
||||||
return this.docShell.browsingContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendAsyncMessage(name, data = {}) {
|
|
||||||
log.trace(`<--(message ${name}) ${JSON.stringify(data)}`);
|
|
||||||
super.sendAsyncMessage(name, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
receiveMessage(name, data) {
|
|
||||||
log.trace(`(message ${name})--> ${JSON.stringify(data)}`);
|
|
||||||
super.receiveMessage(name, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(ato): Move to MessageChannel.jsm?
|
|
||||||
// TODO(ato): This can eventually be replaced by ActorChild and IPDL generation
|
|
||||||
// TODO(ato): Can we find a shorter name?
|
|
||||||
class MessageChannelActorChild extends RemoteAgentActorChild {
|
|
||||||
constructor(dispatcher) {
|
|
||||||
super(dispatcher);
|
|
||||||
this.name = `RemoteAgent:${this.constructor.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(eventName, params = {}) {
|
|
||||||
this.send({eventName, params});
|
|
||||||
}
|
|
||||||
|
|
||||||
send(message = {}) {
|
|
||||||
this.sendAsyncMessage(this.name, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// nsIMessageListener
|
|
||||||
|
|
||||||
async receiveMessage({name, data}) {
|
|
||||||
const {id, methodName, params} = data;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const func = this[methodName];
|
|
||||||
if (!func) {
|
|
||||||
throw new Error("Unknown method: " + methodName);
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await func.call(this, params);
|
|
||||||
this.send({id, result});
|
|
||||||
} catch ({message, stack}) {
|
|
||||||
const error = `${message}\n${stack}`;
|
|
||||||
this.send({id, error});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +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/. */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["AtomicMap"];
|
|
||||||
|
|
||||||
class AtomicMap extends Map {
|
|
||||||
set(key, value) {
|
|
||||||
if (this.has(key)) {
|
|
||||||
throw new RangeError("Key already used: " + key);
|
|
||||||
}
|
|
||||||
super.set(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
pop(key) {
|
|
||||||
if (!super.has(key)) {
|
|
||||||
throw new RangeError("No such key in map: " + key);
|
|
||||||
}
|
|
||||||
const rv = super.get(key);
|
|
||||||
super.delete(key);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,90 +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/. */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["MessageChannel"];
|
|
||||||
|
|
||||||
const {AtomicMap} = ChromeUtils.import("chrome://remote/content/Collections.jsm");
|
|
||||||
const {FatalError} = ChromeUtils.import("chrome://remote/content/Error.jsm");
|
|
||||||
const {Log} = ChromeUtils.import("chrome://remote/content/Log.jsm");
|
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGetter(this, "log", Log.get);
|
|
||||||
|
|
||||||
class MessageChannel {
|
|
||||||
constructor(target, channelName, messageManager) {
|
|
||||||
this.target = target;
|
|
||||||
this.name = channelName;
|
|
||||||
this.mm = messageManager;
|
|
||||||
this.mm.addMessageListener(this.name, this);
|
|
||||||
|
|
||||||
this.ids = 0;
|
|
||||||
this.pending = new AtomicMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
destructor() {
|
|
||||||
this.mm.removeMessageListener(this.name, this);
|
|
||||||
this.ids = 0;
|
|
||||||
this.pending.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
send(methodName, params = {}) {
|
|
||||||
const id = ++this.ids;
|
|
||||||
const promise = new Promise((resolve, reject) => {
|
|
||||||
this.pending.set(id, {resolve, reject});
|
|
||||||
});
|
|
||||||
|
|
||||||
const msg = {id, methodName, params};
|
|
||||||
log.trace(`(channel ${this.name})--> ${JSON.stringify(msg)}`);
|
|
||||||
this.mm.sendAsyncMessage(this.name, msg);
|
|
||||||
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
onevent() {}
|
|
||||||
|
|
||||||
onresponse(id, result) {
|
|
||||||
const {resolve} = this.pending.pop(id);
|
|
||||||
resolve(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
onerror(id, error) {
|
|
||||||
const {reject} = this.pending.pop(id);
|
|
||||||
reject(new Error(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
receiveMessage({data}) {
|
|
||||||
log.trace(`<--(channel ${this.name}) ${JSON.stringify(data)}`);
|
|
||||||
|
|
||||||
if (data.methodName) {
|
|
||||||
throw new FatalError("Circular message channel!", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.id) {
|
|
||||||
const {id, error, result} = data;
|
|
||||||
if (error) {
|
|
||||||
this.onerror(id, error);
|
|
||||||
} else {
|
|
||||||
this.onresponse(id, result);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const {eventName, params = {}} = data;
|
|
||||||
this.onevent(eventName, params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toString() {
|
|
||||||
return `[object MessageChannel ${this.name}]`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XPCOM
|
|
||||||
|
|
||||||
get QueryInterface() {
|
|
||||||
return ChromeUtils.generateQI([
|
|
||||||
Ci.nsIMessageListener,
|
|
||||||
Ci.nsISupportsWeakReference,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
remote.jar:
|
remote.jar:
|
||||||
% content remote %content/
|
% content remote %content/
|
||||||
content/Actor.jsm (Actor.jsm)
|
|
||||||
content/Collections.jsm (Collections.jsm)
|
|
||||||
content/Connection.jsm (Connection.jsm)
|
content/Connection.jsm (Connection.jsm)
|
||||||
content/ContentProcessSession.jsm (ContentProcessSession.jsm)
|
content/ContentProcessSession.jsm (ContentProcessSession.jsm)
|
||||||
content/Domain.jsm (Domain.jsm)
|
content/Domain.jsm (Domain.jsm)
|
||||||
|
@ -14,7 +12,6 @@ remote.jar:
|
||||||
content/EventEmitter.jsm (EventEmitter.jsm)
|
content/EventEmitter.jsm (EventEmitter.jsm)
|
||||||
content/Handler.jsm (Handler.jsm)
|
content/Handler.jsm (Handler.jsm)
|
||||||
content/Log.jsm (Log.jsm)
|
content/Log.jsm (Log.jsm)
|
||||||
content/MessageChannel.jsm (MessageChannel.jsm)
|
|
||||||
content/Observer.jsm (Observer.jsm)
|
content/Observer.jsm (Observer.jsm)
|
||||||
content/Prefs.jsm (Prefs.jsm)
|
content/Prefs.jsm (Prefs.jsm)
|
||||||
content/Protocol.jsm (Protocol.jsm)
|
content/Protocol.jsm (Protocol.jsm)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче