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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 191 |
192 class BASE_EXPORT SampleCountIterator { | 192 class BASE_EXPORT SampleCountIterator { |
193 public: | 193 public: |
194 virtual ~SampleCountIterator(); | 194 virtual ~SampleCountIterator(); |
195 | 195 |
196 virtual bool Done() const = 0; | 196 virtual bool Done() const = 0; |
197 virtual void Next() = 0; | 197 virtual void Next() = 0; |
198 | 198 |
199 // Get the sample and count at current position. | 199 // Get the sample and count at current position. |
200 // |min| |max| and |count| can be NULL if the value is not of interest. | 200 // |min| |max| and |count| can be NULL if the value is not of interest. |
201 // Note: |max| is int64_t because histograms support logged values in the | |
202 // full int32_t range and bucket max is exclusive, so it needs to support | |
203 // values up to MAXINT32+1. | |
Ilya Sherman
2017/05/02 21:37:49
Could you add a compile-time assertion somewhere t
Alexei Svitkine (slow)
2017/05/03 15:21:53
Done.
| |
201 // Requires: !Done(); | 204 // Requires: !Done(); |
202 virtual void Get(HistogramBase::Sample* min, | 205 virtual void Get(HistogramBase::Sample* min, |
203 HistogramBase::Sample* max, | 206 int64_t* max, |
204 HistogramBase::Count* count) const = 0; | 207 HistogramBase::Count* count) const = 0; |
205 | 208 |
206 // Get the index of current histogram bucket. | 209 // Get the index of current histogram bucket. |
207 // For histograms that don't use predefined buckets, it returns false. | 210 // For histograms that don't use predefined buckets, it returns false. |
208 // Requires: !Done(); | 211 // Requires: !Done(); |
209 virtual bool GetBucketIndex(size_t* index) const; | 212 virtual bool GetBucketIndex(size_t* index) const; |
210 }; | 213 }; |
211 | 214 |
212 class BASE_EXPORT SingleSampleIterator : public SampleCountIterator { | 215 class BASE_EXPORT SingleSampleIterator : public SampleCountIterator { |
213 public: | 216 public: |
214 SingleSampleIterator(HistogramBase::Sample min, | 217 SingleSampleIterator(HistogramBase::Sample min, |
215 HistogramBase::Sample max, | 218 int64_t max, |
216 HistogramBase::Count count); | 219 HistogramBase::Count count); |
217 SingleSampleIterator(HistogramBase::Sample min, | 220 SingleSampleIterator(HistogramBase::Sample min, |
218 HistogramBase::Sample max, | 221 int64_t max, |
219 HistogramBase::Count count, | 222 HistogramBase::Count count, |
220 size_t bucket_index); | 223 size_t bucket_index); |
221 ~SingleSampleIterator() override; | 224 ~SingleSampleIterator() override; |
222 | 225 |
223 // SampleCountIterator: | 226 // SampleCountIterator: |
224 bool Done() const override; | 227 bool Done() const override; |
225 void Next() override; | 228 void Next() override; |
226 void Get(HistogramBase::Sample* min, | 229 void Get(HistogramBase::Sample* min, |
227 HistogramBase::Sample* max, | 230 int64_t* max, |
228 HistogramBase::Count* count) const override; | 231 HistogramBase::Count* count) const override; |
229 | 232 |
230 // SampleVector uses predefined buckets so iterator can return bucket index. | 233 // SampleVector uses predefined buckets so iterator can return bucket index. |
231 bool GetBucketIndex(size_t* index) const override; | 234 bool GetBucketIndex(size_t* index) const override; |
232 | 235 |
233 private: | 236 private: |
234 // Information about the single value to return. | 237 // Information about the single value to return. |
235 const HistogramBase::Sample min_; | 238 const HistogramBase::Sample min_; |
236 const HistogramBase::Sample max_; | 239 const int64_t max_; |
237 const size_t bucket_index_; | 240 const size_t bucket_index_; |
238 HistogramBase::Count count_; | 241 HistogramBase::Count count_; |
239 }; | 242 }; |
240 | 243 |
241 } // namespace base | 244 } // namespace base |
242 | 245 |
243 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 246 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
OLD | NEW |