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 #ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_ | 5 #ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_ |
6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_ | 6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Likewise Sqlite.Error.* are SPARSE, because most databases generate few or no | 44 // Likewise Sqlite.Error.* are SPARSE, because most databases generate few or no |
45 // errors and there are large gaps in the set of possible errors. | 45 // errors and there are large gaps in the set of possible errors. |
46 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ | 46 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ |
47 do { \ | 47 do { \ |
48 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ | 48 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ |
49 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ | 49 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ |
50 histogram->Add(sample); \ | 50 histogram->Add(sample); \ |
51 } while (0) | 51 } while (0) |
52 | 52 |
53 class HistogramSamples; | 53 class HistogramSamples; |
54 class PersistentMemoryAllocator; | 54 class PersistentHistogramAllocator; |
55 | 55 |
56 class BASE_EXPORT SparseHistogram : public HistogramBase { | 56 class BASE_EXPORT SparseHistogram : public HistogramBase { |
57 public: | 57 public: |
58 // If there's one with same name, return the existing one. If not, create a | 58 // If there's one with same name, return the existing one. If not, create a |
59 // new one. | 59 // new one. |
60 static HistogramBase* FactoryGet(const std::string& name, int32_t flags); | 60 static HistogramBase* FactoryGet(const std::string& name, int32_t flags); |
61 | 61 |
62 // Create a histogram using data in persistent storage. | 62 // Create a histogram using data in persistent storage. |
63 static std::unique_ptr<HistogramBase> PersistentCreate( | 63 static std::unique_ptr<HistogramBase> PersistentCreate( |
64 PersistentMemoryAllocator* allocator, | 64 PersistentHistogramAllocator* allocator, |
65 const std::string& name, | 65 const std::string& name, |
66 HistogramSamples::Metadata* meta, | 66 HistogramSamples::Metadata* meta, |
67 HistogramSamples::Metadata* logged_meta); | 67 HistogramSamples::Metadata* logged_meta); |
68 | 68 |
69 ~SparseHistogram() override; | 69 ~SparseHistogram() override; |
70 | 70 |
71 // HistogramBase implementation: | 71 // HistogramBase implementation: |
72 uint64_t name_hash() const override; | 72 uint64_t name_hash() const override; |
73 HistogramType GetHistogramType() const override; | 73 HistogramType GetHistogramType() const override; |
74 bool HasConstructionArguments(Sample expected_minimum, | 74 bool HasConstructionArguments(Sample expected_minimum, |
75 Sample expected_maximum, | 75 Sample expected_maximum, |
76 uint32_t expected_bucket_count) const override; | 76 uint32_t expected_bucket_count) const override; |
77 void Add(Sample value) override; | 77 void Add(Sample value) override; |
78 void AddCount(Sample value, int count) override; | 78 void AddCount(Sample value, int count) override; |
79 void AddSamples(const HistogramSamples& samples) override; | 79 void AddSamples(const HistogramSamples& samples) override; |
80 bool AddSamplesFromPickle(base::PickleIterator* iter) override; | 80 bool AddSamplesFromPickle(base::PickleIterator* iter) override; |
81 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; | 81 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; |
82 std::unique_ptr<HistogramSamples> SnapshotDelta() override; | 82 std::unique_ptr<HistogramSamples> SnapshotDelta() override; |
83 void WriteHTMLGraph(std::string* output) const override; | 83 void WriteHTMLGraph(std::string* output) const override; |
84 void WriteAscii(std::string* output) const override; | 84 void WriteAscii(std::string* output) const override; |
85 | 85 |
86 protected: | 86 protected: |
87 // HistogramBase implementation: | 87 // HistogramBase implementation: |
88 bool SerializeInfoImpl(base::Pickle* pickle) const override; | 88 bool SerializeInfoImpl(base::Pickle* pickle) const override; |
89 | 89 |
90 private: | 90 private: |
91 // Clients should always use FactoryGet to create SparseHistogram. | 91 // Clients should always use FactoryGet to create SparseHistogram. |
92 explicit SparseHistogram(const std::string& name); | 92 explicit SparseHistogram(const std::string& name); |
93 | 93 |
94 SparseHistogram(PersistentMemoryAllocator* allocator, | 94 SparseHistogram(PersistentHistogramAllocator* allocator, |
95 const std::string& name, | 95 const std::string& name, |
96 HistogramSamples::Metadata* meta, | 96 HistogramSamples::Metadata* meta, |
97 HistogramSamples::Metadata* logged_meta); | 97 HistogramSamples::Metadata* logged_meta); |
98 | 98 |
99 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( | 99 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( |
100 base::PickleIterator* iter); | 100 base::PickleIterator* iter); |
101 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 101 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
102 | 102 |
103 void GetParameters(DictionaryValue* params) const override; | 103 void GetParameters(DictionaryValue* params) const override; |
104 void GetCountAndBucketData(Count* count, | 104 void GetCountAndBucketData(Count* count, |
(...skipping 17 matching lines...) Expand all Loading... |
122 | 122 |
123 std::unique_ptr<HistogramSamples> samples_; | 123 std::unique_ptr<HistogramSamples> samples_; |
124 std::unique_ptr<HistogramSamples> logged_samples_; | 124 std::unique_ptr<HistogramSamples> logged_samples_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); | 126 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); |
127 }; | 127 }; |
128 | 128 |
129 } // namespace base | 129 } // namespace base |
130 | 130 |
131 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ | 131 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ |
OLD | NEW |