| 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/sparse_histogram.h" | 5 #include "base/metrics/sparse_histogram.h" |
| 6 | 6 |
| 7 #include "base/metrics/sample_map.h" | 7 #include "base/metrics/sample_map.h" |
| 8 #include "base/metrics/statistics_recorder.h" | 8 #include "base/metrics/statistics_recorder.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void SparseHistogram::Add(Sample value) { | 50 void SparseHistogram::Add(Sample value) { |
| 51 base::AutoLock auto_lock(lock_); | 51 base::AutoLock auto_lock(lock_); |
| 52 samples_.Accumulate(value, 1); | 52 samples_.Accumulate(value, 1); |
| 53 } | 53 } |
| 54 | 54 |
| 55 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { | 55 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { |
| 56 scoped_ptr<SampleMap> snapshot(new SampleMap()); | 56 scoped_ptr<SampleMap> snapshot(new SampleMap()); |
| 57 | 57 |
| 58 base::AutoLock auto_lock(lock_); | 58 base::AutoLock auto_lock(lock_); |
| 59 snapshot->Add(samples_); | 59 snapshot->Add(samples_); |
| 60 return snapshot.PassAs<HistogramSamples>(); | 60 return snapshot.Pass(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void SparseHistogram::AddSamples(const HistogramSamples& samples) { | 63 void SparseHistogram::AddSamples(const HistogramSamples& samples) { |
| 64 base::AutoLock auto_lock(lock_); | 64 base::AutoLock auto_lock(lock_); |
| 65 samples_.Add(samples); | 65 samples_.Add(samples); |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) { | 68 bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) { |
| 69 base::AutoLock auto_lock(lock_); | 69 base::AutoLock auto_lock(lock_); |
| 70 return samples_.AddFromPickle(iter); | 70 return samples_.AddFromPickle(iter); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 std::string* output) const { | 170 std::string* output) const { |
| 171 StringAppendF(output, | 171 StringAppendF(output, |
| 172 "Histogram: %s recorded %d samples", | 172 "Histogram: %s recorded %d samples", |
| 173 histogram_name().c_str(), | 173 histogram_name().c_str(), |
| 174 total_count); | 174 total_count); |
| 175 if (flags() & ~kHexRangePrintingFlag) | 175 if (flags() & ~kHexRangePrintingFlag) |
| 176 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); | 176 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace base | 179 } // namespace base |
| OLD | NEW |