| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 bool HistogramSamples::Serialize(Pickle* pickle) const { | 135 bool HistogramSamples::Serialize(Pickle* pickle) const { |
| 136 if (!pickle->WriteInt64(meta_->sum)) | 136 if (!pickle->WriteInt64(meta_->sum)) |
| 137 return false; | 137 return false; |
| 138 if (!pickle->WriteInt(subtle::NoBarrier_Load(&meta_->redundant_count))) | 138 if (!pickle->WriteInt(subtle::NoBarrier_Load(&meta_->redundant_count))) |
| 139 return false; | 139 return false; |
| 140 | 140 |
| 141 HistogramBase::Sample min; | 141 HistogramBase::Sample min; |
| 142 HistogramBase::Sample max; | 142 HistogramBase::Sample max; |
| 143 HistogramBase::Count count; | 143 HistogramBase::Count count; |
| 144 for (scoped_ptr<SampleCountIterator> it = Iterator(); | 144 for (std::unique_ptr<SampleCountIterator> it = Iterator(); !it->Done(); |
| 145 !it->Done(); | |
| 146 it->Next()) { | 145 it->Next()) { |
| 147 it->Get(&min, &max, &count); | 146 it->Get(&min, &max, &count); |
| 148 if (!pickle->WriteInt(min) || | 147 if (!pickle->WriteInt(min) || |
| 149 !pickle->WriteInt(max) || | 148 !pickle->WriteInt(max) || |
| 150 !pickle->WriteInt(count)) | 149 !pickle->WriteInt(count)) |
| 151 return false; | 150 return false; |
| 152 } | 151 } |
| 153 return true; | 152 return true; |
| 154 } | 153 } |
| 155 | 154 |
| 156 void HistogramSamples::IncreaseSum(int64_t diff) { | 155 void HistogramSamples::IncreaseSum(int64_t diff) { |
| 157 meta_->sum += diff; | 156 meta_->sum += diff; |
| 158 } | 157 } |
| 159 | 158 |
| 160 void HistogramSamples::IncreaseRedundantCount(HistogramBase::Count diff) { | 159 void HistogramSamples::IncreaseRedundantCount(HistogramBase::Count diff) { |
| 161 subtle::NoBarrier_Store(&meta_->redundant_count, | 160 subtle::NoBarrier_Store(&meta_->redundant_count, |
| 162 subtle::NoBarrier_Load(&meta_->redundant_count) + diff); | 161 subtle::NoBarrier_Load(&meta_->redundant_count) + diff); |
| 163 } | 162 } |
| 164 | 163 |
| 165 SampleCountIterator::~SampleCountIterator() {} | 164 SampleCountIterator::~SampleCountIterator() {} |
| 166 | 165 |
| 167 bool SampleCountIterator::GetBucketIndex(size_t* index) const { | 166 bool SampleCountIterator::GetBucketIndex(size_t* index) const { |
| 168 DCHECK(!Done()); | 167 DCHECK(!Done()); |
| 169 return false; | 168 return false; |
| 170 } | 169 } |
| 171 | 170 |
| 172 } // namespace base | 171 } // namespace base |
| OLD | NEW |