Backed out changeset fb40775d1451 (bug 1366294)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 21 Jul 2017 15:19:26 +0200
changeset 418925 e87d51f223d9bf9ff03a6dfcef7e949945c1a098
parent 418924 2c1ee57abd493421609a89e40aeb44702859ecc1
child 418926 724d5d0cef066e4716af07ba8f60ac65703c33cc
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1366294
milestone56.0a1
backs outfb40775d14517a387f3520e59515e119c70f2830
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 fb40775d1451 (bug 1366294)
toolkit/components/telemetry/TelemetryHistogram.cpp
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -137,17 +137,16 @@ enum class SessionType {
   Session = 0,
   Subsession = 1,
   Count,
 };
 
 class KeyedHistogram {
 public:
   KeyedHistogram(HistogramID id, const HistogramInfo& info);
-  ~KeyedHistogram();
   nsresult GetHistogram(const nsCString& name, Histogram** histogram, bool subsession);
   Histogram* GetHistogram(const nsCString& name, bool subsession);
   uint32_t GetHistogramType() const { return mHistogramInfo.histogramType; }
   nsresult GetJSKeys(JSContext* cx, JS::CallArgs& args);
   nsresult GetJSSnapshot(JSContext* cx, JS::Handle<JSObject*> obj,
                          bool subsession, bool clearSubsession);
 
   nsresult Add(const nsCString& key, uint32_t aSample, ProcessID aProcessType);
@@ -638,31 +637,16 @@ KeyedHistogram::KeyedHistogram(Histogram
 #if !defined(MOZ_WIDGET_ANDROID)
   , mSubsessionMap()
 #endif
   , mId(id)
   , mHistogramInfo(info)
 {
 }
 
-KeyedHistogram::~KeyedHistogram()
-{
-  for (auto iter = mHistogramMap.Iter(); !iter.Done(); iter.Next()) {
-    delete iter.Get()->mData;
-  }
-  mHistogramMap.Clear();
-
-#if !defined(MOZ_WIDGET_ANDROID)
-  for (auto iter = mSubsessionMap.Iter(); !iter.Done(); iter.Next()) {
-    delete iter.Get()->mData;
-  }
-  mSubsessionMap.Clear();
-#endif
-}
-
 nsresult
 KeyedHistogram::GetHistogram(const nsCString& key, Histogram** histogram,
                              bool subsession)
 {
 #if !defined(MOZ_WIDGET_ANDROID)
   KeyedHistogramMapType& map = subsession ? mSubsessionMap : mHistogramMap;
 #else
   KeyedHistogramMapType& map = mHistogramMap;
@@ -738,26 +722,26 @@ void
 KeyedHistogram::Clear(bool onlySubsession)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
   if (!XRE_IsParentProcess()) {
     return;
   }
 #if !defined(MOZ_WIDGET_ANDROID)
   for (auto iter = mSubsessionMap.Iter(); !iter.Done(); iter.Next()) {
-    delete iter.Get()->mData;
+    iter.Get()->mData->Clear();
   }
   mSubsessionMap.Clear();
   if (onlySubsession) {
     return;
   }
 #endif
 
   for (auto iter = mHistogramMap.Iter(); !iter.Done(); iter.Next()) {
-    delete iter.Get()->mData;
+    iter.Get()->mData->Clear();
   }
   mHistogramMap.Clear();
 }
 
 nsresult
 KeyedHistogram::GetJSKeys(JSContext* cx, JS::CallArgs& args)
 {
   JS::AutoValueVector keys(cx);
@@ -1641,34 +1625,16 @@ void TelemetryHistogram::InitializeGloba
 
 void TelemetryHistogram::DeInitializeGlobalState()
 {
   StaticMutexAutoLock locker(gTelemetryHistogramMutex);
   gCanRecordBase = false;
   gCanRecordExtended = false;
   gNameToHistogramIDMap.Clear();
   gInitDone = false;
-
-  // FactoryGet `new`s Histograms for us, but requires us to manually delete.
-  for (size_t i = 0; i < HistogramCount; ++i) {
-    for (uint32_t process = 0; process < static_cast<uint32_t>(ProcessID::Count); ++process) {
-      delete gKeyedHistogramStorage[i][process];
-      gKeyedHistogramStorage[i][process] = nullptr;
-      for (uint32_t session = 0; session <
-        static_cast<uint32_t>(SessionType::Count); ++session) {
-        if (gHistogramStorage[i][process][session] == gExpiredHistogram) {
-          continue;
-        }
-        delete gHistogramStorage[i][process][session];
-        gHistogramStorage[i][process][session] = nullptr;
-      }
-    }
-  }
-  delete gExpiredHistogram;
-  gExpiredHistogram = nullptr;
 }
 
 #ifdef DEBUG
 bool TelemetryHistogram::GlobalStateHasBeenInitialized() {
   StaticMutexAutoLock locker(gTelemetryHistogramMutex);
   return gInitDone;
 }
 #endif