Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1540)

Unified Diff: base/metrics/sparse_histogram.cc

Issue 12207058: Connect SparseHistogram with the rest of stats system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix and add tests Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/metrics/sparse_histogram.cc
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc
index c64f7cb1c649dff13de20a8a9ed04e3a320a1973..296c0179ab23ae279e541251843270bd1bc6c473 100644
--- a/base/metrics/sparse_histogram.cc
+++ b/base/metrics/sparse_histogram.cc
@@ -7,6 +7,7 @@
#include "base/metrics/sample_map.h"
#include "base/metrics/statistics_recorder.h"
#include "base/pickle.h"
+#include "base/stringprintf.h"
Ilya Sherman 2013/02/21 05:36:06 nit: Doesn't look like this is needed.
kaiwang 2013/02/27 04:39:42 Done.
#include "base/synchronization/lock.h"
using std::map;
@@ -19,9 +20,16 @@ typedef HistogramBase::Sample Sample;
// static
HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) {
- // TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder.
- HistogramBase* histogram = new SparseHistogram(name);
- histogram->SetFlags(flags);
+ HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
+
+ if (!histogram) {
+ // To avoid racy destruction at shutdown, the following will be leaked.
+ HistogramBase* tentative_histogram = new SparseHistogram(name);
+ tentative_histogram->SetFlags(flags);
+ histogram =
+ StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
+ }
+ CHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType());
Ilya Sherman 2013/02/21 05:36:06 nit: DCHECK_EQ
kaiwang 2013/02/27 04:39:42 This is following histogram.h Seems this kind of e
Ilya Sherman 2013/02/28 00:29:56 They shouldn't be. It would be good to fix histog
kaiwang 2013/02/28 04:58:05 Done.
return histogram;
}

Powered by Google App Engine
This is Rietveld 408576698