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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 bool SparseHistogram::HasConstructionArguments( | 40 bool SparseHistogram::HasConstructionArguments( |
41 Sample expected_minimum, | 41 Sample expected_minimum, |
42 Sample expected_maximum, | 42 Sample expected_maximum, |
43 size_t expected_bucket_count) const { | 43 size_t expected_bucket_count) const { |
44 // SparseHistogram never has min/max/bucket_count limit. | 44 // SparseHistogram never has min/max/bucket_count limit. |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 void SparseHistogram::Add(Sample value) { | 48 void SparseHistogram::Add(Sample value) { |
49 base::AutoLock auto_lock(lock_); | 49 { |
50 samples_.Accumulate(value, 1); | 50 base::AutoLock auto_lock(lock_); |
| 51 samples_.Accumulate(value, 1); |
| 52 } |
| 53 |
| 54 FindAndRunCallback(value); |
51 } | 55 } |
52 | 56 |
53 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { | 57 scoped_ptr<HistogramSamples> SparseHistogram::SnapshotSamples() const { |
54 scoped_ptr<SampleMap> snapshot(new SampleMap()); | 58 scoped_ptr<SampleMap> snapshot(new SampleMap()); |
55 | 59 |
56 base::AutoLock auto_lock(lock_); | 60 base::AutoLock auto_lock(lock_); |
57 snapshot->Add(samples_); | 61 snapshot->Add(samples_); |
58 return snapshot.Pass(); | 62 return snapshot.Pass(); |
59 } | 63 } |
60 | 64 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 std::string* output) const { | 170 std::string* output) const { |
167 StringAppendF(output, | 171 StringAppendF(output, |
168 "Histogram: %s recorded %d samples", | 172 "Histogram: %s recorded %d samples", |
169 histogram_name().c_str(), | 173 histogram_name().c_str(), |
170 total_count); | 174 total_count); |
171 if (flags() & ~kHexRangePrintingFlag) | 175 if (flags() & ~kHexRangePrintingFlag) |
172 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); | 176 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); |
173 } | 177 } |
174 | 178 |
175 } // namespace base | 179 } // namespace base |
OLD | NEW |