| 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 <utility> |
| 8 |
| 7 #include "base/metrics/sample_map.h" | 9 #include "base/metrics/sample_map.h" |
| 8 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| 9 #include "base/pickle.h" | 11 #include "base/pickle.h" |
| 10 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 11 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 12 | 14 |
| 13 namespace base { | 15 namespace base { |
| 14 | 16 |
| 15 typedef HistogramBase::Count Count; | 17 typedef HistogramBase::Count Count; |
| 16 typedef HistogramBase::Sample Sample; | 18 typedef HistogramBase::Sample Sample; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 62 } |
| 61 | 63 |
| 62 FindAndRunCallback(value); | 64 FindAndRunCallback(value); |
| 63 } | 65 } |
| 64 | 66 |
| 65 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { | 67 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { |
| 66 scoped_ptr<SampleMap> snapshot(new SampleMap()); | 68 scoped_ptr<SampleMap> snapshot(new SampleMap()); |
| 67 | 69 |
| 68 base::AutoLock auto_lock(lock_); | 70 base::AutoLock auto_lock(lock_); |
| 69 snapshot->Add(samples_); | 71 snapshot->Add(samples_); |
| 70 return snapshot.Pass(); | 72 return std::move(snapshot); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void SparseHistogram::AddSamples(const HistogramSamples& samples) { | 75 void SparseHistogram::AddSamples(const HistogramSamples& samples) { |
| 74 base::AutoLock auto_lock(lock_); | 76 base::AutoLock auto_lock(lock_); |
| 75 samples_.Add(samples); | 77 samples_.Add(samples); |
| 76 } | 78 } |
| 77 | 79 |
| 78 bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) { | 80 bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) { |
| 79 base::AutoLock auto_lock(lock_); | 81 base::AutoLock auto_lock(lock_); |
| 80 return samples_.AddFromPickle(iter); | 82 return samples_.AddFromPickle(iter); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 std::string* output) const { | 180 std::string* output) const { |
| 179 StringAppendF(output, | 181 StringAppendF(output, |
| 180 "Histogram: %s recorded %d samples", | 182 "Histogram: %s recorded %d samples", |
| 181 histogram_name().c_str(), | 183 histogram_name().c_str(), |
| 182 total_count); | 184 total_count); |
| 183 if (flags() & ~kHexRangePrintingFlag) | 185 if (flags() & ~kHexRangePrintingFlag) |
| 184 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); | 186 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); |
| 185 } | 187 } |
| 186 | 188 |
| 187 } // namespace base | 189 } // namespace base |
| OLD | NEW |