Bug 1260908 - Allow keyed histograms to accumulate early in startup. r=gfritzsche, a=ritu
authorBill McCloskey <billm@mozilla.com>
Wed, 30 Mar 2016 15:25:18 -0700
changeset 323945 5662624cb37150749cf0e28182b95c24f29fc8f7
parent 323944 74e3c3ac7049652b21d532fca2fc0a7f82e90a71
child 323946 e903ac1672b8fcca918772bcaa611b8648192720
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche, ritu
bugs1260908
milestone47.0a2
Bug 1260908 - Allow keyed histograms to accumulate early in startup. r=gfritzsche, a=ritu MozReview-Commit-ID: 4pVxMyOajB5
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,
@@ -3317,16 +3318,22 @@ TelemetryImpl::GetCanRecordBase(bool *re
 }
 
 NS_IMETHODIMP
 TelemetryImpl::SetCanRecordBase(bool canRecord) {
   mCanRecordBase = canRecord;
   return NS_OK;
 }
 
+/* static */ bool
+TelemetryImpl::IsInitialized()
+{
+  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.
  */
@@ -3910,17 +3917,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);
 }