Bug 1482990 - Use different message names for inbound/outbound message between console and netmonitor actors. r=jdescottes
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 29 Aug 2018 12:38:24 +0000
changeset 491537 f6b4091debb457316ddd9fb19ef1df3b22be008a
parent 491536 5a10206060324bbc968a76d5f570e9de05b12506
child 491538 cb3227f5156ca5b03e571b42ee50bac06713c6f8
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1482990
milestone63.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 1482990 - Use different message names for inbound/outbound message between console and netmonitor actors. r=jdescottes Differential Revision: https://phabricator.services.mozilla.com/D4521
devtools/server/actors/network-event.js
devtools/server/actors/network-monitor.js
devtools/server/actors/network-monitor/stack-trace-collector.js
devtools/server/actors/webconsole.js
--- a/devtools/server/actors/network-event.js
+++ b/devtools/server/actors/network-event.js
@@ -257,22 +257,23 @@ const NetworkEventActor = protocol.Actor
     // and the stack is available from the content process.
     // Fetch it lazily from here via the message manager.
     if (stacktrace && typeof stacktrace == "boolean") {
       const messageManager = this.netMonitorActor.messageManager;
       stacktrace = await new Promise(resolve => {
         const onMessage = ({ data }) => {
           const { channelId, stack } = data;
           if (channelId == this._channelId) {
-            messageManager.removeMessageListener("debug:request-stack", onMessage);
+            messageManager.removeMessageListener("debug:request-stack:response",
+              onMessage);
             resolve(stack);
           }
         };
-        messageManager.addMessageListener("debug:request-stack", onMessage);
-        messageManager.sendAsyncMessage("debug:request-stack", this._channelId);
+        messageManager.addMessageListener("debug:request-stack:response", onMessage);
+        messageManager.sendAsyncMessage("debug:request-stack:request", this._channelId);
       });
       this._stackTrace = stacktrace;
     }
 
     return {
       stacktrace,
     };
   },
--- a/devtools/server/actors/network-monitor.js
+++ b/devtools/server/actors/network-monitor.js
@@ -44,23 +44,23 @@ const NetworkMonitorActor = ActorClassWi
     this.observer = new NetworkObserver(filters, this);
     this.observer.init();
 
     this.stackTraces = new Set();
     this.onStackTraceAvailable = this.onStackTraceAvailable.bind(this);
     this.messageManager.addMessageListener("debug:request-stack-available",
       this.onStackTraceAvailable);
     this.onRequestContent = this.onRequestContent.bind(this);
