Backed out changeset 96d6f014fda9 (bug 1162538)
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Fri, 29 May 2015 14:40:33 +0200
changeset 246275 8f69b7de3293accfd694978d7172baa8b69220c8
parent 246274 52bb09691b8acbe53ac9151aff5625b035e0ae4f
child 246276 ef0dcec0103aa3fdb067bc91c28e161edc719a6d
push id28825
push userryanvm@gmail.com
push dateFri, 29 May 2015 20:56:27 +0000
treeherdermozilla-central@164a9a5ab7c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1162538
milestone41.0a1
backs out96d6f014fda9dc55834d0e107a0c1f54466c0b41
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
Backed out changeset 96d6f014fda9 (bug 1162538)
toolkit/components/telemetry/TelemetryEnvironment.jsm
toolkit/components/telemetry/TelemetryUtils.jsm
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -12,21 +12,18 @@ const {classes: Cc, interfaces: Ci, util
 const myScope = this;
 
 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/TelemetryUtils.jsm", this);
 Cu.import("resource://gre/modules/ObjectUtils.jsm");
 
-const Utils = TelemetryUtils;
-
 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",
@@ -149,21 +146,33 @@ const PREF_DISTRIBUTOR_CHANNEL = "app.di
 const PREF_E10S_ENABLED = "browser.tabs.remote.autostart";
 const PREF_HOTFIX_LASTVERSION = "extensions.hotfix.lastVersion";
 const PREF_APP_PARTNER_BRANCH = "app.partner.";
 const PREF_PARTNER_ID = "mozilla.partner.id";
 const PREF_TELEMETRY_ENABLED = "toolkit.telemetry.enabled";
 const PREF_UPDATE_ENABLED = "app.update.enabled";
 const PREF_UPDATE_AUTODOWNLOAD = "app.update.auto";
 
+const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
+
 const EXPERIMENTS_CHANGED_TOPIC = "experiments-changed";
 const SEARCH_ENGINE_MODIFIED_TOPIC = "browser-search-engine-modified";
 const SEARCH_SERVICE_TOPIC = "browser-search-service";
 
 /**
+ * Turn a millisecond timestamp into a day timestamp.
+ *
+ * @param aMsec a number of milliseconds since epoch.
+ * @return the number of whole days denoted by the input.
+ */
+function truncateToDays(aMsec) {
+  return Math.floor(aMsec / MILLISECONDS_PER_DAY);
+}
+
+/**
  * Get the current browser.
  * @return a string with the locale or null on failure.
  */
 function getBrowserLocale() {
   try {
     return Cc["@mozilla.org/chrome/chrome-registry;1"].
              getService(Ci.nsIXULChromeRegistry).
              getSelectedLocale('global');
@@ -488,18 +497,18 @@ EnvironmentAddonBuilder.prototype = {
         name: addon.name,
         userDisabled: addon.userDisabled,
         appDisabled: addon.appDisabled,
         version: addon.version,
         scope: addon.scope,
         type: addon.type,
         foreignInstall: addon.foreignInstall,
         hasBinaryComponents: addon.hasBinaryComponents,
-        installDay: Utils.millisecondsToDays(installDate.getTime()),
-        updateDay: Utils.millisecondsToDays(updateDate.getTime()),
+        installDay: truncateToDays(installDate.getTime()),
+        updateDay: truncateToDays(updateDate.getTime()),
       };
     }
 
     return activeAddons;
   }),
 
   /**
    * Get the currently active theme data in object form.
@@ -523,18 +532,18 @@ EnvironmentAddonBuilder.prototype = {
         description: theme.description,
         name: theme.name,
         userDisabled: theme.userDisabled,
         appDisabled: theme.appDisabled,
         version: theme.version,
         scope: theme.scope,
         foreignInstall: theme.foreignInstall,
         hasBinaryComponents: theme.hasBinaryComponents,
-        installDay: Utils.millisecondsToDays(installDate.getTime()),
-        updateDay: Utils.millisecondsToDays(updateDate.getTime()),
+        installDay: truncateToDays(installDate.getTime()),
+        updateDay: truncateToDays(updateDate.getTime()),
       };
     }
 
     return activeTheme;
   }),
 
   /**
    * Get the plugins data in object form.
@@ -557,17 +566,17 @@ EnvironmentAddonBuilder.prototype = {
       activePlugins.push({
         name: tag.name,
         version: tag.version,
         description: tag.description,
         blocklisted: tag.blocklisted,
         disabled: tag.disabled,
         clicktoplay: tag.clicktoplay,
         mimeTypes: tag.getMimeTypes({}),
-        updateDay: Utils.millisecondsToDays(updateDate.getTime()),
+        updateDay: truncateToDays(updateDate.getTime()),
       });
     }
 
     return activePlugins;
   },
 
   /**
    * Get the GMPlugins data in object form.
@@ -989,20 +998,19 @@ EnvironmentCache.prototype = {
   _updateProfile: Task.async(function* () {
     const logger = Log.repository.getLoggerWithMessagePrefix(LOGGER_NAME, "ProfileAge - ");
     let profileAccessor = new ProfileAge(null, logger);
 
     let creationDate = yield profileAccessor.created;
     let resetDate = yield profileAccessor.reset;
 
     this._currentEnvironment.profile.creationDate =
-      Utils.millisecondsToDays(creationDate);
+      truncateToDays(creationDate);
     if (resetDate) {
-      this._currentEnvironment.profile.resetDate =
-        Utils.millisecondsToDays(resetDate);
+      this._currentEnvironment.profile.resetDate = truncateToDays(resetDate);
     }
   }),
 
   /**
    * Get the partner data in object form.
    * @return Object containing the partner data.
    */
   _getPartner: function () {
--- a/toolkit/components/telemetry/TelemetryUtils.jsm
+++ b/toolkit/components/telemetry/TelemetryUtils.jsm
@@ -5,30 +5,18 @@
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
   "TelemetryUtils"
 ];
 
 const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
 
-const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
-
 this.TelemetryUtils = {
   /**
-   * Turn a millisecond timestamp into a day timestamp.
-   *
-   * @param aMsec A number of milliseconds since Unix epoch.
-   * @return The number of whole days since Unix epoch.
-   */
-  millisecondsToDays: function(aMsec) {
-    return Math.floor(aMsec / MILLISECONDS_PER_DAY);
-  },
-
-  /**
    * Takes a date and returns it trunctated to a date with daily precision.
    */
   truncateToDays: function(date) {
     return new Date(date.getFullYear(),
                     date.getMonth(),
                     date.getDate(),
                     0, 0, 0, 0);
   },