Bug 1492700 - Migrate AdbRuntime to a class;r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 27 Nov 2018 12:53:26 +0000
changeset 507478 ad28397dfa43589ea5bd814391c26386c5bf751f
parent 507477 21f0a93a65c24f34ad47fcf2204c84ac8fd9fba9
child 507479 268c6832d2bebe890b737c14755b3785366cf829
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [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 - Migrate AdbRuntime to a class;r=daisuke Depends on D12766 Differential Revision: https://phabricator.services.mozilla.com/D12767
devtools/shared/adb/adb-runtime.js
--- a/devtools/shared/adb/adb-runtime.js
+++ b/devtools/shared/adb/adb-runtime.js
@@ -2,77 +2,72 @@
  * 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 { RuntimeTypes } = require("devtools/client/webide/modules/runtime-types");
 const { ADB } = require("devtools/shared/adb/adb");
 
-function AdbRuntime(adbDevice, model, socketPath) {
-  this._adbDevice = adbDevice;
-  this._model = model;
-  this._socketPath = socketPath;
-}
+class AdbRuntime {
+  constructor(adbDevice, model, socketPath) {
+    this.type = RuntimeTypes.USB;
+
+    this._adbDevice = adbDevice;
+    this._model = model;
+    this._socketPath = socketPath;
+  }
+
+  get id() {
+    return this._adbDevice.id + "|" + this._socketPath;
+  }
 
-AdbRuntime.prototype = {
-  type: RuntimeTypes.USB,
+  get deviceName() {
+    return this._model || this._adbDevice.id;
+  }
+
+  get shortName() {
+    return `Firefox ${this._channel()}`;
+  }
+
+  get name() {
+    return `Firefox ${this._channel()} on Android (${this.deviceName})`;
+  }
+
   connect(connection) {
     return ADB.prepareTCPConnection(this._socketPath).then(port => {
       connection.host = "localhost";
       connection.port = port;
       connection.connect();
     });
-  },
-  get id() {
-    return this._adbDevice.id + "|" + this._socketPath;
-  },
-};
-
-AdbRuntime.prototype._channel = function() {
-  const packageName = this._packageName();
+  }
 
-  switch (packageName) {
-    case "org.mozilla.firefox":
-      return "";
-    case "org.mozilla.firefox_beta":
-      return "Beta";
-    case "org.mozilla.fennec":
-    case "org.mozilla.fennec_aurora":
-      // This package name is now the one for Firefox Nightly distributed
-      // through the Google Play Store since "dawn project"
-      // cf. https://bugzilla.mozilla.org/show_bug.cgi?id=1357351#c8
-      return "Nightly";
-    default:
-      return "Custom";
-  }
-};
+  _channel() {
+    const packageName = this._packageName();
 
-AdbRuntime.prototype._packageName = function() {
-  // If using abstract socket address, it is "@org.mozilla.firefox/..."
-  // If using path base socket, it is "/data/data/<package>...""
-  // Until Fennec 62 only supports path based UNIX domain socket, but
-  // Fennec 63+ supports both path based and abstract socket.
-  return this._socketPath.startsWith("@") ?
-    this._socketPath.substr(1).split("/")[0] :
-    this._socketPath.split("/")[3];
-};
+    switch (packageName) {
+      case "org.mozilla.firefox":
+        return "";
+      case "org.mozilla.firefox_beta":
+        return "Beta";
+      case "org.mozilla.fennec":
+      case "org.mozilla.fennec_aurora":
+        // This package name is now the one for Firefox Nightly distributed
+        // through the Google Play Store since "dawn project"
+        // cf. https://bugzilla.mozilla.org/show_bug.cgi?id=1357351#c8
+        return "Nightly";
+      default:
+        return "Custom";
+    }
+  }
 
-Object.defineProperty(AdbRuntime.prototype, "shortName", {
-  get() {
-    return `Firefox ${this._channel()}`;
-  },
-});
-
-Object.defineProperty(AdbRuntime.prototype, "deviceName", {
-  get() {
-    return this._model || this._adbDevice.id;
-  },
-});
-
-Object.defineProperty(AdbRuntime.prototype, "name", {
-  get() {
-    const channel = this._channel();
-    return "Firefox " + channel + " on Android (" + this.deviceName + ")";
-  },
-});
+  _packageName() {
+    // If using abstract socket address, it is "@org.mozilla.firefox/..."
+    // If using path base socket, it is "/data/data/<package>...""
+    // Until Fennec 62 only supports path based UNIX domain socket, but
+    // Fennec 63+ supports both path based and abstract socket.
+    return this._socketPath.startsWith("@") ?
+      this._socketPath.substr(1).split("/")[0] :
+      this._socketPath.split("/")[3];
+  }
+}
 
 exports.AdbRuntime = AdbRuntime;