-    this.messageManager.addMessageListener("debug:request-content",
+    this.messageManager.addMessageListener("debug:request-content:request",
       this.onRequestContent);
     this.onSetPreference = this.onSetPreference.bind(this);
     this.messageManager.addMessageListener("debug:netmonitor-preference",
       this.onSetPreference);
     this.onGetNetworkEventActor = this.onGetNetworkEventActor.bind(this);
-    this.messageManager.addMessageListener("debug:get-network-event-actor",
+    this.messageManager.addMessageListener("debug:get-network-event-actor:request",
       this.onGetNetworkEventActor);
     this.onDestroyMessage = this.onDestroyMessage.bind(this);
     this.messageManager.addMessageListener("debug:destroy-network-monitor",
       this.onDestroyMessage);
   },
 
   onDestroyMessage({ data }) {
     if (data.actorID == this.parentID) {
@@ -75,21 +75,21 @@ const NetworkMonitorActor = ActorClassWi
       this.observer.destroy();
       this.observer = null;
     }
 
     this.stackTraces.clear();
     if (this.messageManager) {
       this.messageManager.removeMessageListener("debug:request-stack-available",
         this.onStackTraceAvailable);
-      this.messageManager.removeMessageListener("debug:request-content",
+      this.messageManager.removeMessageListener("debug:request-content:request",
         this.onRequestContent);
       this.messageManager.removeMessageListener("debug:netmonitor-preference",
         this.onSetPreference);
-      this.messageManager.removeMessageListener("debug:get-network-event-actor",
+      this.messageManager.removeMessageListener("debug:get-network-event-actor:request",
         this.onGetNetworkEventActor);
       this.messageManager.removeMessageListener("debug:destroy-network-monitor",
         this.onDestroyMessage);
       this.messageManager = null;
     }
   },
 
   onStackTraceAvailable(msg) {
@@ -128,34 +128,34 @@ const NetworkMonitorActor = ActorClassWi
   },
 
   onRequestContent(msg) {
     const { url } = msg.data;
     const actor = this._networkEventActorsByURL.get(url);
     // Always reply with a message, but with a null `content` if this instance
     // did not processed this request
     const content = actor ? this.getRequestContentForActor(actor) : null;
-    this.messageManager.sendAsyncMessage("debug:request-content", {
+    this.messageManager.sendAsyncMessage("debug:request-content:response", {
       url,
       content,
     });
   },
 
   onSetPreference({ data }) {
     if ("saveRequestAndResponseBodies" in data) {
       this.observer.saveRequestAndResponseBodies = data.saveRequestAndResponseBodies;
     }
     if ("throttleData" in data) {
       this.observer.throttleData = data.throttleData;
     }
   },
 
   onGetNetworkEventActor({ data }) {
     const actor = this.getNetworkEventActor(data.channelId);
-    this.messageManager.sendAsyncMessage("debug:get-network-event-actor", {
+    this.messageManager.sendAsyncMessage("debug:get-network-event-actor:response", {
       channelId: data.channelId,
       actor: actor.form()
     });
   },
 
   getNetworkEventActor(channelId) {
     let actor = this._netEvents.get(channelId);
     if (actor) {
--- a/devtools/server/actors/network-monitor/stack-trace-collector.js
+++ b/devtools/server/actors/network-monitor/stack-trace-collector.js
@@ -23,25 +23,26 @@ function StackTraceCollector(filters, ne
 }
 
 StackTraceCollector.prototype = {
   init() {
     Services.obs.addObserver(this, "http-on-opening-request");
     ChannelEventSinkFactory.getService().registerCollector(this);
     this.onGetStack = this.onGetStack.bind(this);
     for (const { messageManager } of this.netmonitors) {
-      messageManager.addMessageListener("debug:request-stack", this.onGetStack);
+      messageManager.addMessageListener("debug:request-stack:request", this.onGetStack);
     }
   },
 
   destroy() {
     Services.obs.removeObserver(this, "http-on-opening-request");
     ChannelEventSinkFactory.getService().unregisterCollector(this);
     for (const { messageManager } of this.netmonitors) {
-      messageManager.removeMessageListener("debug:request-stack", this.onGetStack);
+      messageManager.removeMessageListener("debug:request-stack:request",
+        this.onGetStack);
     }
   },
 
   _saveStackTrace(channel, stacktrace) {
     for (const { messageManager } of this.netmonitors) {
       messageManager.sendAsyncMessage("debug:request-stack-available", {
         channelId: channel.channelId,
         stacktrace: stacktrace && stacktrace.length > 0
@@ -100,16 +101,16 @@ StackTraceCollector.prototype = {
     this.stacktracesById.delete(channelId);
     return trace;
   },
 
   onGetStack(msg) {
     const messageManager = msg.target;
     const channelId = msg.data;
     const stack = this.getStackTrace(channelId);
-    messageManager.sendAsyncMessage("debug:request-stack", {
+    messageManager.sendAsyncMessage("debug:request-stack:response", {
       channelId,
       stack,
     });
   },
 };
 
 exports.StackTraceCollector = StackTraceCollector;
--- a/devtools/server/actors/webconsole.js
+++ b/devtools/server/actors/webconsole.js
@@ -1510,24 +1510,25 @@ WebConsoleActor.prototype =
         if (data.url != url) {
           return;
         }
         messagesReceived++;
         // Either use the first response with a content, or return a null content
         // if we received the responses from all the message managers.
         if (data.content || messagesReceived == this.netmonitors.length) {
           for (const { messageManager } of this.netmonitors) {
-            messageManager.removeMessageListener("debug:request-content", onMessage);
+            messageManager.removeMessageListener("debug:request-content:response",
+              onMessage);
           }
           resolve(data.content);
         }
       };
       for (const { messageManager } of this.netmonitors) {
-        messageManager.addMessageListener("debug:request-content", onMessage);
-        messageManager.sendAsyncMessage("debug:request-content", { url });
+        messageManager.addMessageListener("debug:request-content:response", onMessage);
+        messageManager.sendAsyncMessage("debug:request-content:request", { url });
       }
     });
   },
 
   /**
    * Send a new HTTP request from the target's window.
    *
    * @param object message
@@ -1577,25 +1578,27 @@ WebConsoleActor.prototype =
     // Only query the NetworkMonitorActor running in the parent process, where the
     // request will be done. There always is one listener running in the parent process,
     // see startListeners.
     const netmonitor = this.netmonitors.filter(({ parentProcess }) => parentProcess)[0];
     const { messageManager } = netmonitor;
     return new Promise(resolve => {
       const onMessage = ({ data }) => {
         if (data.channelId == channelId) {
-          messageManager.removeMessageListener("debug:get-network-event-actor",
+          messageManager.removeMessageListener("debug:get-network-event-actor:response",
             onMessage);
           resolve({
             eventActor: data.actor
           });
         }
       };
-      messageManager.addMessageListener("debug:get-network-event-actor", onMessage);
-      messageManager.sendAsyncMessage("debug:get-network-event-actor", { channelId });
+      messageManager.addMessageListener("debug:get-network-event-actor:response",
+        onMessage);
+      messageManager.sendAsyncMessage("debug:get-network-event-actor:request",
+        { channelId });
     });
   },
 
   /**
    * Handler for file activity. This method sends the file request information
    * to the remote Web Console client.
    *
    * @see ConsoleProgressListener