Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: base/metrics/histogram_samples.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/metrics/histogram_samples.h ('k') | base/metrics/histogram_snapshot_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « base/metrics/histogram_samples.h ('k') | base/metrics/histogram_snapshot_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698