Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: base/metrics/sparse_histogram.cc

Issue 1726873002: Report histogram creation results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « base/metrics/persistent_histogram_allocator.cc ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698