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/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/persistent_memory_allocator.h" | 10 #include "base/metrics/persistent_memory_allocator.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 if (subtle::NoBarrier_Load(&counts_) == 0) { | 265 if (subtle::NoBarrier_Load(&counts_) == 0) { |
266 AutoLock lock(counts_lock.Get()); | 266 AutoLock lock(counts_lock.Get()); |
267 if (subtle::NoBarrier_Load(&counts_) == 0) { | 267 if (subtle::NoBarrier_Load(&counts_) == 0) { |
268 // Create the actual counts storage while the above lock is acquired. | 268 // Create the actual counts storage while the above lock is acquired. |
269 HistogramBase::Count* counts = CreateCountsStorageWhileLocked(); | 269 HistogramBase::Count* counts = CreateCountsStorageWhileLocked(); |
270 DCHECK(counts); | 270 DCHECK(counts); |
271 | 271 |
272 // Point |counts_| to the newly created storage. This is done while | 272 // Point |counts_| to the newly created storage. This is done while |
273 // locked to prevent possible concurrent calls to CreateCountsStorage | 273 // locked to prevent possible concurrent calls to CreateCountsStorage |
274 // but, between that call and here, other threads could notice the | 274 // but, between that call and here, other threads could notice the |
275 // existance of the storage and race with this to set_counts(). That's | 275 // existence of the storage and race with this to set_counts(). That's |
276 // okay because (a) it's atomic and (b) it always writes the same value. | 276 // okay because (a) it's atomic and (b) it always writes the same value. |
277 set_counts(counts); | 277 set_counts(counts); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 // Move any single-sample into the newly mounted storage. | 281 // Move any single-sample into the newly mounted storage. |
282 MoveSingleSampleToCounts(); | 282 MoveSingleSampleToCounts(); |
283 } | 283 } |
284 | 284 |
285 SampleVector::SampleVector(const BucketRanges* bucket_ranges) | 285 SampleVector::SampleVector(const BucketRanges* bucket_ranges) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 return; | 416 return; |
417 | 417 |
418 while (index_ < counts_size_) { | 418 while (index_ < counts_size_) { |
419 if (subtle::NoBarrier_Load(&counts_[index_]) != 0) | 419 if (subtle::NoBarrier_Load(&counts_[index_]) != 0) |
420 return; | 420 return; |
421 index_++; | 421 index_++; |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
425 } // namespace base | 425 } // namespace base |
OLD | NEW |