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_HISTOGRAM_SAMPLES_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
6 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 6 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 AtomicSingleSample single_sample; // 32 bits | 121 AtomicSingleSample single_sample; // 32 bits |
122 }; | 122 }; |
123 | 123 |
124 // Because structures held in persistent memory must be POD, there can be no | 124 // Because structures held in persistent memory must be POD, there can be no |
125 // default constructor to clear the fields. This derived class exists just | 125 // default constructor to clear the fields. This derived class exists just |
126 // to clear them when being allocated on the heap. | 126 // to clear them when being allocated on the heap. |
127 struct BASE_EXPORT LocalMetadata : Metadata { | 127 struct BASE_EXPORT LocalMetadata : Metadata { |
128 LocalMetadata(); | 128 LocalMetadata(); |
129 }; | 129 }; |
130 | 130 |
131 explicit HistogramSamples(uint64_t id); | |
132 HistogramSamples(uint64_t id, Metadata* meta); | 131 HistogramSamples(uint64_t id, Metadata* meta); |
133 virtual ~HistogramSamples(); | 132 virtual ~HistogramSamples(); |
134 | 133 |
135 virtual void Accumulate(HistogramBase::Sample value, | 134 virtual void Accumulate(HistogramBase::Sample value, |
136 HistogramBase::Count count) = 0; | 135 HistogramBase::Count count) = 0; |
137 virtual HistogramBase::Count GetCount(HistogramBase::Sample value) const = 0; | 136 virtual HistogramBase::Count GetCount(HistogramBase::Sample value) const = 0; |
138 virtual HistogramBase::Count TotalCount() const = 0; | 137 virtual HistogramBase::Count TotalCount() const = 0; |
139 | 138 |
140 virtual void Add(const HistogramSamples& other); | 139 virtual void Add(const HistogramSamples& other); |
141 | 140 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 size_t bucket); | 172 size_t bucket); |
174 | 173 |
175 // Atomically adjust the sum and redundant-count. | 174 // Atomically adjust the sum and redundant-count. |
176 void IncreaseSumAndCount(int64_t sum, HistogramBase::Count count); | 175 void IncreaseSumAndCount(int64_t sum, HistogramBase::Count count); |
177 | 176 |
178 AtomicSingleSample& single_sample() { return meta_->single_sample; } | 177 AtomicSingleSample& single_sample() { return meta_->single_sample; } |
179 const AtomicSingleSample& single_sample() const { | 178 const AtomicSingleSample& single_sample() const { |
180 return meta_->single_sample; | 179 return meta_->single_sample; |
181 } | 180 } |
182 | 181 |
| 182 Metadata* meta() { return meta_; } |
| 183 |
183 private: | 184 private: |
184 // In order to support histograms shared through an external memory segment, | |
185 // meta values may be the local storage or external storage depending on the | |
186 // wishes of the derived class. | |
187 LocalMetadata local_meta_; | |
188 Metadata* meta_; | 185 Metadata* meta_; |
189 | 186 |
190 DISALLOW_COPY_AND_ASSIGN(HistogramSamples); | 187 DISALLOW_COPY_AND_ASSIGN(HistogramSamples); |
191 }; | 188 }; |
192 | 189 |
193 class BASE_EXPORT SampleCountIterator { | 190 class BASE_EXPORT SampleCountIterator { |
194 public: | 191 public: |
195 virtual ~SampleCountIterator(); | 192 virtual ~SampleCountIterator(); |
196 | 193 |
197 virtual bool Done() const = 0; | 194 virtual bool Done() const = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // Information about the single value to return. | 238 // Information about the single value to return. |
242 const HistogramBase::Sample min_; | 239 const HistogramBase::Sample min_; |
243 const int64_t max_; | 240 const int64_t max_; |
244 const size_t bucket_index_; | 241 const size_t bucket_index_; |
245 HistogramBase::Count count_; | 242 HistogramBase::Count count_; |
246 }; | 243 }; |
247 | 244 |
248 } // namespace base | 245 } // namespace base |
249 | 246 |
250 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 247 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
OLD | NEW |