| 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 "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" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); | 56 StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); |
| 57 | 57 |
| 58 // To avoid racy destruction at shutdown, the following will be leaked. | 58 // To avoid racy destruction at shutdown, the following will be leaked. |
| 59 StatsHistogram* stats_histogram = | 59 StatsHistogram* stats_histogram = |
| 60 new StatsHistogram(name, minimum, maximum, bucket_count, | 60 new StatsHistogram(name, minimum, maximum, bucket_count, |
| 61 registered_ranges, stats); | 61 registered_ranges, stats); |
| 62 stats_histogram->SetFlags(kUmaTargetedHistogramFlag); | 62 stats_histogram->SetFlags(kUmaTargetedHistogramFlag); |
| 63 histogram = StatisticsRecorder::RegisterOrDeleteDuplicate(stats_histogram); | 63 histogram = StatisticsRecorder::RegisterOrDeleteDuplicate(stats_histogram); |
| 64 } | 64 } |
| 65 | 65 |
| 66 DCHECK(HISTOGRAM == histogram->histogram_type()); | 66 DCHECK(base::HISTOGRAM == histogram->GetHistogramType()); |
| 67 DCHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); | 67 DCHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); |
| 68 | 68 |
| 69 // We're preparing for an otherwise unsafe upcast by ensuring we have the | 69 // We're preparing for an otherwise unsafe upcast by ensuring we have the |
| 70 // proper class type. | 70 // proper class type. |
| 71 StatsHistogram* return_histogram = static_cast<StatsHistogram*>(histogram); | 71 StatsHistogram* return_histogram = static_cast<StatsHistogram*>(histogram); |
| 72 return return_histogram; | 72 return return_histogram; |
| 73 } | 73 } |
| 74 | 74 |
| 75 scoped_ptr<HistogramSamples> StatsHistogram::SnapshotSamples() const { | 75 scoped_ptr<HistogramSamples> StatsHistogram::SnapshotSamples() const { |
| 76 scoped_ptr<SampleVector> samples(new SampleVector(bucket_ranges())); | 76 scoped_ptr<SampleVector> samples(new SampleVector(bucket_ranges())); |
| 77 stats_->Snapshot(samples.get()); | 77 stats_->Snapshot(samples.get()); |
| 78 | 78 |
| 79 // Only report UMA data once. | 79 // Only report UMA data once. |
| 80 StatsHistogram* mutable_me = const_cast<StatsHistogram*>(this); | 80 StatsHistogram* mutable_me = const_cast<StatsHistogram*>(this); |
| 81 mutable_me->ClearFlags(kUmaTargetedHistogramFlag); | 81 mutable_me->ClearFlags(kUmaTargetedHistogramFlag); |
| 82 | 82 |
| 83 return samples.PassAs<HistogramSamples>(); | 83 return samples.PassAs<HistogramSamples>(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 Histogram::Inconsistencies StatsHistogram::FindCorruption( | 86 Histogram::Inconsistencies StatsHistogram::FindCorruption( |
| 87 const HistogramSamples& samples) const { | 87 const HistogramSamples& samples) const { |
| 88 return NO_INCONSISTENCIES; // This class won't monitor inconsistencies. | 88 return NO_INCONSISTENCIES; // This class won't monitor inconsistencies. |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace disk_cache | 91 } // namespace disk_cache |
| OLD | NEW |