OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // PersistentSampleMap implements HistogramSamples interface. It is used | 5 // PersistentSampleMap implements HistogramSamples interface. It is used |
6 // by the SparseHistogram class to store samples in persistent memory which | 6 // by the SparseHistogram class to store samples in persistent memory which |
7 // allows it to be shared between processes or live across restarts. | 7 // allows it to be shared between processes or live across restarts. |
8 | 8 |
9 #ifndef BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ | 9 #ifndef BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ |
10 #define BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ | 10 #define BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ |
11 | 11 |
12 #include <stdint.h> | 12 #include <stdint.h> |
13 | 13 |
14 #include <map> | 14 #include <map> |
| 15 #include <memory> |
15 | 16 |
16 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/scoped_ptr.h" | |
19 #include "base/metrics/histogram_base.h" | 19 #include "base/metrics/histogram_base.h" |
20 #include "base/metrics/histogram_samples.h" | 20 #include "base/metrics/histogram_samples.h" |
21 #include "base/metrics/persistent_memory_allocator.h" | 21 #include "base/metrics/persistent_memory_allocator.h" |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 | 24 |
25 // The logic here is similar to that of SampleMap but with different data | 25 // The logic here is similar to that of SampleMap but with different data |
26 // structures. Changes here likely need to be duplicated there. | 26 // structures. Changes here likely need to be duplicated there. |
27 class BASE_EXPORT PersistentSampleMap : public HistogramSamples { | 27 class BASE_EXPORT PersistentSampleMap : public HistogramSamples { |
28 public: | 28 public: |
29 PersistentSampleMap(uint64_t id, | 29 PersistentSampleMap(uint64_t id, |
30 PersistentMemoryAllocator* allocator, | 30 PersistentMemoryAllocator* allocator, |
31 Metadata* meta); | 31 Metadata* meta); |
32 ~PersistentSampleMap() override; | 32 ~PersistentSampleMap() override; |
33 | 33 |
34 // HistogramSamples: | 34 // HistogramSamples: |
35 void Accumulate(HistogramBase::Sample value, | 35 void Accumulate(HistogramBase::Sample value, |
36 HistogramBase::Count count) override; | 36 HistogramBase::Count count) override; |
37 HistogramBase::Count GetCount(HistogramBase::Sample value) const override; | 37 HistogramBase::Count GetCount(HistogramBase::Sample value) const override; |
38 HistogramBase::Count TotalCount() const override; | 38 HistogramBase::Count TotalCount() const override; |
39 scoped_ptr<SampleCountIterator> Iterator() const override; | 39 std::unique_ptr<SampleCountIterator> Iterator() const override; |
40 | 40 |
41 protected: | 41 protected: |
42 // Performs arithemetic. |op| is ADD or SUBTRACT. | 42 // Performs arithemetic. |op| is ADD or SUBTRACT. |
43 bool AddSubtractImpl(SampleCountIterator* iter, Operator op) override; | 43 bool AddSubtractImpl(SampleCountIterator* iter, Operator op) override; |
44 | 44 |
45 // Gets a pointer to a "count" corresponding to a given |value|. Returns NULL | 45 // Gets a pointer to a "count" corresponding to a given |value|. Returns NULL |
46 // if sample does not exist. | 46 // if sample does not exist. |
47 HistogramBase::Count* GetSampleCountStorage(HistogramBase::Sample value); | 47 HistogramBase::Count* GetSampleCountStorage(HistogramBase::Sample value); |
48 | 48 |
49 // Gets a pointer to a "count" corresponding to a given |value|, creating | 49 // Gets a pointer to a "count" corresponding to a given |value|, creating |
(...skipping 19 matching lines...) Expand all Loading... |
69 // The persistent memory allocator holding samples and an iterator through it. | 69 // The persistent memory allocator holding samples and an iterator through it. |
70 PersistentMemoryAllocator* allocator_; | 70 PersistentMemoryAllocator* allocator_; |
71 PersistentMemoryAllocator::Iterator sample_iter_; | 71 PersistentMemoryAllocator::Iterator sample_iter_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(PersistentSampleMap); | 73 DISALLOW_COPY_AND_ASSIGN(PersistentSampleMap); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace base | 76 } // namespace base |
77 | 77 |
78 #endif // BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ | 78 #endif // BASE_METRICS_PERSISTENT_SAMPLE_MAP_H_ |
OLD | NEW |