| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/disk_cache/stats.h" | 8 #include "net/disk_cache/stats.h" |
| 9 | 9 |
| 10 namespace disk_cache { | 10 namespace disk_cache { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 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.get() != NULL); | 33 DCHECK(histogram.get() != NULL); |
| 34 } else { | 34 } else { |
| 35 StatsHistogram* stats_histogram = new StatsHistogram(name, minimum, maximum, | 35 StatsHistogram* stats_histogram = new StatsHistogram(name, minimum, maximum, |
| 36 bucket_count); | 36 bucket_count); |
| 37 stats_histogram->InitializeBucketRange(); | 37 stats_histogram->InitializeBucketRange(); |
| 38 histogram = stats_histogram; | 38 histogram = stats_histogram; |
| 39 StatisticsRecorder::Register(&histogram); | 39 StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); |
| 40 } | 40 } |
| 41 | 41 |
| 42 DCHECK(HISTOGRAM == histogram->histogram_type()); | 42 DCHECK(HISTOGRAM == histogram->histogram_type()); |
| 43 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count)); | 43 DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count)); |
| 44 | 44 |
| 45 // We're preparing for an otherwise unsafe upcast by ensuring we have the | 45 // We're preparing for an otherwise unsafe upcast by ensuring we have the |
| 46 // proper class type. | 46 // proper class type. |
| 47 Histogram* temp_histogram = histogram.get(); | 47 Histogram* temp_histogram = histogram.get(); |
| 48 StatsHistogram* temp_stats_histogram = | 48 StatsHistogram* temp_stats_histogram = |
| 49 static_cast<StatsHistogram*>(temp_histogram); | 49 static_cast<StatsHistogram*>(temp_histogram); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return NO_INCONSISTENCIES; // This class won't monitor inconsistencies. | 93 return NO_INCONSISTENCIES; // This class won't monitor inconsistencies. |
| 94 } | 94 } |
| 95 | 95 |
| 96 uint32 StatsHistogram::CalculateRangeChecksum() const { | 96 uint32 StatsHistogram::CalculateRangeChecksum() const { |
| 97 // We don't calculate checksums, so at least establish a unique constant. | 97 // We don't calculate checksums, so at least establish a unique constant. |
| 98 const uint32 kStatsHistogramChecksum = 0x0cecce; | 98 const uint32 kStatsHistogramChecksum = 0x0cecce; |
| 99 return kStatsHistogramChecksum; | 99 return kStatsHistogramChecksum; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace disk_cache | 102 } // namespace disk_cache |
| OLD | NEW |