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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 bool HasConstructionArguments(Sample expected_minimum, | 75 bool HasConstructionArguments(Sample expected_minimum, |
76 Sample expected_maximum, | 76 Sample expected_maximum, |
77 uint32_t expected_bucket_count) const override; | 77 uint32_t expected_bucket_count) const override; |
78 void Add(Sample value) override; | 78 void Add(Sample value) override; |
79 void AddCount(Sample value, int count) override; | 79 void AddCount(Sample value, int count) override; |
80 void AddSamples(const HistogramSamples& samples) override; | 80 void AddSamples(const HistogramSamples& samples) override; |
81 bool AddSamplesFromPickle(base::PickleIterator* iter) override; | 81 bool AddSamplesFromPickle(base::PickleIterator* iter) override; |
82 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; | 82 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; |
83 std::unique_ptr<HistogramSamples> SnapshotDelta() override; | 83 std::unique_ptr<HistogramSamples> SnapshotDelta() override; |
84 std::unique_ptr<HistogramSamples> SnapshotFinalDelta() const override; | 84 std::unique_ptr<HistogramSamples> SnapshotFinalDelta() const override; |
85 void WriteHTMLGraph(std::string* output) const override; | 85 void WriteHTMLGraph(const HistogramSamples* snapshot, |
86 void WriteAscii(std::string* output) const override; | 86 std::string* output) const override; |
| 87 void WriteAscii(const HistogramSamples* snapshot, |
| 88 std::string* output) const override; |
87 | 89 |
88 protected: | 90 protected: |
89 // HistogramBase implementation: | 91 // HistogramBase implementation: |
90 bool SerializeInfoImpl(base::Pickle* pickle) const override; | 92 bool SerializeInfoImpl(base::Pickle* pickle) const override; |
91 | 93 |
92 private: | 94 private: |
93 // Clients should always use FactoryGet to create SparseHistogram. | 95 // Clients should always use FactoryGet to create SparseHistogram. |
94 explicit SparseHistogram(const std::string& name); | 96 explicit SparseHistogram(const std::string& name); |
95 | 97 |
96 SparseHistogram(PersistentHistogramAllocator* allocator, | 98 SparseHistogram(PersistentHistogramAllocator* allocator, |
97 const std::string& name, | 99 const std::string& name, |
98 HistogramSamples::Metadata* meta, | 100 HistogramSamples::Metadata* meta, |
99 HistogramSamples::Metadata* logged_meta); | 101 HistogramSamples::Metadata* logged_meta); |
100 | 102 |
101 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( | 103 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( |
102 base::PickleIterator* iter); | 104 base::PickleIterator* iter); |
103 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 105 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
104 | 106 |
105 void GetParameters(DictionaryValue* params) const override; | 107 void GetParameters(DictionaryValue* params) const override; |
106 void GetCountAndBucketData(Count* count, | 108 void GetCountAndBucketData(Count* count, |
107 int64_t* sum, | 109 int64_t* sum, |
108 ListValue* buckets) const override; | 110 ListValue* buckets) const override; |
109 | 111 |
110 // Helpers for emitting Ascii graphic. Each method appends data to output. | 112 // Helpers for emitting Ascii graphic. Each method appends data to output. |
111 void WriteAsciiImpl(bool graph_it, | 113 void WriteAsciiImpl(bool graph_it, |
112 const std::string& newline, | 114 const std::string& newline, |
| 115 const HistogramSamples* snapshot, |
113 std::string* output) const; | 116 std::string* output) const; |
114 | 117 |
115 // Write a common header message describing this histogram. | 118 // Write a common header message describing this histogram. |
116 void WriteAsciiHeader(const Count total_count, | 119 void WriteAsciiHeader(const Count total_count, |
117 std::string* output) const; | 120 std::string* output) const; |
118 | 121 |
119 // For constuctor calling. | 122 // For constuctor calling. |
120 friend class SparseHistogramTest; | 123 friend class SparseHistogramTest; |
121 | 124 |
122 // Protects access to |samples_|. | 125 // Protects access to |samples_|. |
123 mutable base::Lock lock_; | 126 mutable base::Lock lock_; |
124 | 127 |
125 // Flag to indicate if PrepareFinalDelta has been previously called. | 128 // Flag to indicate if PrepareFinalDelta has been previously called. |
126 mutable bool final_delta_created_ = false; | 129 mutable bool final_delta_created_ = false; |
127 | 130 |
128 std::unique_ptr<HistogramSamples> samples_; | 131 std::unique_ptr<HistogramSamples> samples_; |
129 std::unique_ptr<HistogramSamples> logged_samples_; | 132 std::unique_ptr<HistogramSamples> logged_samples_; |
130 | 133 |
131 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); | 134 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); |
132 }; | 135 }; |
133 | 136 |
134 } // namespace base | 137 } // namespace base |
135 | 138 |
136 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ | 139 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ |
OLD | NEW |