| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/metrics/metrics_hashes.h" | 9 #include "base/metrics/metrics_hashes.h" |
| 10 #include "base/metrics/sample_map.h" | 10 #include "base/metrics/sample_map.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { | 72 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { |
| 73 scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash())); | 73 scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash())); |
| 74 | 74 |
| 75 base::AutoLock auto_lock(lock_); | 75 base::AutoLock auto_lock(lock_); |
| 76 snapshot->Add(samples_); | 76 snapshot->Add(samples_); |
| 77 return std::move(snapshot); | 77 return std::move(snapshot); |
| 78 } | 78 } |
| 79 | 79 |
| 80 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotDelta() { |
| 81 scoped_ptr<SampleMap> snapshot(new SampleMap(name_hash())); |
| 82 base::AutoLock auto_lock(lock_); |
| 83 snapshot->Add(samples_); |
| 84 |
| 85 // Subtract what was previously logged and update that information. |
| 86 snapshot->Subtract(logged_samples_); |
| 87 logged_samples_.Add(*snapshot); |
| 88 return std::move(snapshot); |
| 89 } |
| 90 |
| 80 void SparseHistogram::AddSamples(const HistogramSamples& samples) { | 91 void SparseHistogram::AddSamples(const HistogramSamples& samples) { |
| 81 base::AutoLock auto_lock(lock_); | 92 base::AutoLock auto_lock(lock_); |
| 82 samples_.Add(samples); | 93 samples_.Add(samples); |
| 83 } | 94 } |
| 84 | 95 |
| 85 bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) { | 96 bool SparseHistogram::AddSamplesFromPickle(PickleIterator* iter) { |
| 86 base::AutoLock auto_lock(lock_); | 97 base::AutoLock auto_lock(lock_); |
| 87 return samples_.AddFromPickle(iter); | 98 return samples_.AddFromPickle(iter); |
| 88 } | 99 } |
| 89 | 100 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 std::string* output) const { | 197 std::string* output) const { |
| 187 StringAppendF(output, | 198 StringAppendF(output, |
| 188 "Histogram: %s recorded %d samples", | 199 "Histogram: %s recorded %d samples", |
| 189 histogram_name().c_str(), | 200 histogram_name().c_str(), |
| 190 total_count); | 201 total_count); |
| 191 if (flags() & ~kHexRangePrintingFlag) | 202 if (flags() & ~kHexRangePrintingFlag) |
| 192 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); | 203 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); |
| 193 } | 204 } |
| 194 | 205 |
| 195 } // namespace base | 206 } // namespace base |
| OLD | NEW |