Bug 1260908 - Allow keyed histograms to accumulate early in startup (r=gfritzsche)
☠☠ backed out by 37ee5a42ddb5 ☠ ☠
authorBill McCloskey <billm@mozilla.com>
Wed, 30 Mar 2016 15:25:18 -0700
changeset 291272 9612cef48d43ed208cd6c013e8245b03e553eb9a
parent 291271 6bd212fe9859a9bccab6df1e455b3a1d6168f74c
child 291273 5582a25d289de681271efd51a75ce5392f4b1639
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1260908
milestone48.0a1
Bug 1260908 - Allow keyed histograms to accumulate early in startup (r=gfritzsche)
toolkit/components/telemetry/Telemetry.cpp
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -698,16 +698,17 @@ class TelemetryImpl final
 {
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITELEMETRY
   NS_DECL_NSIMEMORYREPORTER
 
 public:
   void InitMemoryReporter();
 
+  static bool IsInitialized();
   static bool CanRecordBase();
   static bool CanRecordExtended();
   static already_AddRefed<nsITelemetry> CreateTelemetryInstance();
   static void ShutdownTelemetry();
   static void RecordSlowStatement(const nsACString &sql, const nsACString &dbName,
                                   uint32_t delay);
 #if defined(MOZ_ENABLE_PROFILER_SPS)
   static void RecordChromeHang(uint32_t aDuration,
@@ -3304,16 +3305,22 @@ TelemetryImpl::GetCanRecordBase(bool *re
 }
 
 NS_IMETHODIMP
 TelemetryImpl::SetCanRecordBase(bool canRecord) {
   mCanRecordBase = canRecord;
   return NS_OK;
 }
 
+/* static */ bool
+TelemetryImpl::IsInitialized() const
+{
+  return sTelemetry;
+}
+
 /**
  * Indicates if Telemetry can record base data (FHR data). This is true if the
  * FHR data reporting service or self-support are enabled.
  *
  * In the unlikely event that adding a new base probe is needed, please check the data
  * collection wiki at https://wiki.mozilla.org/Firefox/Data_Collection and talk to the
  * Telemetry team.
  */
@@ -3897,17 +3904,17 @@ Accumulate(ID aHistogram, uint32_t aSamp
   if (NS_SUCCEEDED(rv)) {
     HistogramAdd(*h, aSample, gHistograms[aHistogram].dataset);
   }
 }
 
 void
 Accumulate(ID aID, const nsCString& aKey, uint32_t aSample)
 {
-  if (!TelemetryImpl::CanRecordBase()) {
+  if (!TelemetryImpl::IsInitialized() || !TelemetryImpl::CanRecordBase()) {
     return;
   }
   const TelemetryHistogram& th = gHistograms[aID];
   KeyedHistogram* keyed = TelemetryImpl::GetKeyedHistogramById(nsDependentCString(th.id()));
   MOZ_ASSERT(keyed);
   keyed->Add(aKey, aSample);
 }