Bug 1012526 - UITour.jsm only registers with UITelemetry when it's lazily imported on-demand. r=mconley a=lsblakk
authorBlair McBride <bmcbride@mozilla.com>
Wed, 21 May 2014 12:25:50 +1200
changeset 192355 b19932497b46
parent 192354 b7913b826440
child 192356 3090db8c413f
push id3582
push userbmcbride@mozilla.com
push date2014-05-22 09:07 +0000
treeherdermozilla-beta@b19932497b46 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, lsblakk
bugs1012526
milestone30.0
Bug 1012526 - UITour.jsm only registers with UITelemetry when it's lazily imported on-demand. r=mconley a=lsblakk
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;
@@ -165,16 +167,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);