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

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

Issue 655003004: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/memory/discardable_memory_win.cc ('k') | base/metrics/sparse_histogram.cc » ('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 // Histogram is an object that aggregates statistics, and can summarize them in 5 // Histogram is an object that aggregates statistics, and can summarize them in
6 // various forms, including ASCII graphical, HTML, and numerically (as a 6 // various forms, including ASCII graphical, HTML, and numerically (as a
7 // vector of numbers corresponding to each of the aggregating buckets). 7 // vector of numbers corresponding to each of the aggregating buckets).
8 // See header file for details and examples. 8 // See header file for details and examples.
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 DCHECK_EQ(kSampleType_MAX, ranges(bucket_count())); 261 DCHECK_EQ(kSampleType_MAX, ranges(bucket_count()));
262 262
263 if (value > kSampleType_MAX - 1) 263 if (value > kSampleType_MAX - 1)
264 value = kSampleType_MAX - 1; 264 value = kSampleType_MAX - 1;
265 if (value < 0) 265 if (value < 0)
266 value = 0; 266 value = 0;
267 samples_->Accumulate(value, 1); 267 samples_->Accumulate(value, 1);
268 } 268 }
269 269
270 scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const { 270 scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const {
271 return SnapshotSampleVector().PassAs<HistogramSamples>(); 271 return SnapshotSampleVector().Pass();
272 } 272 }
273 273
274 void Histogram::AddSamples(const HistogramSamples& samples) { 274 void Histogram::AddSamples(const HistogramSamples& samples) {
275 samples_->Add(samples); 275 samples_->Add(samples);
276 } 276 }
277 277
278 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) { 278 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) {
279 return samples_->AddFromPickle(iter); 279 return samples_->AddFromPickle(iter);
280 } 280 }
281 281
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (!ValidateRangeChecksum(*histogram, range_checksum)) { 362 if (!ValidateRangeChecksum(*histogram, range_checksum)) {
363 // The serialized histogram might be corrupted. 363 // The serialized histogram might be corrupted.
364 return NULL; 364 return NULL;
365 } 365 }
366 return histogram; 366 return histogram;
367 } 367 }
368 368
369 scoped_ptr<SampleVector> Histogram::SnapshotSampleVector() const { 369 scoped_ptr<SampleVector> Histogram::SnapshotSampleVector() const {
370 scoped_ptr<SampleVector> samples(new SampleVector(bucket_ranges())); 370 scoped_ptr<SampleVector> samples(new SampleVector(bucket_ranges()));
371 samples->Add(*samples_); 371 samples->Add(*samples_);
372 return samples.Pass(); 372 return samples;
danakj 2014/10/15 17:20:08 Oh that's cool I didn't realize we can do that now
373 } 373 }
374 374
375 void Histogram::WriteAsciiImpl(bool graph_it, 375 void Histogram::WriteAsciiImpl(bool graph_it,
376 const string& newline, 376 const string& newline,
377 string* output) const { 377 string* output) const {
378 // Get local (stack) copies of all effectively volatile class data so that we 378 // Get local (stack) copies of all effectively volatile class data so that we
379 // are consistent across our output activities. 379 // are consistent across our output activities.
380 scoped_ptr<SampleVector> snapshot = SnapshotSampleVector(); 380 scoped_ptr<SampleVector> snapshot = SnapshotSampleVector();
381 Count sample_count = snapshot->TotalCount(); 381 Count sample_count = snapshot->TotalCount();
382 382
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 837
838 BucketRanges* bucket_ranges = new BucketRanges(ranges.size()); 838 BucketRanges* bucket_ranges = new BucketRanges(ranges.size());
839 for (size_t i = 0; i < ranges.size(); i++) { 839 for (size_t i = 0; i < ranges.size(); i++) {
840 bucket_ranges->set_range(i, ranges[i]); 840 bucket_ranges->set_range(i, ranges[i]);
841 } 841 }
842 bucket_ranges->ResetChecksum(); 842 bucket_ranges->ResetChecksum();
843 return bucket_ranges; 843 return bucket_ranges;
844 } 844 }
845 845
846 } // namespace base 846 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_win.cc ('k') | base/metrics/sparse_histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698