Bug 1149778 - Lazify simulator startup to allow ADB init. r=ochameau, a=sledru
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 01 Apr 2015 13:31:00 +0200
changeset 258280 ecf15768ec50
parent 258279 2ff89ac6dc8d
child 258281 3d380257da88
push id4634
push userryanvm@gmail.com
push date2015-04-06 16:06 +0000
treeherdermozilla-beta@6238a894c78f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, sledru
bugs1149778
milestone38.0
Bug 1149778 - Lazify simulator startup to allow ADB init. r=ochameau, a=sledru
browser/devtools/webide/modules/simulator-process.js
browser/devtools/webide/modules/simulators.js
--- a/browser/devtools/webide/modules/simulator-process.js
+++ b/browser/devtools/webide/modules/simulator-process.js
@@ -8,29 +8,33 @@
 const { Cc, Ci, Cu } = require("chrome");
 
 const Environment = require("sdk/system/environment").env;
 const Subprocess = require("sdk/system/child_process/subprocess");
 const { EventEmitter } = Cu.import("resource://gre/modules/devtools/event-emitter.js", {});
 const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
 
-let platform = Services.appShell.hiddenDOMWindow.navigator.platform;
-let OS = "";
-if (platform.indexOf("Win") != -1) {
-  OS = "win32";
-} else if (platform.indexOf("Mac") != -1) {
-  OS = "mac64";
-} else if (platform.indexOf("Linux") != -1) {
-  if (platform.indexOf("x86_64") != -1) {
-    OS = "linux64";
-  } else {
-    OS = "linux32";
+loader.lazyGetter(this, "OS", () => {
+  const Runtime = require("sdk/system/runtime");
+  switch (Runtime.OS) {
+    case "Darwin":
+      return "mac64";
+    case "Linux":
+      if (Runtime.XPCOMABI.indexOf("x86_64") === 0) {
+        return "linux64";
+      } else {
+        return "linux32";
+      }
+    case "WINNT":
+      return "win32";
+    default:
+      return "";
   }
-}
+});
 
 function SimulatorProcess() {}
 SimulatorProcess.prototype = {
 
   // Check if B2G is running.
   get isRunning() !!this.process,
 
   // Start the process and connect the debugger client.
--- a/browser/devtools/webide/modules/simulators.js
+++ b/browser/devtools/webide/modules/simulators.js
@@ -1,17 +1,18 @@
 /* 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/. */
 
 const { Cu } = require("chrome");
 const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
 const { EventEmitter } = Cu.import("resource://gre/modules/devtools/event-emitter.js");
-const { ConnectionManager } = require("devtools/client/connection-manager");
-const { AddonSimulatorProcess, OldAddonSimulatorProcess } = require("devtools/webide/simulator-process");
+loader.lazyRequireGetter(this, "ConnectionManager", "devtools/client/connection-manager", true);
+loader.lazyRequireGetter(this, "AddonSimulatorProcess", "devtools/webide/simulator-process", true);
+loader.lazyRequireGetter(this, "OldAddonSimulatorProcess", "devtools/webide/simulator-process", true);
 const promise = require("promise");
 
 const SimulatorRegExp = new RegExp(Services.prefs.getCharPref("devtools.webide.simulatorAddonRegExp"));
 
 let Simulators = {
   // TODO (Bug 1090949) Don't generate this list from installed simulator
   // addons, but instead implement a persistent list of user-configured
   // simulators.