bug 1523104: remote: s/remote-protocol/remote/g; r=ochameau
authorAndreas Tolfsen <ato@sny.no>
Sat, 23 Feb 2019 15:47:10 +0000
changeset 524106 9ffed583c0e4d825ef12b6f95a5d92c811288c63
parent 524105 b075e49fca677a355b12e28fcbe2f4ee6d533bf7
child 524107 5ce6f3fcc572aa5d0b8aa65eafc1ed759e76f112
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1523104
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1523104: remote: s/remote-protocol/remote/g; r=ochameau
remote/ContentProcessSession.jsm
remote/Session.jsm
--- a/remote/ContentProcessSession.jsm
+++ b/remote/ContentProcessSession.jsm
@@ -12,83 +12,85 @@ const {ContentProcessDomains} = ChromeUt
 class ContentProcessSession {
   constructor(messageManager, browsingContext, content, docShell) {
     this.messageManager = messageManager;
     this.browsingContext = browsingContext;
     this.content = content;
     this.docShell = docShell;
 
     this.domains = new Domains(this, ContentProcessDomains);
-    this.messageManager.addMessageListener("remote-protocol:request", this);
-    this.messageManager.addMessageListener("remote-protocol:destroy", this);
+    this.messageManager.addMessageListener("remote:request", this);
+    this.messageManager.addMessageListener("remote:destroy", this);
 
     this.destroy = this.destroy.bind(this);
     this.content.addEventListener("unload", this.destroy);
   }
 
   destroy() {
     this.content.addEventListener("unload", this.destroy);
-    this.messageManager.removeMessageListener("remote-protocol:request", this);
-    this.messageManager.removeMessageListener("remote-protocol:destroy", this);
+    this.messageManager.removeMessageListener("remote:request", this);
+    this.messageManager.removeMessageListener("remote:destroy", this);
   }
 
-  async receiveMessage({ name, data }) {
-    const { browsingContextId } = data;
+  async receiveMessage({name, data}) {
+    const {browsingContextId} = data;
 
     // We may have more than one tab loaded in the same process,
     // and debug the two at the same time. We want to ensure not
     // mixing up the requests made against two such tabs.
     // Each tab is going to have its own frame script instance
     // and two communication channels are going to be set up via
     // the two message managers.
     if (browsingContextId != this.browsingContext.id) {
       return;
     }
 
     switch (name) {
-      case "remote-protocol:request":
-        try {
-          const { id, domainName, methodName, params } = data.request;
-          const inst = this.domains.get(domainName);
-          const methodFn = inst[methodName];
-          if (!methodFn || typeof methodFn != "function") {
-            throw new Error(`Method implementation of ${methodName} missing`);
-          }
+    case "remote:request":
+      try {
+        const {id, domainName, methodName, params} = data.request;
 
-          const result = await methodFn.call(inst, params);
+        const inst = this.domains.get(domainName);
+        const methodFn = inst[methodName];
+        if (!methodFn || typeof methodFn != "function") {
+          throw new Error(`Method implementation of ${methodName} missing`);
+        }
+
+        const result = await methodFn.call(inst, params);
 
-          this.messageManager.sendAsyncMessage("remote-protocol:result", {
-            browsingContextId,
-            id,
-            result,
-          });
-        } catch (e) {
-          this.messageManager.sendAsyncMessage("remote-protocol:error", {
-            browsingContextId,
-            id: data.request.id,
-            error: {
-              name: e.name || "exception",
-              message: e.message || String(e),
-              stack: e.stack,
-            },
-          });
-        }
-        break;
-      case "remote-protocol:destroy":
-        this.destroy();
-        break;
+        this.messageManager.sendAsyncMessage("remote:result", {
+          browsingContextId,
+          id,
+          result,
+        });
+      } catch (e) {
+        this.messageManager.sendAsyncMessage("remote:error", {
+          browsingContextId,
+          id: data.request.id,
+          error: {
+            name: e.name || "exception",
+            message: e.message || String(e),
+            stack: e.stack,
+          },
+        });
+      }
+      break;
+
+    case "remote:destroy":
+      this.destroy();
+      break;
     }
   }
 
   // EventEmitter
 
   // This method is called when any Domain emit any event
   // Domains register "*" listener on each instantiated Domain.
   onevent(eventName, params) {
-    this.messageManager.sendAsyncMessage("remote-protocol:event", {
+    this.messageManager.sendAsyncMessage("remote:event", {
       browsingContextId: this.browsingContext.id,
       event: {
         method: eventName,
         params,
       },
     });
   }
 }
--- a/remote/Session.jsm
+++ b/remote/Session.jsm
@@ -8,39 +8,39 @@ var EXPORTED_SYMBOLS = ["Session"];
 
 const {ParentProcessDomains} = ChromeUtils.import("chrome://remote/content/domains/ParentProcessDomains.jsm");
 const {Domains} = ChromeUtils.import("chrome://remote/content/domains/Domains.jsm");
 const {formatError} = ChromeUtils.import("chrome://remote/content/Error.jsm");
 
 class Session {
   constructor(connection, target) {
     this.connection = connection;
-    this.target = target;
+    this.connection.onmessage = this.dispatch.bind(this);
 
     this.browsingContext = target.browser.browsingContext;
     this.messageManager = target.browser.messageManager;
-    this.messageManager.loadFrameScript("chrome://remote/content/frame-script.js", false);
-    this.messageManager.addMessageListener("remote-protocol:event", this);
-    this.messageManager.addMessageListener("remote-protocol:result", this);
-    this.messageManager.addMessageListener("remote-protocol:error", this);
-
-    this.connection.onmessage = this.dispatch.bind(this);
 
     this.domains = new Domains(this, ParentProcessDomains);
+    this.messageManager.addMessageListener("remote:event", this);
+    this.messageManager.addMessageListener("remote:result", this);
+    this.messageManager.addMessageListener("remote:error", this);
+
+    this.messageManager.loadFrameScript("chrome://remote/content/frame-script.js", false);
   }
 
   destructor() {
     this.connection.onmessage = null;
 
-    this.messageManager.sendAsyncMessage("remote-protocol:destroy", {
+    this.messageManager.sendAsyncMessage("remote:destroy", {
       browsingContextId: this.browsingContext.id,
     });
-    this.messageManager.removeMessageListener("remote-protocol:event", this);
-    this.messageManager.removeMessageListener("remote-protocol:result", this);
-    this.messageManager.removeMessageListener("remote-protocol:error", this);
+
+    this.messageManager.removeMessageListener("remote:event", this);
+    this.messageManager.removeMessageListener("remote:result", this);
+    this.messageManager.removeMessageListener("remote:error", this);
   }
 
   async dispatch({id, method, params}) {
     try {
       if (typeof id == "undefined") {
         throw new TypeError("Message missing 'id' field");
       }
       if (typeof method == "undefined") {
@@ -53,40 +53,40 @@ class Session {
         const methodFn = inst[methodName];
         if (!methodFn || typeof methodFn != "function") {
           throw new Error(`Method implementation of ${methodName} missing`);
         }
 
         const result = await methodFn.call(inst, params);
         this.connection.send({id, result});
       } else {
-        this.messageManager.sendAsyncMessage("remote-protocol:request", {
+        this.messageManager.sendAsyncMessage("remote:request", {
           browsingContextId: this.browsingContext.id,
           request: {id, domainName, methodName, params},
         });
       }
     } catch (e) {
       const error = formatError(e, {stack: true});
       this.connection.send({id, error});
     }
   }
 
   receiveMessage({name, data}) {
     const {id, result, event, error} = data;
 
     switch (name) {
-    case "remote-protocol:result":
+    case "remote:result":
       this.connection.send({id, result});
       break;
 
-    case "remote-protocol:event":
+    case "remote:event":
       this.connection.send(event);
       break;
 
-    case "remote-protocol:error":
+    case "remote:error":
       this.connection.send({id, error: formatError(error, {stack: true})});
       break;
     }
   }
 
   onevent(eventName, params) {
     this.connection.send({
       method: eventName,