Bug 1166897 - Make telemetry more B2G friendly r=gfritzsche a=sledru
authorFabrice Desré <fabrice@mozilla.com>
Thu, 21 May 2015 10:15:19 -0700
changeset 275134 be983703a966c56dc345b1f02d465ca7d8ce133f
parent 275133 cbb2aac0a8e570da3bf2e4e8dd2787052333182b
child 275135 c8f4915ec89c54d053181ffc6aab7cd1e74feff8
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche, sledru
bugs1166897
milestone40.0a2
Bug 1166897 - Make telemetry more B2G friendly r=gfritzsche a=sledru
toolkit/components/telemetry/TelemetryEnvironment.jsm
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -6,28 +6,28 @@
 
 this.EXPORTED_SYMBOLS = [
   "TelemetryEnvironment",
 ];
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 const myScope = this;
 
-Cu.import("resource://gre/modules/AddonManager.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/PromiseUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/ObjectUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "ctypes",
                                   "resource://gre/modules/ctypes.jsm");
 #ifndef MOZ_WIDGET_GONK
+Cu.import("resource://gre/modules/AddonManager.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
                                   "resource://gre/modules/LightweightThemeManager.jsm");
 #endif
 XPCOMUtils.defineLazyModuleGetter(this, "ProfileAge",
                                   "resource://gre/modules/ProfileAge.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel",
                                   "resource://gre/modules/UpdateChannel.jsm");
 
@@ -43,17 +43,17 @@ let Policy = {
 var gGlobalEnvironment;
 function getGlobal() {
   if (!gGlobalEnvironment) {
     gGlobalEnvironment = new EnvironmentCache();
   }
   return gGlobalEnvironment;
 }
 
-const TelemetryEnvironment = {
+this.TelemetryEnvironment = {
   get currentEnvironment() {
     return getGlobal().currentEnvironment;
   },
 
   onInitialized: function() {
     return getGlobal().onInitialized();
   },
 
@@ -654,19 +654,26 @@ function EnvironmentCache() {
 
   this._updateSettings();
   // Fill in the default search engine, if the search provider is already initialized.
   this._updateSearchEngine();
 
   // Build the remaining asynchronous parts of the environment. Don't register change listeners
   // until the initial environment has been built.
 
+#ifdef MOZ_WIDGET_GONK
+  this._addonBuilder = {
+    watchForChanges: function() {}
+  }
+  let p = [];
+#else
   this._addonBuilder = new EnvironmentAddonBuilder(this);
 
   let p = [ this._addonBuilder.init() ];
+#endif
 #ifndef MOZ_WIDGET_ANDROID
   this._currentEnvironment.profile = {};
   p.push(this._updateProfile());
 #endif
 
   let setup = () => {
     this._initTask = null;
     this._startWatchingPrefs();
@@ -915,16 +922,19 @@ EnvironmentCache.prototype = {
     return buildData;
   },
 
   /**
    * Determine if Firefox is the default browser.
    * @returns null on error, true if we are the default browser, or false otherwise.
    */
   _isDefaultBrowser: function () {
+#ifdef MOZ_WIDGET_GONK
+    return true;
+#else
     if (!("@mozilla.org/browser/shell-service;1" in Cc)) {
       this._log.error("_isDefaultBrowser - Could not obtain shell service");
       return null;
     }
 
     let shellService;
     try {
       shellService = Cc["@mozilla.org/browser/shell-service;1"]
@@ -940,16 +950,17 @@ EnvironmentCache.prototype = {
         return shellService.isDefaultBrowser(false, true) ? true : false;
       } catch (ex) {
         this._log.error("_isDefaultBrowser - Could not determine if default browser", ex);
         return null;
       }
     }
 
     return null;
+#endif
   },
 
   /**
    * Update the cached settings data.
    */
   _updateSettings: function () {
     let updateChannel = null;
     try {