bug 1523104: remote: make Session#receiveMessage slightly more succinct; r=ochameau
authorAndreas Tolfsen <ato@sny.no>
Thu, 21 Feb 2019 13:07:29 +0000
changeset 521102 b35c2a9a00d24231098fa38de9d4178eee7c659f
parent 521101 2f7767b51e69f23c955628d058ff1897af5085c1
child 521103 cce704488a62b3b64b00c1500da76b4db4e08a6f
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [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: make Session#receiveMessage slightly more succinct; r=ochameau
remote/Session.jsm
--- a/remote/Session.jsm
+++ b/remote/Session.jsm
@@ -55,31 +55,31 @@ class Session {
         request: {id, domainName, methodName, params},
       });
     } catch (e) {
       const error = formatError(e, {stack: true});
       this.connection.send({id, error});
     }
   }
 
-  receiveMessage({ name, data }) {
+  receiveMessage({name, data}) {
+    const {id, result, event, error} = data;
+
     switch (name) {
-      case "remote-protocol:result":
-        this.connection.send({
-          id: data.id,
-          result: data.result,
-        });
-        break;
-      case "remote-protocol:event":
-        this.connection.send(data.event);
-        break;
-      case "remote-protocol:error":
-        const error = formatError(data.error, {stack: true});
-        this.connection.send({id: data.id, error});
-        break;
+    case "remote-protocol:result":
+      this.connection.send({id, result});
+      break;
+
+    case "remote-protocol:event":
+      this.connection.send(event);
+      break;
+
+    case "remote-protocol:error":
+      this.connection.send({id, error: formatError(error, {stack: true})});
+      break;
     }
   }
 }
 
 /**
  * Split s by sep, returning list of substrings.
  * If max is given, at most max splits are done.
  * If max is 0, there is no limit on the number of splits.