Bug 1012526 - UITour.jsm only registers with UITelemetry when it's lazily imported on-demand. r=mconley
authorBlair McBride <bmcbride@mozilla.com>
Wed, 21 May 2014 12:25:50 +1200
changeset 184107 f1bd861d8acf9bf102624a67101ff8541afb2f90
parent 184106 e641f0a7a21eb0c885552c1f27724a0e2e62ae48
child 184108 8d51c866de2c8eeeb3df52f30659471285b29fac
push id26811
push usercbook@mozilla.com
push dateWed, 21 May 2014 11:58:32 +0000
treeherdermozilla-central@97943ef127f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1012526
milestone32.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 1012526 - UITour.jsm only registers with UITelemetry when it's lazily imported on-demand. r=mconley
browser/modules/BrowserUITelemetry.jsm
browser/modules/UITour.jsm
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -12,16 +12,18 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry",
   "resource://gre/modules/UITelemetry.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
   "resource:///modules/RecentWindow.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
   "resource:///modules/CustomizableUI.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "UITour",
+  "resource:///modules/UITour.jsm");
 XPCOMUtils.defineLazyGetter(this, "Timer", function() {
   let timer = {};
   Cu.import("resource://gre/modules/Timer.jsm", timer);
   return timer;
 });
 
 const MS_SECOND = 1000;
 const MS_MINUTE = MS_SECOND * 60;
@@ -164,16 +166,21 @@ const BUCKET_PREFIX = "bucket_";
 // Standard separator to use between different parts of a bucket name, such
 // as primary name and the time step string.
 const BUCKET_SEPARATOR = "|";
 
 this.BrowserUITelemetry = {
   init: function() {
     UITelemetry.addSimpleMeasureFunction("toolbars",
                                          this.getToolbarMeasures.bind(this));
+    // Ensure that UITour.jsm remains lazy-loaded, yet always registers its
+    // simple measure function with UITelemetry.
+    UITelemetry.addSimpleMeasureFunction("UITour",
+                                         () => UITour.getTelemetry());
+
     Services.obs.addObserver(this, "sessionstore-windows-restored", false);
     Services.obs.addObserver(this, "browser-delayed-startup-finished", false);
     CustomizableUI.addListener(this);
   },
 
   observe: function(aSubject, aTopic, aData) {
     switch(aTopic) {
       case "sessionstore-windows-restored":
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -139,19 +139,16 @@ this.UITour = {
       configurable: true,
     });
 
     delete this.url;
     XPCOMUtils.defineLazyGetter(this, "url", function () {
       return Services.urlFormatter.formatURLPref("browser.uitour.url");
     });
 
-    UITelemetry.addSimpleMeasureFunction("UITour",
-                                         this.getTelemetry.bind(this));
-
     // Clear the availableTargetsCache on widget changes.
     let listenerMethods = [
       "onWidgetAdded",
       "onWidgetMoved",
       "onWidgetRemoved",
       "onWidgetReset",
       "onAreaReset",
     ];
@@ -536,16 +533,18 @@ this.UITour = {
   setExpiringTelemetryBucket: function(aPageID, aType) {
     let bucket = BUCKET_NAME + BrowserUITelemetry.BUCKET_SEPARATOR + aPageID +
                  BrowserUITelemetry.BUCKET_SEPARATOR + aType;
 
     BrowserUITelemetry.setExpiringBucket(bucket,
                                          BUCKET_TIMESTEPS);
   },
 
+  // This is registered with UITelemetry by BrowserUITelemetry, so that UITour
+  // can remain lazy-loaded on-demand.
   getTelemetry: function() {
     return {
       seenPageIDs: [...this.seenPageIDs.keys()],
     };
   },
 
   teardownTour: function(aWindow, aWindowClosing = false) {
     aWindow.gBrowser.tabContainer.removeEventListener("TabSelect", this);