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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/sparse_histogram.h" 5 #include "base/metrics/sparse_histogram.h"
6 6
7 #include "base/metrics/sample_map.h" 7 #include "base/metrics/sample_map.h"
8 #include "base/metrics/statistics_recorder.h" 8 #include "base/metrics/statistics_recorder.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #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.
10 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
11 12
12 using std::map; 13 using std::map;
13 using std::string; 14 using std::string;
14 15
15 namespace base { 16 namespace base {
16 17
17 typedef HistogramBase::Count Count; 18 typedef HistogramBase::Count Count;
18 typedef HistogramBase::Sample Sample; 19 typedef HistogramBase::Sample Sample;
19 20
20 // static 21 // static
21 HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) { 22 HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) {
22 // TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder. 23 HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
23 HistogramBase* histogram = new SparseHistogram(name); 24
24 histogram->SetFlags(flags); 25 if (!histogram) {
26 // To avoid racy destruction at shutdown, the following will be leaked.
27 HistogramBase* tentative_histogram = new SparseHistogram(name);
28 tentative_histogram->SetFlags(flags);
29 histogram =
30 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
31 }
32 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.
25 return histogram; 33 return histogram;
26 } 34 }
27 35
28 SparseHistogram::~SparseHistogram() {} 36 SparseHistogram::~SparseHistogram() {}
29 37
30 HistogramType SparseHistogram::GetHistogramType() const { 38 HistogramType SparseHistogram::GetHistogramType() const {
31 return SPARSE_HISTOGRAM; 39 return SPARSE_HISTOGRAM;
32 } 40 }
33 41
34 bool SparseHistogram::HasConstructionArguments(Sample minimum, 42 bool SparseHistogram::HasConstructionArguments(Sample minimum,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void SparseHistogram::GetParameters(DictionaryValue* params) const { 101 void SparseHistogram::GetParameters(DictionaryValue* params) const {
94 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) 102 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.)
95 } 103 }
96 104
97 void SparseHistogram::GetCountAndBucketData(Count* count, 105 void SparseHistogram::GetCountAndBucketData(Count* count,
98 ListValue* buckets) const { 106 ListValue* buckets) const {
99 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) 107 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.)
100 } 108 }
101 109
102 } // namespace base 110 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698