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 #include "base/metrics/sample_vector.h" | 5 #include "base/metrics/sample_vector.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/bucket_ranges.h" | 8 #include "base/metrics/bucket_ranges.h" |
9 | 9 |
10 using std::vector; | |
11 | |
12 namespace base { | 10 namespace base { |
13 | 11 |
14 typedef HistogramBase::Count Count; | 12 typedef HistogramBase::Count Count; |
15 typedef HistogramBase::Sample Sample; | 13 typedef HistogramBase::Sample Sample; |
16 | 14 |
17 SampleVector::SampleVector(const BucketRanges* bucket_ranges) | 15 SampleVector::SampleVector(const BucketRanges* bucket_ranges) |
18 : counts_(bucket_ranges->bucket_count()), | 16 : counts_(bucket_ranges->bucket_count()), |
19 bucket_ranges_(bucket_ranges) { | 17 bucket_ranges_(bucket_ranges) { |
20 CHECK_GE(bucket_ranges_->bucket_count(), 1u); | 18 CHECK_GE(bucket_ranges_->bucket_count(), 1u); |
21 } | 19 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 under = mid; | 102 under = mid; |
105 else | 103 else |
106 over = mid; | 104 over = mid; |
107 } while (true); | 105 } while (true); |
108 | 106 |
109 DCHECK_LE(bucket_ranges_->range(mid), value); | 107 DCHECK_LE(bucket_ranges_->range(mid), value); |
110 CHECK_GT(bucket_ranges_->range(mid + 1), value); | 108 CHECK_GT(bucket_ranges_->range(mid + 1), value); |
111 return mid; | 109 return mid; |
112 } | 110 } |
113 | 111 |
114 SampleVectorIterator::SampleVectorIterator(const vector<Count>* counts, | 112 SampleVectorIterator::SampleVectorIterator(const std::vector<Count>* counts, |
115 const BucketRanges* bucket_ranges) | 113 const BucketRanges* bucket_ranges) |
116 : counts_(counts), | 114 : counts_(counts), |
117 bucket_ranges_(bucket_ranges), | 115 bucket_ranges_(bucket_ranges), |
118 index_(0) { | 116 index_(0) { |
119 CHECK_GE(bucket_ranges_->bucket_count(), counts_->size()); | 117 CHECK_GE(bucket_ranges_->bucket_count(), counts_->size()); |
120 SkipEmptyBuckets(); | 118 SkipEmptyBuckets(); |
121 } | 119 } |
122 | 120 |
123 SampleVectorIterator::~SampleVectorIterator() {} | 121 SampleVectorIterator::~SampleVectorIterator() {} |
124 | 122 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return; | 154 return; |
157 | 155 |
158 while (index_ < counts_->size()) { | 156 while (index_ < counts_->size()) { |
159 if (subtle::NoBarrier_Load(&(*counts_)[index_]) != 0) | 157 if (subtle::NoBarrier_Load(&(*counts_)[index_]) != 0) |
160 return; | 158 return; |
161 index_++; | 159 index_++; |
162 } | 160 } |
163 } | 161 } |
164 | 162 |
165 } // namespace base | 163 } // namespace base |
OLD | NEW |