Bug 1482070 - Rename NetworkMonitor to NetworkObserver and move it next to the NetworkMonitorActor. r=Honza
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 16 Aug 2018 05:30:22 -0700
changeset 432402 6871a98b8b0b27c70848cbd3241db7272a1ee60b
parent 432401 e4b6ce31de8d57f7e772232bda29727e82ec6ea5
child 432403 68bff34cbddd1703e706bce5124c4c358352702a
push id106726
push userapoirot@mozilla.com
push dateMon, 20 Aug 2018 16:07:22 +0000
treeherdermozilla-inbound@68bff34cbddd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1482070
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 1482070 - Rename NetworkMonitor to NetworkObserver and move it next to the NetworkMonitorActor. r=Honza Summary: Depends On D3604 Reviewers: Honza! Tags: #secure-revision Bug #: 1482070 Differential Revision: https://phabricator.services.mozilla.com/D3605 MozReview-Commit-ID: ArS8SxVraiu
devtools/server/actors/network-monitor.js
devtools/server/actors/network-monitor/moz.build
devtools/server/actors/network-monitor/network-observer.js
devtools/shared/webconsole/moz.build
devtools/shared/webconsole/network-monitor.js
--- a/devtools/server/actors/network-monitor.js
+++ b/devtools/server/actors/network-monitor.js
@@ -2,17 +2,17 @@
  * 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";
 
 const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol");
 const { networkMonitorSpec } = require("devtools/shared/specs/network-monitor");
 
