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 11 matching lines...) Expand all Loading... |
22 HistogramBase* SparseHistogram::FactoryGet(const std::string& name, | 22 HistogramBase* SparseHistogram::FactoryGet(const std::string& name, |
23 int32_t flags) { | 23 int32_t flags) { |
24 HistogramBase* histogram = StatisticsRecorder::FindHistogram(name); | 24 HistogramBase* histogram = StatisticsRecorder::FindHistogram(name); |
25 | 25 |
26 if (!histogram) { | 26 if (!histogram) { |
27 // To avoid racy destruction at shutdown, the following will be leaked. | 27 // To avoid racy destruction at shutdown, the following will be leaked. |
28 HistogramBase* tentative_histogram = new SparseHistogram(name); | 28 HistogramBase* tentative_histogram = new SparseHistogram(name); |
29 tentative_histogram->SetFlags(flags); | 29 tentative_histogram->SetFlags(flags); |
30 histogram = | 30 histogram = |
31 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); | 31 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); |
| 32 ReportHistogramActivity(*histogram, HISTOGRAM_CREATED); |
| 33 } else { |
| 34 ReportHistogramActivity(*histogram, HISTOGRAM_LOOKUP); |
32 } | 35 } |
33 DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType()); | 36 DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType()); |
34 return histogram; | 37 return histogram; |
35 } | 38 } |
36 | 39 |
37 SparseHistogram::~SparseHistogram() {} | 40 SparseHistogram::~SparseHistogram() {} |
38 | 41 |
39 uint64_t SparseHistogram::name_hash() const { | 42 uint64_t SparseHistogram::name_hash() const { |
40 return samples_.id(); | 43 return samples_.id(); |
41 } | 44 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 std::string* output) const { | 200 std::string* output) const { |
198 StringAppendF(output, | 201 StringAppendF(output, |
199 "Histogram: %s recorded %d samples", | 202 "Histogram: %s recorded %d samples", |
200 histogram_name().c_str(), | 203 histogram_name().c_str(), |
201 total_count); | 204 total_count); |
202 if (flags() & ~kHexRangePrintingFlag) | 205 if (flags() & ~kHexRangePrintingFlag) |
203 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); | 206 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); |
204 } | 207 } |
205 | 208 |
206 } // namespace base | 209 } // namespace base |
OLD | NEW |