Bug 1397287 - remove usage of addon-sdk node/os helper in devtools/shared/system;r=sole
MozReview-Commit-ID: 7JrIeSlmSuj
--- 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`