-loader.lazyRequireGetter(this, "NetworkMonitor", "devtools/shared/webconsole/network-monitor", true);
+loader.lazyRequireGetter(this, "NetworkObserver", "devtools/server/actors/network-monitor/network-observer", true);
 loader.lazyRequireGetter(this, "NetworkEventActor", "devtools/server/actors/network-event", true);
 
 const NetworkMonitorActor = ActorClassWithSpec(networkMonitorSpec, {
   _netEvents: new Map(),
   _networkEventActorsByURL: new Map(),
 
   /**
    * NetworkMonitorActor is instanciated from WebConsoleActor.startListeners
@@ -36,18 +36,18 @@ const NetworkMonitorActor = ActorClassWi
   initialize(conn, filters, parentID, messageManager) {
     Actor.prototype.initialize.call(this, conn);
 
     this.parentID = parentID;
     this.messageManager = messageManager;
 
     // Immediately start watching for new request according to `filters`.
     // NetworkMonitor will call `onNetworkEvent` method.
-    this.netMonitor = new NetworkMonitor(filters, this);
-    this.netMonitor.init();
+    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.onRequestContent);
@@ -66,19 +66,19 @@ const NetworkMonitorActor = ActorClassWi
     if (data.actorID == this.parentID) {
       this.destroy();
     }
   },
 
   destroy() {
     Actor.prototype.destroy.call(this);
 
-    if (this.netMonitor) {
-      this.netMonitor.destroy();
-      this.netMonitor = null;
+    if (this.observer) {
+      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.onRequestContent);
@@ -136,20 +136,20 @@ const NetworkMonitorActor = ActorClassWi
     this.messageManager.sendAsyncMessage("debug:request-content", {
       url,
       content,
     });
   },
 
   onSetPreference({ data }) {
     if ("saveRequestAndResponseBodies" in data) {
-      this.netMonitor.saveRequestAndResponseBodies = data.saveRequestAndResponseBodies;
+      this.observer.saveRequestAndResponseBodies = data.saveRequestAndResponseBodies;
     }
     if ("throttleData" in data) {
-      this.netMonitor.throttleData = data.throttleData;
+      this.observer.throttleData = data.throttleData;
     }
   },
 
   onGetNetworkEventActor({ data }) {
     const actor = this.getNetworkEventActor(data.channelId);
     this.messageManager.sendAsyncMessage("debug:get-network-event-actor", {
       channelId: data.channelId,
       actor: actor.form()
--- a/devtools/server/actors/network-monitor/moz.build
+++ b/devtools/server/actors/network-monitor/moz.build
@@ -1,10 +1,11 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 DevToolsModules(
     'channel-event-sink.js',
+    'network-observer.js',
     'stack-trace-collector.js',
 )
rename from devtools/shared/webconsole/network-monitor.js
rename to devtools/server/actors/network-monitor/network-observer.js
--- a/devtools/shared/webconsole/network-monitor.js
+++ b/devtools/server/actors/network-monitor/network-observer.js
@@ -42,17 +42,17 @@ const HTTP_TEMPORARY_REDIRECT = 307;
 
 /**
  * Check if a given network request should be logged by a network monitor
  * based on the specified filters.
  *
  * @param nsIHttpChannel channel
  *        Request to check.
  * @param filters
- *        NetworkMonitor filters to match against.
+ *        NetworkObserver filters to match against.
  * @return boolean
  *         True if the network request should be logged, false otherwise.
  */
 function matchRequest(channel, filters) {
   // Log everything if no filter is specified
   if (!filters.outerWindowID && !filters.window) {
     return true;
   }
@@ -99,30 +99,30 @@ function matchRequest(channel, filters) 
     }
   }
 
   return false;
 }
 
 /**
  * The network response listener implements the nsIStreamListener and
- * nsIRequestObserver interfaces. This is used within the NetworkMonitor feature
+ * nsIRequestObserver interfaces. This is used within the NetworkObserver feature
  * to get the response body of the request.
  *
  * The code is mostly based on code listings from:
  *
  *   http://www.softwareishard.com/blog/firebug/
  *      nsitraceablechannel-intercept-http-traffic/
  *
  * @constructor
  * @param object owner
  *        The response listener owner. This object needs to hold the
  *        |openResponses| object.
  * @param object httpActivity
- *        HttpActivity object associated with this request. See NetworkMonitor
+ *        HttpActivity object associated with this request. See NetworkObserver
  *        for more information.
  */
 function NetworkResponseListener(owner, httpActivity) {
   this.owner = owner;
   this.receivedData = "";
   this.httpActivity = httpActivity;
   this.bodySize = 0;
   // Indicates if the response had a size greater than response body limit.
@@ -169,17 +169,17 @@ NetworkResponseListener.prototype = {
     } catch (e) {
       if (e.result != Cr.NS_ERROR_NO_INTERFACE) {
         throw e;
       }
     }
   },
 
   /**
-   * This NetworkResponseListener tracks the NetworkMonitor.openResponses object
+   * This NetworkResponseListener tracks the NetworkObserver.openResponses object
    * to find the associated uncached headers.
    * @private
    */
   _foundOpenResponse: false,
 
   /**
    * If the channel already had notificationCallbacks, hold them here internally
    * so that we can forward getInterface requests to that object.
@@ -421,18 +421,18 @@ NetworkResponseListener.prototype = {
   },
 
   onStatus: function() {
     this._forwardNotification(Ci.nsIProgressEventSink, "onStatus", arguments);
   },
 
   /**
    * Find the open response object associated to the current request. The
-   * NetworkMonitor._httpResponseExaminer() method saves the response headers in
-   * NetworkMonitor.openResponses. This method takes the data from the open
+   * NetworkObserver._httpResponseExaminer() method saves the response headers in
+   * NetworkObserver.openResponses. This method takes the data from the open
    * response object and puts it into the HTTP activity object, then sends it to
    * the remote Web Console instance.
    *
    * @private
    */
   _findOpenResponse: function() {
     if (!this.owner || this._foundOpenResponse) {
       return;
@@ -604,33 +604,33 @@ NetworkResponseListener.prototype = {
  * @param object owner
  *        The network monitor owner. This object needs to hold:
  *        - onNetworkEvent(requestInfo)
  *          This method is invoked once for every new network request and it is
  *          given the initial network request information as an argument.
  *          onNetworkEvent() must return an object which holds several add*()
  *          methods which are used to add further network request/response information.
  */
-function NetworkMonitor(filters, owner) {
+function NetworkObserver(filters, owner) {
   this.filters = filters;
   this.owner = owner;
   this.openRequests = new Map();
   this.openResponses = new Map();
   this._httpResponseExaminer =
     DevToolsUtils.makeInfallible(this._httpResponseExaminer).bind(this);
   this._httpModifyExaminer =
     DevToolsUtils.makeInfallible(this._httpModifyExaminer).bind(this);
   this._serviceWorkerRequest = this._serviceWorkerRequest.bind(this);
   this._throttleData = null;
   this._throttler = null;
 }
 
-exports.NetworkMonitor = NetworkMonitor;
+exports.NetworkObserver = NetworkObserver;
 
-NetworkMonitor.prototype = {
+NetworkObserver.prototype = {
   filters: null,
 
   httpTransactionCodes: {
     0x5001: "REQUEST_HEADER",
     0x5002: "REQUEST_BODY_SENT",
     0x5003: "RESPONSE_START",
     0x5004: "RESPONSE_HEADER",
     0x5005: "RESPONSE_COMPLETE",
--- a/devtools/shared/webconsole/moz.build
+++ b/devtools/shared/webconsole/moz.build
@@ -7,12 +7,11 @@
 if CONFIG['OS_TARGET'] != 'Android':
     MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
     XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
 
 DevToolsModules(
     'client.js',
     'js-property-provider.js',
     'network-helper.js',
-    'network-monitor.js',
     'screenshot-helper.js',
     'throttle.js',
 )