OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 8 #include "base/logging.h" |
8 #include "net/disk_cache/stats.h" | 9 #include "net/disk_cache/stats.h" |
9 | 10 |
10 namespace disk_cache { | 11 namespace disk_cache { |
11 | 12 |
12 using base::Histogram; | 13 using base::Histogram; |
13 using base::StatisticsRecorder; | 14 using base::StatisticsRecorder; |
14 | 15 |
15 // Static. | 16 // Static. |
16 const Stats* StatsHistogram::stats_ = NULL; | 17 const Stats* StatsHistogram::stats_ = NULL; |
17 | 18 |
18 StatsHistogram::~StatsHistogram() { | 19 StatsHistogram::~StatsHistogram() { |
19 // Only cleanup what we set. | 20 // Only cleanup what we set. |
20 if (init_) | 21 if (init_) |
21 stats_ = NULL; | 22 stats_ = NULL; |
22 } | 23 } |
23 | 24 |
24 StatsHistogram* StatsHistogram::StatsHistogramFactoryGet( | 25 StatsHistogram* StatsHistogram::FactoryGet(const std::string& name) { |
25 const std::string& name) { | |
26 Histogram* histogram(NULL); | 26 Histogram* histogram(NULL); |
27 | 27 |
28 Sample minimum = 1; | 28 Sample minimum = 1; |
29 Sample maximum = disk_cache::Stats::kDataSizesLength - 1; | 29 Sample maximum = disk_cache::Stats::kDataSizesLength - 1; |
30 size_t bucket_count = disk_cache::Stats::kDataSizesLength; | 30 size_t bucket_count = disk_cache::Stats::kDataSizesLength; |
31 | 31 |
32 if (StatisticsRecorder::FindHistogram(name, &histogram)) { | 32 if (StatisticsRecorder::FindHistogram(name, &histogram)) { |
33 DCHECK(histogram != NULL); | 33 DCHECK(histogram != NULL); |
34 } else { | 34 } else { |
35 // To avoid racy destruction at shutdown, the following will be leaked. | 35 // To avoid racy destruction at shutdown, the following will be leaked. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 return NO_INCONSISTENCIES; // This class won't monitor inconsistencies. | 89 return NO_INCONSISTENCIES; // This class won't monitor inconsistencies. |
90 } | 90 } |
91 | 91 |
92 uint32 StatsHistogram::CalculateRangeChecksum() const { | 92 uint32 StatsHistogram::CalculateRangeChecksum() const { |
93 // We don't calculate checksums, so at least establish a unique constant. | 93 // We don't calculate checksums, so at least establish a unique constant. |
94 const uint32 kStatsHistogramChecksum = 0x0cecce; | 94 const uint32 kStatsHistogramChecksum = 0x0cecce; |
95 return kStatsHistogramChecksum; | 95 return kStatsHistogramChecksum; |
96 } | 96 } |
97 | 97 |
98 } // namespace disk_cache | 98 } // namespace disk_cache |
OLD | NEW |