Bug 1492700 - adb-device.js should export AdbDevice and not Device;r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 27 Nov 2018 12:50:45 +0000
changeset 448274 65825c93b47bdcef950dc020ac8a12edfdcdc789
parent 448273 363e8b2ecfabea51817b7531a77366f0a62d0208
child 448275 d5e67b8fbde32dd9c145ffd02086bf0398fdbd58
push id73775
push userjdescottes@mozilla.com
push dateTue, 27 Nov 2018 13:54:48 +0000
treeherderautoland@ad28397dfa43 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke
bugs1492700
milestone65.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 1492700 - adb-device.js should export AdbDevice and not Device;r=daisuke Depends on D12761 Differential Revision: https://phabricator.services.mozilla.com/D12762
devtools/shared/adb/adb-device.js
devtools/shared/adb/adb-devices-registry.js
devtools/shared/adb/adb-scanner.js
--- a/devtools/shared/adb/adb-device.js
+++ b/devtools/shared/adb/adb-device.js
@@ -5,29 +5,29 @@
 "use strict";
 
 const { ADB } = require("devtools/shared/adb/adb");
 
 /**
  * A Device instance is created and registered with the Devices module whenever
  * ADB notices a new device is connected.
  */
-function Device(id) {
+function AdbDevice(id) {
   this.id = id;
 }
 
-Device.prototype = {
+AdbDevice.prototype = {
   type: "adb",
 
   shell: ADB.shell.bind(ADB),
 
   getModel() {
     if (this._modelPromise) {
       return this._modelPromise;
     }
     this._modelPromise = this.shell("getprop ro.product.model")
                              .then(model => model.trim());
     return this._modelPromise;
   },
   // push, pull were removed in Bug 1481691.
 };
 
-module.exports = Device;
+module.exports = AdbDevice;
--- a/devtools/shared/adb/adb-devices-registry.js
+++ b/devtools/shared/adb/adb-devices-registry.js
@@ -26,17 +26,17 @@ class AdbDevicesRegistry extends EventEm
     adbAddon.on("update", this._onAdbAddonUpdate);
   }
 
   /**
    * Register a device (Device class defined in from adb-device.js) for the provided name.
    *
    * @param {String} name
    *        Name of the device.
-   * @param {Device} device
+   * @param {AdbDevice} device
    *        The device to register.
    */
   register(name, device) {
     this._devices[name] = device;
     this.emit("register");
   }
 
   /**
--- a/devtools/shared/adb/adb-scanner.js
+++ b/devtools/shared/adb/adb-scanner.js
@@ -6,17 +6,17 @@
 
 const EventEmitter = require("devtools/shared/event-emitter");
 const { dumpn } = require("devtools/shared/DevToolsUtils");
 const { RuntimeTypes } =
   require("devtools/client/webide/modules/runtime-types");
 const { ADB } = require("devtools/shared/adb/adb");
 const { adbDevicesRegistry } = require("devtools/shared/adb/adb-devices-registry");
 
-loader.lazyRequireGetter(this, "Device", "devtools/shared/adb/adb-device");
+loader.lazyRequireGetter(this, "AdbDevice", "devtools/shared/adb/adb-device");
 
 class ADBScanner extends EventEmitter {
   constructor() {
     super();
     this._runtimes = [];
 
     this._onDeviceConnected = this._onDeviceConnected.bind(this);
     this._onDeviceDisconnected = this._onDeviceDisconnected.bind(this);
@@ -44,17 +44,17 @@ class ADBScanner extends EventEmitter {
     this._updateRuntimes();
   }
 
   _emitUpdated() {
     this.emit("runtime-list-updated");
   }
 
   _onDeviceConnected(deviceId) {
-    const device = new Device(deviceId);
+    const device = new AdbDevice(deviceId);
     adbDevicesRegistry.register(deviceId, device);
   }
 
   _onDeviceDisconnected(deviceId) {
     adbDevicesRegistry.unregister(deviceId);
   }
 
   _updateRuntimes() {
@@ -88,59 +88,59 @@ class ADBScanner extends EventEmitter {
     return this._updateRuntimes();
   }
 
   listRuntimes() {
     return this._runtimes;
   }
 }
 
-function Runtime(device, model, socketPath) {
-  this.device = device;
+function Runtime(adbDevice, model, socketPath) {
+  this._adbDevice = adbDevice;
   this._model = model;
   this._socketPath = socketPath;
 }
 
 Runtime.prototype = {
   type: RuntimeTypes.USB,
   connect(connection) {
     return ADB.prepareTCPConnection(this._socketPath).then(port => {
       connection.host = "localhost";
       connection.port = port;
       connection.connect();
     });
   },
   get id() {
-    return this.device.id + "|" + this._socketPath;
+    return this._adbDevice.id + "|" + this._socketPath;
   },
 };
 
-function FirefoxOnAndroidRuntime(device, model, socketPath) {
-  Runtime.call(this, device, model, socketPath);
+function FirefoxOnAndroidRuntime(adbDevice, model, socketPath) {
+  Runtime.call(this, adbDevice, model, socketPath);
 }
 
 // This requires Unix socket support from Firefox for Android (35+)
-FirefoxOnAndroidRuntime.detect = async function(device, model) {
+FirefoxOnAndroidRuntime.detect = async function(adbDevice, model) {
   const runtimes = [];
   // A matching entry looks like:
   // 00000000: 00000002 00000000 00010000 0001 01 6551588
   //  /data/data/org.mozilla.fennec/firefox-debugger-socket
   const query = "cat /proc/net/unix";
-  const rawSocketInfo = await device.shell(query);
+  const rawSocketInfo = await adbDevice.shell(query);
   let socketInfos = rawSocketInfo.split(/\r?\n/);
   // Filter to lines with "firefox-debugger-socket"
   socketInfos = socketInfos.filter(l => l.includes("firefox-debugger-socket"));
   // It's possible to have multiple lines with the same path, so de-dupe them
   const socketPaths = new Set();
   for (const socketInfo of socketInfos) {
     const socketPath = socketInfo.split(" ").pop();
     socketPaths.add(socketPath);
   }
   for (const socketPath of socketPaths) {
-    const runtime = new FirefoxOnAndroidRuntime(device, model, socketPath);
+    const runtime = new FirefoxOnAndroidRuntime(adbDevice, model, socketPath);
     dumpn("Found " + runtime.name);
     runtimes.push(runtime);
   }
   return runtimes;
 };
 
 FirefoxOnAndroidRuntime.prototype = Object.create(Runtime.prototype);
 
@@ -176,17 +176,17 @@ FirefoxOnAndroidRuntime.prototype._packa
 Object.defineProperty(FirefoxOnAndroidRuntime.prototype, "shortName", {
   get() {
     return `Firefox ${this._channel()}`;
   },
 });
 
 Object.defineProperty(FirefoxOnAndroidRuntime.prototype, "deviceName", {
   get() {
-    return this._model || this.device.id;
+    return this._model || this._adbDevice.id;
   },
 });
 
 Object.defineProperty(FirefoxOnAndroidRuntime.prototype, "name", {
   get() {
     const channel = this._channel();
     return "Firefox " + channel + " on Android (" + this.deviceName + ")";
   },