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 <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <map> | 13 #include <map> |
| 14 #include <memory> |
14 | 15 |
15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "base/metrics/histogram_base.h" | 18 #include "base/metrics/histogram_base.h" |
19 #include "base/metrics/histogram_samples.h" | 19 #include "base/metrics/histogram_samples.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 | 22 |
23 // The logic here is similar to that of PersistentSampleMap but with different | 23 // The logic here is similar to that of PersistentSampleMap but with different |
24 // data structures. Changes here likely need to be duplicated there. | 24 // data structures. Changes here likely need to be duplicated there. |
25 class BASE_EXPORT SampleMap : public HistogramSamples { | 25 class BASE_EXPORT SampleMap : public HistogramSamples { |
26 public: | 26 public: |
27 SampleMap(); | 27 SampleMap(); |
28 explicit SampleMap(uint64_t id); | 28 explicit SampleMap(uint64_t id); |
29 ~SampleMap() override; | 29 ~SampleMap() override; |
30 | 30 |
31 // HistogramSamples: | 31 // HistogramSamples: |
32 void Accumulate(HistogramBase::Sample value, | 32 void Accumulate(HistogramBase::Sample value, |
33 HistogramBase::Count count) override; | 33 HistogramBase::Count count) override; |
34 HistogramBase::Count GetCount(HistogramBase::Sample value) const override; | 34 HistogramBase::Count GetCount(HistogramBase::Sample value) const override; |
35 HistogramBase::Count TotalCount() const override; | 35 HistogramBase::Count TotalCount() const override; |
36 scoped_ptr<SampleCountIterator> Iterator() const override; | 36 std::unique_ptr<SampleCountIterator> Iterator() const override; |
37 | 37 |
38 protected: | 38 protected: |
39 // Performs arithemetic. |op| is ADD or SUBTRACT. | 39 // Performs arithemetic. |op| is ADD or SUBTRACT. |
40 bool AddSubtractImpl(SampleCountIterator* iter, Operator op) override; | 40 bool AddSubtractImpl(SampleCountIterator* iter, Operator op) override; |
41 | 41 |
42 private: | 42 private: |
43 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_; | 43 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_; |
44 | 44 |
45 DISALLOW_COPY_AND_ASSIGN(SampleMap); | 45 DISALLOW_COPY_AND_ASSIGN(SampleMap); |
46 }; | 46 }; |
47 | 47 |
48 } // namespace base | 48 } // namespace base |
49 | 49 |
50 #endif // BASE_METRICS_SAMPLE_MAP_H_ | 50 #endif // BASE_METRICS_SAMPLE_MAP_H_ |
OLD | NEW |