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

Side by Side Diff: net/disk_cache/stats_histogram.cc

Issue 17451016: [UMA] Remove redundant bucket_count variable from base::Histogram. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename variables to be clearer Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/stats_histogram.h ('k') | net/dns/dns_session.cc » ('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 "net/disk_cache/stats_histogram.h" 5 #include "net/disk_cache/stats_histogram.h"
6 6
7 #include "base/debug/leak_annotations.h" 7 #include "base/debug/leak_annotations.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/bucket_ranges.h" 9 #include "base/metrics/bucket_ranges.h"
10 #include "base/metrics/histogram_base.h" 10 #include "base/metrics/histogram_base.h"
11 #include "base/metrics/sample_vector.h" 11 #include "base/metrics/sample_vector.h"
12 #include "base/metrics/statistics_recorder.h" 12 #include "base/metrics/statistics_recorder.h"
13 #include "net/disk_cache/stats.h" 13 #include "net/disk_cache/stats.h"
14 14
15 namespace disk_cache { 15 namespace disk_cache {
16 16
17 using base::BucketRanges; 17 using base::BucketRanges;
18 using base::Histogram; 18 using base::Histogram;
19 using base::HistogramSamples; 19 using base::HistogramSamples;
20 using base::SampleVector; 20 using base::SampleVector;
21 using base::StatisticsRecorder; 21 using base::StatisticsRecorder;
22 22
23 StatsHistogram::StatsHistogram(const std::string& name, 23 StatsHistogram::StatsHistogram(const std::string& name,
24 Sample minimum, 24 Sample minimum,
25 Sample maximum, 25 Sample maximum,
26 size_t bucket_count,
27 const BucketRanges* ranges, 26 const BucketRanges* ranges,
28 const Stats* stats) 27 const Stats* stats)
29 : Histogram(name, minimum, maximum, bucket_count, ranges), 28 : Histogram(name, minimum, maximum, ranges),
30 stats_(stats) {} 29 stats_(stats) {}
31 30
32 StatsHistogram::~StatsHistogram() {} 31 StatsHistogram::~StatsHistogram() {}
33 32
34 // static 33 // static
35 void StatsHistogram::InitializeBucketRanges(const Stats* stats, 34 void StatsHistogram::InitializeBucketRanges(const Stats* stats,
36 BucketRanges* ranges) { 35 BucketRanges* ranges) {
37 for (size_t i = 0; i < ranges->size(); i++) { 36 for (size_t i = 0; i < ranges->size(); ++i) {
38 ranges->set_range(i, stats->GetBucketRange(i)); 37 ranges->set_range(i, stats->GetBucketRange(i));
39 } 38 }
40 ranges->ResetChecksum(); 39 ranges->ResetChecksum();
41 } 40 }
42 41
43 StatsHistogram* StatsHistogram::FactoryGet(const std::string& name, 42 StatsHistogram* StatsHistogram::FactoryGet(const std::string& name,
44 const Stats* stats) { 43 const Stats* stats) {
45 Sample minimum = 1; 44 Sample minimum = 1;
46 Sample maximum = disk_cache::Stats::kDataSizesLength - 1; 45 Sample maximum = disk_cache::Stats::kDataSizesLength - 1;
47 size_t bucket_count = disk_cache::Stats::kDataSizesLength; 46 size_t bucket_count = disk_cache::Stats::kDataSizesLength;
48 HistogramBase* histogram = StatisticsRecorder::FindHistogram(name); 47 HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
49 if (!histogram) { 48 if (!histogram) {
50 DCHECK(stats); 49 DCHECK(stats);
51 50
52 // To avoid racy destruction at shutdown, the following will be leaked. 51 // To avoid racy destruction at shutdown, the following will be leaked.
53 BucketRanges* ranges = new BucketRanges(bucket_count + 1); 52 BucketRanges* ranges = new BucketRanges(bucket_count + 1);
54 InitializeBucketRanges(stats, ranges); 53 InitializeBucketRanges(stats, ranges);
55 const BucketRanges* registered_ranges = 54 const BucketRanges* registered_ranges =
56 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); 55 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges);
57 56
58 // To avoid racy destruction at shutdown, the following will be leaked. 57 // To avoid racy destruction at shutdown, the following will be leaked.
59 StatsHistogram* stats_histogram = 58 StatsHistogram* stats_histogram =
60 new StatsHistogram(name, minimum, maximum, bucket_count, 59 new StatsHistogram(name, minimum, maximum, registered_ranges, stats);
61 registered_ranges, stats);
62 stats_histogram->SetFlags(kUmaTargetedHistogramFlag); 60 stats_histogram->SetFlags(kUmaTargetedHistogramFlag);
63 histogram = StatisticsRecorder::RegisterOrDeleteDuplicate(stats_histogram); 61 histogram = StatisticsRecorder::RegisterOrDeleteDuplicate(stats_histogram);
64 } 62 }
65 63
66 DCHECK(base::HISTOGRAM == histogram->GetHistogramType()); 64 DCHECK(base::HISTOGRAM == histogram->GetHistogramType());
67 DCHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); 65 DCHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
68 66
69 // We're preparing for an otherwise unsafe upcast by ensuring we have the 67 // We're preparing for an otherwise unsafe upcast by ensuring we have the
70 // proper class type. 68 // proper class type.
71 StatsHistogram* return_histogram = static_cast<StatsHistogram*>(histogram); 69 StatsHistogram* return_histogram = static_cast<StatsHistogram*>(histogram);
(...skipping 10 matching lines...) Expand all
82 80
83 return samples.PassAs<HistogramSamples>(); 81 return samples.PassAs<HistogramSamples>();
84 } 82 }
85 83
86 int StatsHistogram::FindCorruption(const HistogramSamples& samples) const { 84 int StatsHistogram::FindCorruption(const HistogramSamples& samples) const {
87 // This class won't monitor inconsistencies. 85 // This class won't monitor inconsistencies.
88 return HistogramBase::NO_INCONSISTENCIES; 86 return HistogramBase::NO_INCONSISTENCIES;
89 } 87 }
90 88
91 } // namespace disk_cache 89 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/stats_histogram.h ('k') | net/dns/dns_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698