| 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 namespace base { | 10 namespace base { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 Count SampleVector::TotalCount() const { | 61 Count SampleVector::TotalCount() const { |
| 62 Count count = 0; | 62 Count count = 0; |
| 63 for (size_t i = 0; i < counts_size_; i++) { | 63 for (size_t i = 0; i < counts_size_; i++) { |
| 64 count += subtle::NoBarrier_Load(&counts_[i]); | 64 count += subtle::NoBarrier_Load(&counts_[i]); |
| 65 } | 65 } |
| 66 return count; | 66 return count; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void SampleVector::Negate() { |
| 70 for (size_t i = 0; i < counts_size_; i++) { |
| 71 subtle::NoBarrier_Store(&counts_[i], |
| 72 -subtle::NoBarrier_Load(&counts_[i])); |
| 73 } |
| 74 } |
| 75 |
| 69 Count SampleVector::GetCountAtIndex(size_t bucket_index) const { | 76 Count SampleVector::GetCountAtIndex(size_t bucket_index) const { |
| 70 DCHECK(bucket_index < counts_size_); | 77 DCHECK(bucket_index < counts_size_); |
| 71 return subtle::NoBarrier_Load(&counts_[bucket_index]); | 78 return subtle::NoBarrier_Load(&counts_[bucket_index]); |
| 72 } | 79 } |
| 73 | 80 |
| 74 scoped_ptr<SampleCountIterator> SampleVector::Iterator() const { | 81 scoped_ptr<SampleCountIterator> SampleVector::Iterator() const { |
| 75 return scoped_ptr<SampleCountIterator>( | 82 return scoped_ptr<SampleCountIterator>( |
| 76 new SampleVectorIterator(counts_, counts_size_, bucket_ranges_)); | 83 new SampleVectorIterator(counts_, counts_size_, bucket_ranges_)); |
| 77 } | 84 } |
| 78 | 85 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return; | 200 return; |
| 194 | 201 |
| 195 while (index_ < counts_size_) { | 202 while (index_ < counts_size_) { |
| 196 if (subtle::NoBarrier_Load(&counts_[index_]) != 0) | 203 if (subtle::NoBarrier_Load(&counts_[index_]) != 0) |
| 197 return; | 204 return; |
| 198 index_++; | 205 index_++; |
| 199 } | 206 } |
| 200 } | 207 } |
| 201 | 208 |
| 202 } // namespace base | 209 } // namespace base |
| OLD | NEW |