Bug 1209458 - Replace HISTOGRAM_FILE_VERSION preprocessor usage with AppConstants.jsm definitions. r=ted,gfritzsche
authorIaroslav (yarik) Sheptykin <yarik.sheptykin@googlemail.com>
Thu, 01 Oct 2015 10:18:10 +0200
changeset 268206 34b1b7b2c8714c9a0a9ea73551b79ae8a7045eae
parent 268205 b969d7c0af78c4487fa9dbcdeecfb8d1d65af6c4
child 268207 9da222c758b8136abd8e51ff16c798f910df4016
push id15745
push usercbook@mozilla.com
push dateMon, 19 Oct 2015 06:28:58 +0000
treeherderfx-team@34b1b7b2c871 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, gfritzsche
bugs1209458
milestone44.0a1
Bug 1209458 - Replace HISTOGRAM_FILE_VERSION preprocessor usage with AppConstants.jsm definitions. r=ted,gfritzsche
configure.in
toolkit/components/telemetry/Makefile.in
toolkit/components/telemetry/TelemetrySession.jsm
toolkit/components/telemetry/moz.build
toolkit/modules/AppConstants.jsm
toolkit/modules/moz.build
--- a/configure.in
+++ b/configure.in
@@ -8772,16 +8772,28 @@ AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
 
 AC_SUBST(MOZILLA_OFFICIAL)
 if test "$MOZILLA_OFFICIAL"; then
     AC_DEFINE(MOZILLA_OFFICIAL)
     # Build revisions should always be present in official builds
     MOZ_INCLUDE_SOURCE_INFO=1
 fi
 
+# On official builds, we need to know in Telemetry what revision this is built from.
+# This is e.g. needed to match incoming data to a specific revision of the Histograms.json
+# file.
+if test "$MOZILLA_OFFICIAL" && test -d ${_topsrcdir}/.hg; then
+  SOURCE_REV=`cd $_topsrcdir && hg parent --template='{node|short}'`
+  SOURCE_REPO=`cd $_topsrcdir && hg showconfig paths.default | sed -e 's|^ssh://|http://|' -e 's|/$||'`
+  SOURCE_REV_URL=$SOURCE_REPO/rev/$SOURCE_REV
+else
+  SOURCE_REV_URL=
+fi
+AC_SUBST(SOURCE_REV_URL)
+
 AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
 
 AC_DEFINE_UNQUOTED(MOZ_TELEMETRY_DISPLAY_REV, 2)
 AC_SUBST(MOZ_TELEMETRY_DISPLAY_REV)
 
 if test "$MOZ_TELEMETRY_REPORTING"; then
     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
 
--- a/toolkit/components/telemetry/Makefile.in
+++ b/toolkit/components/telemetry/Makefile.in
@@ -1,23 +1,16 @@
 #
 # 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/.
 
 USE_RCS_MK := 1
 include $(topsrcdir)/config/makefiles/rcs.mk
 
-ifdef MOZILLA_OFFICIAL
-MOZ_HISTOGRAMS_VERSION ?= $(call getSourceRepo)/rev/$(firstword $(shell hg -R $(topsrcdir) parent --template='{node|short}\n' 2>/dev/null))
-ifdef MOZ_HISTOGRAMS_VERSION
-DEFINES += -DHISTOGRAMS_FILE_VERSION='$(MOZ_HISTOGRAMS_VERSION)'
-endif
-endif
-
 INSTALL_TARGETS += histoenums
 histoenums_FILES := TelemetryHistogramEnums.h
 histoenums_DEST = $(DIST)/include/mozilla
 histoenums_TARGET := export
 
 include $(topsrcdir)/config/rules.mk
 
 # This is so hacky. Waiting on bug 988938.
--- a/toolkit/components/telemetry/TelemetrySession.jsm
+++ b/toolkit/components/telemetry/TelemetrySession.jsm
@@ -42,20 +42,16 @@ const REASON_TEST_PING = "test-ping";
 const REASON_ENVIRONMENT_CHANGE = "environment-change";
 const REASON_SHUTDOWN = "shutdown";
 
 const ENVIRONMENT_CHANGE_LISTENER = "TelemetrySession::onEnvironmentChange";
 
 const MS_IN_ONE_HOUR  = 60 * 60 * 1000;
 const MIN_SUBSESSION_LENGTH_MS = Preferences.get("toolkit.telemetry.minSubsessionLength", 10 * 60) * 1000;
 
