Bug 1397287 - remove usage of addon-sdk node/os helper in devtools/shared/system;r=sole
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 06 Sep 2017 16:35:11 +0200
changeset 428684 90099274b157b256b6af76d510ca2cc2796d4998
parent 428683 6f1782b5810197fba21ce8d8579d7813e7dae94a
child 428685 d297771c1ebe214c255644a8a813ce3742afac73
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssole
bugs1397287
milestone57.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 1397287 - remove usage of addon-sdk node/os helper in devtools/shared/system;r=sole MozReview-Commit-ID: 7JrIeSlmSuj
devtools/shared/system.js
--- a/devtools/shared/system.js
+++ b/devtools/shared/system.js
@@ -4,27 +4,41 @@
 "use strict";
 
 const { Cc, Ci } = require("chrome");
 const { Task } = require("devtools/shared/task");
 
 loader.lazyRequireGetter(this, "Services");
 loader.lazyRequireGetter(this, "promise");
 loader.lazyRequireGetter(this, "defer", "devtools/shared/defer");
-loader.lazyRequireGetter(this, "OS", "resource://gre/modules/commonjs/node/os.js");
 loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
 loader.lazyRequireGetter(this, "AppConstants",
   "resource://gre/modules/AppConstants.jsm", true);
 loader.lazyGetter(this, "screenManager", () => {
   return Cc["@mozilla.org/gfx/screenmanager;1"].getService(Ci.nsIScreenManager);
 });
 loader.lazyGetter(this, "oscpu", () => {
   return Cc["@mozilla.org/network/protocol;1?name=http"]
            .getService(Ci.nsIHttpProtocolHandler).oscpu;
 });
+loader.lazyGetter(this, "hostname", () => {
+  try {
+    // On some platforms (Linux according to try), this service does not exist and fails.
+    return Cc["@mozilla.org/network/dns-service;1"]
+              .getService(Ci.nsIDNSService).myHostName;
+  } catch (e) {
+    return "";
+  }
+});
+loader.lazyGetter(this, "endianness", () => {
+  if ((new Uint32Array((new Uint8Array([1, 2, 3, 4])).buffer))[0] === 0x04030201) {
+    return "LE";
+  }
+  return "BE";
+});
 
 const APP_MAP = {
   "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": "firefox",
   "{3550f703-e582-4d05-9a08-453d09bdfdc6}": "thunderbird",
   "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}": "seamonkey",
   "{718e30fb-e89b-41dd-9da7-e25a45638b28}": "sunbird",
   "{3c2e2abc-06d4-11e1-ac3b-374f68613e61}": "b2g",
   "{aa3c5121-dab2-40e2-81ca-7ea25febc110}": "mobile/android",
@@ -134,20 +148,20 @@ function* getSystemInfo() {
     // Locale used in this build
     locale: Services.locale.getAppLocaleAsLangTag(),
 
     /**
      * Information regarding the operating system.
      */
 
     // Returns the endianness of the architecture: either "LE" or "BE"
-    endianness: OS.endianness(),
+    endianness: endianness,
 
     // Returns the hostname of the machine
-    hostname: OS.hostname(),
+    hostname: hostname,
 
     // Name of the OS type. Typically the same as `uname -s`. Possible values:
     // https://developer.mozilla.org/en/OS_TARGET
     // Also may be "B2G".
     os,
     platform: os,
 
     // hardware and version info from `deviceinfo.hardware`