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/histogram_samples.h" | 5 #include "base/metrics/histogram_samples.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 HistogramBase::Sample* max, | 52 HistogramBase::Sample* max, |
53 HistogramBase::Count* count) const { | 53 HistogramBase::Count* count) const { |
54 DCHECK(!Done()); | 54 DCHECK(!Done()); |
55 *min = min_; | 55 *min = min_; |
56 *max = max_; | 56 *max = max_; |
57 *count = count_; | 57 *count = count_; |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 // Don't try to delegate behavior to the constructor below that accepts a | |
63 // Matadata pointer by passing &local_meta_. Such cannot be reliably passed | |
Nico
2015/12/14 20:49:01
typo matadata
| |
64 // because it has not yet been constructed -- no member variables have; the | |
65 // class itself is in the middle of being constructed. Using it to | |
66 // initialize meta_ is okay because the object now exists and local_meta_ | |
67 // is before meta_ in the construction order. | |
62 HistogramSamples::HistogramSamples(uint64_t id) | 68 HistogramSamples::HistogramSamples(uint64_t id) |
63 : HistogramSamples(id, &local_meta_) {} | 69 : meta_(&local_meta_) { |
70 meta_->id = id; | |
71 } | |
64 | 72 |
65 HistogramSamples::HistogramSamples(uint64_t id, Metadata* meta) | 73 HistogramSamples::HistogramSamples(uint64_t id, Metadata* meta) |
66 : meta_(meta) { | 74 : meta_(meta) { |
67 DCHECK(meta_->id == 0 || meta_->id == id); | 75 DCHECK(meta_->id == 0 || meta_->id == id); |
Alexei Svitkine (slow)
2015/12/14 18:54:41
Nit: Add this line to the ctor above.
bcwhite
2015/12/14 19:11:07
Unnecessary since local_meta_ has just been constr
| |
68 meta_->id = id; | 76 meta_->id = id; |
69 } | 77 } |
70 | 78 |
71 HistogramSamples::~HistogramSamples() {} | 79 HistogramSamples::~HistogramSamples() {} |
72 | 80 |
73 // Despite using atomic operations, the increment/add actions below are *not* | 81 // Despite using atomic operations, the increment/add actions below are *not* |
74 // atomic! Race conditions may cause loss of samples or even completely corrupt | 82 // atomic! Race conditions may cause loss of samples or even completely corrupt |
75 // the 64-bit sum on 32-bit machines. This is done intentionally to reduce the | 83 // the 64-bit sum on 32-bit machines. This is done intentionally to reduce the |
76 // cost of these operations that could be executed in performance-significant | 84 // cost of these operations that could be executed in performance-significant |
77 // points of the code. | 85 // points of the code. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 } | 159 } |
152 | 160 |
153 SampleCountIterator::~SampleCountIterator() {} | 161 SampleCountIterator::~SampleCountIterator() {} |
154 | 162 |
155 bool SampleCountIterator::GetBucketIndex(size_t* index) const { | 163 bool SampleCountIterator::GetBucketIndex(size_t* index) const { |
156 DCHECK(!Done()); | 164 DCHECK(!Done()); |
157 return false; | 165 return false; |
158 } | 166 } |
159 | 167 |
160 } // namespace base | 168 } // namespace base |
OLD | NEW |