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 // SampleMap implements HistogramSamples interface. It is used by the | 5 // SampleMap implements HistogramSamples interface. It is used by the |
6 // SparseHistogram class to store samples. | 6 // SparseHistogram class to store samples. |
7 | 7 |
8 #ifndef BASE_METRICS_SAMPLE_MAP_H_ | 8 #ifndef BASE_METRICS_SAMPLE_MAP_H_ |
9 #define BASE_METRICS_SAMPLE_MAP_H_ | 9 #define BASE_METRICS_SAMPLE_MAP_H_ |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/metrics/histogram_base.h" | 15 #include "base/metrics/histogram_base.h" |
16 #include "base/metrics/histogram_samples.h" | 16 #include "base/metrics/histogram_samples.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 | 19 |
20 class BASE_EXPORT_PRIVATE SampleMap : public HistogramSamples { | 20 class BASE_EXPORT_PRIVATE SampleMap : public HistogramSamples { |
21 public: | 21 public: |
22 SampleMap(); | 22 SampleMap(); |
23 virtual ~SampleMap(); | 23 virtual ~SampleMap(); |
24 | 24 |
25 // HistogramSamples implementation: | 25 // HistogramSamples implementation: |
26 virtual void Accumulate(HistogramBase::Sample value, | 26 void Accumulate(HistogramBase::Sample value, |
27 HistogramBase::Count count) OVERRIDE; | 27 HistogramBase::Count count) override; |
28 virtual HistogramBase::Count GetCount( | 28 virtual HistogramBase::Count GetCount( |
29 HistogramBase::Sample value) const OVERRIDE; | 29 HistogramBase::Sample value) const override; |
30 virtual HistogramBase::Count TotalCount() const OVERRIDE; | 30 HistogramBase::Count TotalCount() const override; |
31 virtual scoped_ptr<SampleCountIterator> Iterator() const OVERRIDE; | 31 scoped_ptr<SampleCountIterator> Iterator() const override; |
32 | 32 |
33 protected: | 33 protected: |
34 virtual bool AddSubtractImpl( | 34 bool AddSubtractImpl(SampleCountIterator* iter, HistogramSamples::Operator op) |
35 SampleCountIterator* iter, | 35 override; // |op| is ADD or SUBTRACT. |
36 HistogramSamples::Operator op) OVERRIDE; // |op| is ADD or SUBTRACT. | |
37 | 36 |
38 private: | 37 private: |
39 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_; | 38 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_; |
40 | 39 |
41 DISALLOW_COPY_AND_ASSIGN(SampleMap); | 40 DISALLOW_COPY_AND_ASSIGN(SampleMap); |
42 }; | 41 }; |
43 | 42 |
44 class BASE_EXPORT_PRIVATE SampleMapIterator : public SampleCountIterator { | 43 class BASE_EXPORT_PRIVATE SampleMapIterator : public SampleCountIterator { |
45 public: | 44 public: |
46 typedef std::map<HistogramBase::Sample, HistogramBase::Count> | 45 typedef std::map<HistogramBase::Sample, HistogramBase::Count> |
47 SampleToCountMap; | 46 SampleToCountMap; |
48 | 47 |
49 explicit SampleMapIterator(const SampleToCountMap& sample_counts); | 48 explicit SampleMapIterator(const SampleToCountMap& sample_counts); |
50 virtual ~SampleMapIterator(); | 49 virtual ~SampleMapIterator(); |
51 | 50 |
52 // SampleCountIterator implementation: | 51 // SampleCountIterator implementation: |
53 virtual bool Done() const OVERRIDE; | 52 bool Done() const override; |
54 virtual void Next() OVERRIDE; | 53 void Next() override; |
55 virtual void Get(HistogramBase::Sample* min, | 54 void Get(HistogramBase::Sample* min, |
56 HistogramBase::Sample* max, | 55 HistogramBase::Sample* max, |
57 HistogramBase::Count* count) const OVERRIDE; | 56 HistogramBase::Count* count) const override; |
| 57 |
58 private: | 58 private: |
59 SampleToCountMap::const_iterator iter_; | 59 SampleToCountMap::const_iterator iter_; |
60 const SampleToCountMap::const_iterator end_; | 60 const SampleToCountMap::const_iterator end_; |
61 }; | 61 }; |
62 | 62 |
63 } // namespace base | 63 } // namespace base |
64 | 64 |
65 #endif // BASE_METRICS_SAMPLE_MAP_H_ | 65 #endif // BASE_METRICS_SAMPLE_MAP_H_ |
OLD | NEW |