bug 1600111: remote: make nsIRemoteAgent.listen() sync r=remote-protocol-reviewers,maja_zf

Interfaces exposed over XPIDL cannot be marked async, otherwise their
return values get lost.  This patch makes nsIRemoteAgent.listen()
synchronous by removing the use of async/await.

Unfortunately Rust does not yet support deserialising promises sent across
XPIDL, documented in https://bugzilla.mozilla.org/show_bug.cgi?id=1512319.

In an effort to retain the original API internally the function
now returns a promise.  This means the function can be awaited in
JS only, which we make use of in remote/test/browser/head.js.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Tolfsen 2019-12-04 11:57:13 +00:00
Родитель 629a3a47dc
Коммит a217b583f9
1 изменённых файлов: 6 добавлений и 2 удалений

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

@ -31,7 +31,7 @@ class RemoteAgentClass {
return !!this.server && !this.server.isStopped();
}
async listen(url) {
listen(url) {
if (!Preferences.get(ENABLED, false)) {
throw new Error("Remote agent is disabled by preference");
}
@ -56,7 +56,7 @@ class RemoteAgentClass {
}
if (this.listening) {
return;
return Promise.resolve();
}
Preferences.set(RecommendedPreferences);
@ -77,6 +77,10 @@ class RemoteAgentClass {
delete this.server._handler._overridePaths[target.path];
});
return this.asyncListen(host, port);
}
async asyncListen(host, port) {
try {
await this.targets.watchForTargets();