-// This is the HG changeset of the Histogram.json file, used to associate
-// submitted ping data with its histogram definition (bug 832007)
-#expand const HISTOGRAMS_FILE_VERSION = "__HISTOGRAMS_FILE_VERSION__";
-
 const LOGGER_NAME = "Toolkit.Telemetry";
 const LOGGER_PREFIX = "TelemetrySession" + (Utils.isContentProcess ? "#content::" : "::");
 
 const PREF_BRANCH = "toolkit.telemetry.";
 const PREF_PREVIOUS_BUILDID = PREF_BRANCH + "previousBuildID";
 const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
 const PREF_ASYNC_PLUGIN_INIT = "dom.ipc.plugins.asyncInit.enabled";
 const PREF_UNIFIED = PREF_BRANCH + "unified";
@@ -1039,17 +1035,17 @@ var Impl = {
     this._log.trace("getMetadata - Reason " + reason);
 
     const sessionStartDate = toLocalTimeISOString(Utils.truncateToDays(this._sessionStartDate));
     const subsessionStartDate = toLocalTimeISOString(Utils.truncateToDays(this._subsessionStartDate));
     const monotonicNow = Policy.monotonicNow();
 
     let ret = {
       reason: reason,
-      revision: HISTOGRAMS_FILE_VERSION,
+      revision: AppConstants.SOURCE_REVISION_URL,
       asyncPluginInit: Preferences.get(PREF_ASYNC_PLUGIN_INIT, false),
 
       // Date.getTimezoneOffset() unintuitively returns negative values if we are ahead of
       // UTC and vice versa (e.g. -60 for UTC+1). We invert the sign here.
       timezoneOffset: -this._subsessionStartDate.getTimezoneOffset(),
       previousBuildId: this._previousBuildId,
 
       sessionId: this._sessionId,
--- a/toolkit/components/telemetry/moz.build
+++ b/toolkit/components/telemetry/moz.build
@@ -31,27 +31,24 @@ EXTRA_COMPONENTS += [
 
 EXTRA_JS_MODULES += [
     'TelemetryArchive.jsm',
     'TelemetryController.jsm',
     'TelemetryEnvironment.jsm',
     'TelemetryLog.jsm',
     'TelemetryReportingPolicy.jsm',
     'TelemetrySend.jsm',
+    'TelemetrySession.jsm',
     'TelemetryStopwatch.jsm',
     'TelemetryStorage.jsm',
     'TelemetryUtils.jsm',
     'ThirdPartyCookieProbe.jsm',
     'UITelemetry.jsm',
 ]
 
-EXTRA_PP_JS_MODULES += [
-    'TelemetrySession.jsm',
-]
-
 TESTING_JS_MODULES += [
   'tests/unit/TelemetryArchiveTesting.jsm',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -218,10 +218,15 @@ this.AppConstants = Object.freeze({
   ANDROID_PACKAGE_NAME: "@ANDROID_PACKAGE_NAME@",
 
   MOZ_ANDROID_APZ:
 #ifdef MOZ_ANDROID_APZ
     true,
 #else
     false,
 #endif
-  DEBUG_JS_MODULES: "@DEBUG_JS_MODULES@"
+  DEBUG_JS_MODULES: "@DEBUG_JS_MODULES@",
+
+  // URL to the hg revision this was built from (e.g.
+  // "https://hg.mozilla.org/mozilla-central/rev/6256ec9113c1")
+  // On unofficial builds, this is an empty string.
+  SOURCE_REVISION_URL: "@SOURCE_REV_URL@"
 });
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -102,15 +102,16 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind
 
 for var in ('ANDROID_PACKAGE_NAME',
             'MOZ_APP_NAME',
             'MOZ_APP_VERSION',
             'MOZ_APP_VERSION_DISPLAY',
             'MOZ_WIDGET_TOOLKIT',
             'DLL_PREFIX',
             'DLL_SUFFIX',
-            'DEBUG_JS_MODULES'):
+            'DEBUG_JS_MODULES',
+            'SOURCE_REV_URL'):
             DEFINES[var] = CONFIG[var]
 
 for var in ('MOZ_TOOLKIT_SEARCH',
             'MOZ_UPDATER'):
     if CONFIG[var]:
         DEFINES[var] = True