| 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 // 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 if (count <= 0) { | 286 if (count <= 0) { |
| 287 NOTREACHED(); | 287 NOTREACHED(); |
| 288 return; | 288 return; |
| 289 } | 289 } |
| 290 samples_->Accumulate(value, count); | 290 samples_->Accumulate(value, count); |
| 291 | 291 |
| 292 FindAndRunCallback(value); | 292 FindAndRunCallback(value); |
| 293 } | 293 } |
| 294 | 294 |
| 295 scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const { | 295 scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const { |
| 296 return SnapshotSampleVector().Pass(); | 296 return SnapshotSampleVector(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void Histogram::AddSamples(const HistogramSamples& samples) { | 299 void Histogram::AddSamples(const HistogramSamples& samples) { |
| 300 samples_->Add(samples); | 300 samples_->Add(samples); |
| 301 } | 301 } |
| 302 | 302 |
| 303 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) { | 303 bool Histogram::AddSamplesFromPickle(PickleIterator* iter) { |
| 304 return samples_->AddFromPickle(iter); | 304 return samples_->AddFromPickle(iter); |
| 305 } | 305 } |
| 306 | 306 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 if (!ValidateRangeChecksum(*histogram, range_checksum)) { | 387 if (!ValidateRangeChecksum(*histogram, range_checksum)) { |
| 388 // The serialized histogram might be corrupted. | 388 // The serialized histogram might be corrupted. |
| 389 return NULL; | 389 return NULL; |
| 390 } | 390 } |
| 391 return histogram; | 391 return histogram; |
| 392 } | 392 } |
| 393 | 393 |
| 394 scoped_ptr<SampleVector> Histogram::SnapshotSampleVector() const { | 394 scoped_ptr<SampleVector> Histogram::SnapshotSampleVector() const { |
| 395 scoped_ptr<SampleVector> samples(new SampleVector(bucket_ranges())); | 395 scoped_ptr<SampleVector> samples(new SampleVector(bucket_ranges())); |
| 396 samples->Add(*samples_); | 396 samples->Add(*samples_); |
| 397 return samples.Pass(); | 397 return samples; |
| 398 } | 398 } |
| 399 | 399 |
| 400 void Histogram::WriteAsciiImpl(bool graph_it, | 400 void Histogram::WriteAsciiImpl(bool graph_it, |
| 401 const std::string& newline, | 401 const std::string& newline, |
| 402 std::string* output) const { | 402 std::string* output) const { |
| 403 // Get local (stack) copies of all effectively volatile class data so that we | 403 // Get local (stack) copies of all effectively volatile class data so that we |
| 404 // are consistent across our output activities. | 404 // are consistent across our output activities. |
| 405 scoped_ptr<SampleVector> snapshot = SnapshotSampleVector(); | 405 scoped_ptr<SampleVector> snapshot = SnapshotSampleVector(); |
| 406 Count sample_count = snapshot->TotalCount(); | 406 Count sample_count = snapshot->TotalCount(); |
| 407 | 407 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 | 892 |
| 893 BucketRanges* bucket_ranges = new BucketRanges(ranges.size()); | 893 BucketRanges* bucket_ranges = new BucketRanges(ranges.size()); |
| 894 for (size_t i = 0; i < ranges.size(); i++) { | 894 for (size_t i = 0; i < ranges.size(); i++) { |
| 895 bucket_ranges->set_range(i, ranges[i]); | 895 bucket_ranges->set_range(i, ranges[i]); |
| 896 } | 896 } |
| 897 bucket_ranges->ResetChecksum(); | 897 bucket_ranges->ResetChecksum(); |
| 898 return bucket_ranges; | 898 return bucket_ranges; |
| 899 } | 899 } |
| 900 | 900 |
| 901 } // namespace base | 901 } // namespace base |
| OLD | NEW |