bug 1523104: remote: rename Debugger to TargetListener; r=ochameau
authorAndreas Tolfsen <ato@sny.no>
Fri, 08 Feb 2019 16:10:23 +0000
changeset 521068 f7e7800294cb
parent 521067 3e150e389aaa
child 521069 9b980764075b
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: rename Debugger to TargetListener; r=ochameau
remote/Debugger.jsm
remote/Target.jsm
remote/TargetListener.jsm
remote/jar.mn
deleted file mode 100644
--- a/remote/Debugger.jsm
+++ /dev/null
@@ -1,73 +0,0 @@
-/* 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";
-
-var EXPORTED_SYMBOLS = ["Debugger"];
-
-const {Connection} = ChromeUtils.import("chrome://remote/content/Connection.jsm");
-const {Session} = ChromeUtils.import("chrome://remote/content/Session.jsm");
-const {SocketListener} = ChromeUtils.import("chrome://remote/content/server/Socket.jsm");
-
-/**
- * Represents a debuggee target (a browsing context, typically a tab)
- * that clients can connect to and debug.
- *
- * Debugger#listen starts a WebSocket listener,
- * and for each accepted connection a new Session is created.
- * There can be multiple sessions per target.
- * The session's lifetime is equal to the lifetime of the debugger connection.
- */
-this.Debugger = class {
-  constructor(target) {
-    this.target = target;
-    this.listener = null;
-    this.sessions = new Map();
-    this.nextConnID = 0;
-  }
-
-  get connected() {
-    return !!this.listener && this.listener.listening;
-  }
-
-  listen() {
-    if (this.listener) {
-      return;
-    }
-
-    this.listener = new SocketListener();
-    this.listener.on("accepted", this.onConnectionAccepted.bind(this));
-
-    this.listener.listen("ws", 0 /* atomically allocated port */);
-  }
-
-  close() {
-    this.listener.off("accepted", this.onConnectionAccepted.bind(this));
-    for (const [conn, session] of this.sessions) {
-      session.destructor();
-      conn.close();
-    }
-    this.listener.close();
-    this.listener = null;
-    this.sessions.clear();
-  }
-
-  onConnectionAccepted(transport, listener) {
-    const conn = new Connection(this.nextConnID++, transport, listener);
-    transport.ready();
-    this.sessions.set(conn, new Session(conn, this.target));
-  }
-
-  get url() {
-    if (this.connected) {
-      const {network, host, port} = this.listener;
-      return `${network}://${host}:${port}/`;
-    }
-    return null;
-  }
-
-  toString() {
-    return `[object Debugger ${this.url || "disconnected"}]`;
-  }
-};
--- a/remote/Target.jsm
+++ b/remote/Target.jsm
@@ -1,29 +1,29 @@
 /* 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";
 
 var EXPORTED_SYMBOLS = ["Target"];
 
-const {Debugger} = ChromeUtils.import("chrome://remote/content/Debugger.jsm");
 const {EventEmitter} = ChromeUtils.import("chrome://remote/content/EventEmitter.jsm");
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const {TargetListener} = ChromeUtils.import("chrome://remote/content/TargetListener.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "Favicons",
     "@mozilla.org/browser/favicon-service;1", "nsIFaviconService");
 
 /** A debugging target. */
 this.Target = class {
   constructor(browser) {
     this.browser = browser;
-    this.debugger = new Debugger(this);
+    this.debugger = new TargetListener(this);
 
     EventEmitter.decorate(this);
   }
 
   connect() {
     Services.obs.addObserver(this, "message-manager-disconnect");
     this.debugger.listen();
     this.emit("connect");
new file mode 100644
--- /dev/null
+++ b/remote/TargetListener.jsm
@@ -0,0 +1,73 @@
+/* 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";
+
+var EXPORTED_SYMBOLS = ["Debugger"];
+
+const {Connection} = ChromeUtils.import("chrome://remote/content/Connection.jsm");
+const {Session} = ChromeUtils.import("chrome://remote/content/Session.jsm");
+const {SocketListener} = ChromeUtils.import("chrome://remote/content/server/Socket.jsm");
+
+/**
+ * Represents a debuggee target (a browsing context, typically a tab)
+ * that clients can connect to and debug.
+ *
+ * Debugger#listen starts a WebSocket listener,
+ * and for each accepted connection a new Session is created.
+ * There can be multiple sessions per target.
+ * The session's lifetime is equal to the lifetime of the debugger connection.
+ */
+this.TargetListener = class {
+  constructor(target) {
+    this.target = target;
+    this.listener = null;
+    this.sessions = new Map();
+    this.nextConnID = 0;
+  }
+
+  get connected() {
+    return !!this.listener && this.listener.listening;
+  }
+
+  listen() {
+    if (this.listener) {
+      return;
+    }
+
+    this.listener = new SocketListener();
+    this.listener.on("accepted", this.onConnectionAccepted.bind(this));
+
+    this.listener.listen("ws", 0 /* atomically allocated port */);
+  }
+
+  close() {
+    this.listener.off("accepted", this.onConnectionAccepted.bind(this));
+    for (const [conn, session] of this.sessions) {
+      session.destructor();
+      conn.close();
+    }
+    this.listener.close();
+    this.listener = null;
+    this.sessions.clear();
+  }
+
+  onConnectionAccepted(transport, listener) {
+    const conn = new Connection(this.nextConnID++, transport, listener);
+    transport.ready();
+    this.sessions.set(conn, new Session(conn, this.target));
+  }
+
+  get url() {
+    if (this.connected) {
+      const {network, host, port} = this.listener;
+      return `${network}://${host}:${port}/`;
+    }
+    return null;
+  }
+
+  toString() {
+    return `[object Debugger ${this.url || "disconnected"}]`;
+  }
+};
--- a/remote/jar.mn
+++ b/remote/jar.mn
@@ -3,29 +3,29 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 remote.jar:
 % content remote %content/
   content/Actor.jsm (Actor.jsm)
   content/Collections.jsm (Collections.jsm)
   content/Connection.jsm (Connection.jsm)
   content/ConsoleServiceObserver.jsm (ConsoleServiceObserver.jsm)
-  content/Debugger.jsm (Debugger.jsm)
   content/Domain.jsm (Domain.jsm)
   content/Error.jsm (Error.jsm)
   content/EventEmitter.jsm (EventEmitter.jsm)
   content/Handler.jsm (Handler.jsm)
   content/Log.jsm (Log.jsm)
   content/MessageChannel.jsm (MessageChannel.jsm)
   content/Observer.jsm (Observer.jsm)
   content/Prefs.jsm (Prefs.jsm)
   content/Protocol.jsm (Protocol.jsm)
   content/Session.jsm (Session.jsm)
   content/Sync.jsm (Sync.jsm)
   content/Target.jsm (Target.jsm)
+  content/TargetListener.jsm (TargetListener.jsm)
   content/WindowManager.jsm (WindowManager.jsm)
 
   # domains
   content/domain/Log.jsm (domain/Log.jsm)
   content/domain/Network.jsm (domain/Network.jsm)
   content/domain/Page.jsm (domain/Page.jsm)
   content/domain/Runtime.jsm (domain/Runtime.jsm)