| 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 bool SparseHistogram::HasConstructionArguments(Sample minimum, |
| 30 Sample maximum, |
| 31 size_t bucket_count) const { |
| 32 // SparseHistogram never has min/max/bucket_count limit. |
| 33 return false; |
| 34 } |
| 35 |
| 29 void SparseHistogram::Add(Sample value) { | 36 void SparseHistogram::Add(Sample value) { |
| 30 base::AutoLock auto_lock(lock_); | 37 base::AutoLock auto_lock(lock_); |
| 31 sample_counts_[value]++; | 38 sample_counts_[value]++; |
| 32 redundant_count_ += 1; | 39 redundant_count_ += 1; |
| 33 } | 40 } |
| 34 | 41 |
| 35 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { | 42 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { |
| 36 scoped_ptr<SampleMap> snapshot(new SampleMap()); | 43 scoped_ptr<SampleMap> snapshot(new SampleMap()); |
| 37 | 44 |
| 38 base::AutoLock auto_lock(lock_); | 45 base::AutoLock auto_lock(lock_); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 60 void SparseHistogram::GetParameters(DictionaryValue* params) const { | 67 void SparseHistogram::GetParameters(DictionaryValue* params) const { |
| 61 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) | 68 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) |
| 62 } | 69 } |
| 63 | 70 |
| 64 void SparseHistogram::GetCountAndBucketData(Count* count, | 71 void SparseHistogram::GetCountAndBucketData(Count* count, |
| 65 ListValue* buckets) const { | 72 ListValue* buckets) const { |
| 66 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) | 73 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) |
| 67 } | 74 } |
| 68 | 75 |
| 69 } // namespace base | 76 } // namespace base |
| OLD | NEW |