Bug 1378865 - Stop using sdk/core/heritage in DevTools shared webconsole server logger; r=zer0 draft
authorJan Odvarko <odvarko@gmail.com>
Fri, 07 Jul 2017 15:16:56 +0200
changeset 611244 75e5aec30fe33ab1dfcab8837c9c853dee917ad1
parent 610234 5e73b9798464c3f7106f0161dc9a49b234f42f9c
child 638088 59a0b0bfb539506f1eeae224396741135589c785
push id69142
push userjodvarko@mozilla.com
push dateWed, 19 Jul 2017 08:57:45 +0000
reviewerszer0
bugs1378865
milestone56.0a1
Bug 1378865 - Stop using sdk/core/heritage in DevTools shared webconsole server logger; r=zer0 MozReview-Commit-ID: ADFdvBWWMZL
devtools/shared/webconsole/server-logger.js
--- a/devtools/shared/webconsole/server-logger.js
+++ b/devtools/shared/webconsole/server-logger.js
@@ -2,19 +2,17 @@
 /* vim: set ft= javascript ts=2 et sw=2 tw=80: */
 /* 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/. */
 
 "use strict";
 
 const {Ci} = require("chrome");
-const {Class} = require("sdk/core/heritage");
 const Services = require("Services");
-
 const {DebuggerServer} = require("devtools/server/main");
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 
 loader.lazyGetter(this, "NetworkHelper", () => require("devtools/shared/webconsole/network-helper"));
 
 // Helper tracer. Should be generic sharable by other modules (bug 1171927)
 const trace = {
   log: function () {
@@ -30,42 +28,38 @@ const acceptableHeaders = ["x-chromelogg
  * within HTTP headers and sending them to the client.
  *
  * The logic is based on "http-on-examine-response" event that is
  * sent when a response from the server is received. Consequently HTTP
  * headers are parsed to find server side logs.
  *
  * A listeners for "http-on-examine-response" is registered when
  * the listener starts and removed when destroy is executed.
+ *
+ * @param {Object} win (nsIDOMWindow):
+ *        filter network requests by the associated window object.
+ *        If null (i.e. in the browser context) log everything
+ * @param {Object} owner
+ *        The {@WebConsoleActor} instance
  */
-var ServerLoggingListener = Class({
-  /**
-   * Initialization of the listener. The main step during the initialization
-   * process is registering a listener for "http-on-examine-response" event.
-   *
-   * @param {Object} win (nsIDOMWindow):
-   *        filter network requests by the associated window object.
-   *        If null (i.e. in the browser context) log everything
-   * @param {Object} owner
-   *        The {@WebConsoleActor} instance
-   */
-  initialize: function (win, owner) {
-    trace.log("ServerLoggingListener.initialize; ", owner.actorID,
-      ", child process: ", DebuggerServer.isInChildProcess);
+function ServerLoggingListener(win, owner) {
+  trace.log("ServerLoggingListener.initialize; ", owner.actorID,
+    ", child process: ", DebuggerServer.isInChildProcess);
+
+  this.owner = owner;
+  this.window = win;
 
-    this.owner = owner;
-    this.window = win;
+  this.onExamineResponse = this.onExamineResponse.bind(this);
+  this.onExamineHeaders = this.onExamineHeaders.bind(this);
+  this.onParentMessage = this.onParentMessage.bind(this);
 
-    this.onExamineResponse = this.onExamineResponse.bind(this);
-    this.onExamineHeaders = this.onExamineHeaders.bind(this);
-    this.onParentMessage = this.onParentMessage.bind(this);
+  this.attach();
+}
 
-    this.attach();
-  },
-
+ServerLoggingListener.prototype = {
   /**
    * The destroy is called by the parent WebConsoleActor actor.
    */
   destroy: function () {
     trace.log("ServerLoggingListener.destroy; ", this.owner.actorID,
       ", child process: ", DebuggerServer.isInChildProcess);
 
     this.detach();
@@ -372,17 +366,17 @@ var ServerLoggingListener = Class({
       }
     }
 
     trace.log("ServerLoggingListener.sendMessage; raw: ",
       msg.logs.join(", "), message);
 
     this.owner.onServerLogCall(message);
   },
-});
+};
 
 // Helpers
 
 /**
  * Parse printf-like specifiers ("%f", "%d", ...) and
  * format the logs according to them.
  */
 function format(msg) {