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 // BucketRanges stores the vector of ranges that delimit what samples are | 5 // BucketRanges stores the vector of ranges that delimit what samples are |
6 // tallied in the corresponding buckets of a histogram. Histograms that have | 6 // tallied in the corresponding buckets of a histogram. Histograms that have |
7 // same ranges for all their corresponding buckets should share the same | 7 // same ranges for all their corresponding buckets should share the same |
8 // BucketRanges object. | 8 // BucketRanges object. |
9 // | 9 // |
10 // E.g. A 5 buckets LinearHistogram with 1 as minimal value and 4 as maximal | 10 // E.g. A 5 buckets LinearHistogram with 1 as minimal value and 4 as maximal |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 explicit BucketRanges(size_t num_ranges); | 33 explicit BucketRanges(size_t num_ranges); |
34 ~BucketRanges(); | 34 ~BucketRanges(); |
35 | 35 |
36 size_t size() const { return ranges_.size(); } | 36 size_t size() const { return ranges_.size(); } |
37 HistogramBase::Sample range(size_t i) const { return ranges_[i]; } | 37 HistogramBase::Sample range(size_t i) const { return ranges_[i]; } |
38 void set_range(size_t i, HistogramBase::Sample value); | 38 void set_range(size_t i, HistogramBase::Sample value); |
39 uint32 checksum() const { return checksum_; } | 39 uint32 checksum() const { return checksum_; } |
40 void set_checksum(uint32 checksum) { checksum_ = checksum; } | 40 void set_checksum(uint32 checksum) { checksum_ = checksum; } |
41 | 41 |
| 42 // A bucket is defined by a consecutive pair of entries in |ranges|, so there |
| 43 // is one fewer bucket than there are ranges. For example, if |ranges| is |
| 44 // [0, 1, 3, 7, INT_MAX], then the buckets in this histogram are |
| 45 // [0, 1), [1, 3), [3, 7), and [7, INT_MAX). |
| 46 size_t bucket_count() const { return ranges_.size() - 1; } |
| 47 |
42 // Checksum methods to verify whether the ranges are corrupted (e.g. bad | 48 // Checksum methods to verify whether the ranges are corrupted (e.g. bad |
43 // memory access). | 49 // memory access). |
44 uint32 CalculateChecksum() const; | 50 uint32 CalculateChecksum() const; |
45 bool HasValidChecksum() const; | 51 bool HasValidChecksum() const; |
46 void ResetChecksum(); | 52 void ResetChecksum(); |
47 | 53 |
48 // Return true iff |other| object has same ranges_ as |this| object's ranges_. | 54 // Return true iff |other| object has same ranges_ as |this| object's ranges_. |
49 bool Equals(const BucketRanges* other) const; | 55 bool Equals(const BucketRanges* other) const; |
50 | 56 |
51 private: | 57 private: |
(...skipping 12 matching lines...) Expand all Loading... |
64 DISALLOW_COPY_AND_ASSIGN(BucketRanges); | 70 DISALLOW_COPY_AND_ASSIGN(BucketRanges); |
65 }; | 71 }; |
66 | 72 |
67 ////////////////////////////////////////////////////////////////////////////// | 73 ////////////////////////////////////////////////////////////////////////////// |
68 // Expose only for test. | 74 // Expose only for test. |
69 BASE_EXPORT_PRIVATE extern const uint32 kCrcTable[256]; | 75 BASE_EXPORT_PRIVATE extern const uint32 kCrcTable[256]; |
70 | 76 |
71 } // namespace base | 77 } // namespace base |
72 | 78 |
73 #endif // BASE_METRICS_BUCKET_RANGES_H_ | 79 #endif // BASE_METRICS_BUCKET_RANGES_H_ |
OLD | NEW |