| 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 |
| 11 #include <limits> |
| 11 #include <memory> | 12 #include <memory> |
| 12 | 13 |
| 13 #include "base/atomicops.h" | 14 #include "base/atomicops.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/metrics/histogram_base.h" | 16 #include "base/metrics/histogram_base.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 | 19 |
| 19 class Pickle; | 20 class Pickle; |
| 20 class PickleIterator; | 21 class PickleIterator; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 192 |
| 192 class BASE_EXPORT SampleCountIterator { | 193 class BASE_EXPORT SampleCountIterator { |
| 193 public: | 194 public: |
| 194 virtual ~SampleCountIterator(); | 195 virtual ~SampleCountIterator(); |
| 195 | 196 |
| 196 virtual bool Done() const = 0; | 197 virtual bool Done() const = 0; |
| 197 virtual void Next() = 0; | 198 virtual void Next() = 0; |
| 198 | 199 |
| 199 // Get the sample and count at current position. | 200 // Get the sample and count at current position. |
| 200 // |min| |max| and |count| can be NULL if the value is not of interest. | 201 // |min| |max| and |count| can be NULL if the value is not of interest. |
| 202 // Note: |max| is int64_t because histograms support logged values in the |
| 203 // full int32_t range and bucket max is exclusive, so it needs to support |
| 204 // values up to MAXINT32+1. |
| 201 // Requires: !Done(); | 205 // Requires: !Done(); |
| 202 virtual void Get(HistogramBase::Sample* min, | 206 virtual void Get(HistogramBase::Sample* min, |
| 203 HistogramBase::Sample* max, | 207 int64_t* max, |
| 204 HistogramBase::Count* count) const = 0; | 208 HistogramBase::Count* count) const = 0; |
| 209 static_assert(std::numeric_limits<HistogramBase::Sample>::max() < |
| 210 std::numeric_limits<int64_t>::max(), |
| 211 "Get() |max| must be able to hold Histogram::Sample max + 1"); |
| 205 | 212 |
| 206 // Get the index of current histogram bucket. | 213 // Get the index of current histogram bucket. |
| 207 // For histograms that don't use predefined buckets, it returns false. | 214 // For histograms that don't use predefined buckets, it returns false. |
| 208 // Requires: !Done(); | 215 // Requires: !Done(); |
| 209 virtual bool GetBucketIndex(size_t* index) const; | 216 virtual bool GetBucketIndex(size_t* index) const; |
| 210 }; | 217 }; |
| 211 | 218 |
| 212 class BASE_EXPORT SingleSampleIterator : public SampleCountIterator { | 219 class BASE_EXPORT SingleSampleIterator : public SampleCountIterator { |
| 213 public: | 220 public: |
| 214 SingleSampleIterator(HistogramBase::Sample min, | 221 SingleSampleIterator(HistogramBase::Sample min, |
| 215 HistogramBase::Sample max, | 222 int64_t max, |
| 216 HistogramBase::Count count); | 223 HistogramBase::Count count); |
| 217 SingleSampleIterator(HistogramBase::Sample min, | 224 SingleSampleIterator(HistogramBase::Sample min, |
| 218 HistogramBase::Sample max, | 225 int64_t max, |
| 219 HistogramBase::Count count, | 226 HistogramBase::Count count, |
| 220 size_t bucket_index); | 227 size_t bucket_index); |
| 221 ~SingleSampleIterator() override; | 228 ~SingleSampleIterator() override; |
| 222 | 229 |
| 223 // SampleCountIterator: | 230 // SampleCountIterator: |
| 224 bool Done() const override; | 231 bool Done() const override; |
| 225 void Next() override; | 232 void Next() override; |
| 226 void Get(HistogramBase::Sample* min, | 233 void Get(HistogramBase::Sample* min, |
| 227 HistogramBase::Sample* max, | 234 int64_t* max, |
| 228 HistogramBase::Count* count) const override; | 235 HistogramBase::Count* count) const override; |
| 229 | 236 |
| 230 // SampleVector uses predefined buckets so iterator can return bucket index. | 237 // SampleVector uses predefined buckets so iterator can return bucket index. |
| 231 bool GetBucketIndex(size_t* index) const override; | 238 bool GetBucketIndex(size_t* index) const override; |
| 232 | 239 |
| 233 private: | 240 private: |
| 234 // Information about the single value to return. | 241 // Information about the single value to return. |
| 235 const HistogramBase::Sample min_; | 242 const HistogramBase::Sample min_; |
| 236 const HistogramBase::Sample max_; | 243 const int64_t max_; |
| 237 const size_t bucket_index_; | 244 const size_t bucket_index_; |
| 238 HistogramBase::Count count_; | 245 HistogramBase::Count count_; |
| 239 }; | 246 }; |
| 240 | 247 |
| 241 } // namespace base | 248 } // namespace base |
| 242 | 249 |
| 243 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ | 250 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ |
| OLD | NEW |