| OLD | NEW |
| 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/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 | 10 |
| 11 using std::map; | 11 using std::map; |
| 12 using std::string; | 12 using std::string; |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 | 15 |
| 16 typedef HistogramBase::Count Count; | 16 typedef HistogramBase::Count Count; |
| 17 typedef HistogramBase::Sample Sample; | 17 typedef HistogramBase::Sample Sample; |
| 18 | 18 |
| 19 // static | 19 // static |
| 20 HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) { | 20 HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) { |
| 21 // TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder. | 21 // TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder. |
| 22 HistogramBase* histogram = new SparseHistogram(name); | 22 HistogramBase* histogram = new SparseHistogram(name); |
| 23 histogram->SetFlags(flags); | 23 histogram->SetFlags(flags); |
| 24 return histogram; | 24 return histogram; |
| 25 } | 25 } |
| 26 | 26 |
| 27 SparseHistogram::~SparseHistogram() {} | 27 SparseHistogram::~SparseHistogram() {} |
| 28 | 28 |
| 29 HistogramType SparseHistogram::GetHistogramType() const { |
| 30 return SPARSE_HISTOGRAM; |
| 31 } |
| 32 |
| 29 bool SparseHistogram::HasConstructionArguments(Sample minimum, | 33 bool SparseHistogram::HasConstructionArguments(Sample minimum, |
| 30 Sample maximum, | 34 Sample maximum, |
| 31 size_t bucket_count) const { | 35 size_t bucket_count) const { |
| 32 // SparseHistogram never has min/max/bucket_count limit. | 36 // SparseHistogram never has min/max/bucket_count limit. |
| 33 return false; | 37 return false; |
| 34 } | 38 } |
| 35 | 39 |
| 36 void SparseHistogram::Add(Sample value) { | 40 void SparseHistogram::Add(Sample value) { |
| 37 base::AutoLock auto_lock(lock_); | 41 base::AutoLock auto_lock(lock_); |
| 38 sample_counts_[value]++; | 42 sample_counts_[value]++; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 67 void SparseHistogram::GetParameters(DictionaryValue* params) const { | 71 void SparseHistogram::GetParameters(DictionaryValue* params) const { |
| 68 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) | 72 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) |
| 69 } | 73 } |
| 70 | 74 |
| 71 void SparseHistogram::GetCountAndBucketData(Count* count, | 75 void SparseHistogram::GetCountAndBucketData(Count* count, |
| 72 ListValue* buckets) const { | 76 ListValue* buckets) const { |
| 73 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) | 77 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) |
| 74 } | 78 } |
| 75 | 79 |
| 76 } // namespace base | 80 } // namespace base |
| OLD | NEW |