Chromium Code Reviews| Index: net/disk_cache/stats_histogram.cc |
| =================================================================== |
| --- net/disk_cache/stats_histogram.cc (revision 76117) |
| +++ net/disk_cache/stats_histogram.cc (working copy) |
| @@ -32,12 +32,11 @@ |
| if (StatisticsRecorder::FindHistogram(name, &histogram)) { |
| DCHECK(histogram.get() != NULL); |
| } else { |
| - histogram = new StatsHistogram(name, minimum, maximum, bucket_count); |
| - scoped_refptr<Histogram> registered_histogram(NULL); |
| - StatisticsRecorder::FindHistogram(name, ®istered_histogram); |
| - if (registered_histogram.get() != NULL && |
| - registered_histogram.get() != histogram.get()) |
| - histogram = registered_histogram; |
| + StatsHistogram* stats_histogram = new StatsHistogram(name, minimum, maximum, |
|
rvargas (doing something else)
2011/02/28 19:50:53
Why use a temp variable at all?
jar (doing other things)
2011/02/28 22:11:44
This is subtle, and perchance worth a comment.
If
rvargas (doing something else)
2011/02/28 23:05:33
Thanks for the explanation. Wouldn't it be better
jar (doing other things)
2011/03/01 00:21:18
You're code was fairly special (starting around li
|
| + bucket_count); |
| + stats_histogram->InitializeBucketRange(); |
| + histogram = stats_histogram; |
| + StatisticsRecorder::Register(&histogram); |
| } |
| DCHECK(HISTOGRAM == histogram->histogram_type()); |
| @@ -48,6 +47,9 @@ |
| Histogram* temp_histogram = histogram.get(); |
| StatsHistogram* temp_stats_histogram = |
| static_cast<StatsHistogram*>(temp_histogram); |
| + // Validate upcast by seeing that we're probably providing the checksum. |
| + CHECK_EQ(temp_stats_histogram->StatsHistogram::CalculateRangeChecksum(), |
| + temp_stats_histogram->CalculateRangeChecksum()); |
| scoped_refptr<StatsHistogram> return_histogram(temp_stats_histogram); |
| return return_histogram; |
| } |
| @@ -91,5 +93,10 @@ |
| return NO_INCONSISTENCIES; // This class won't monitor inconsistencies. |
| } |
| +uint32 StatsHistogram::CalculateRangeChecksum() const { |
| + // We don't calculate checksums, so at least establish a unique constant. |
| + const uint32 kStatsHistogramChecksum = 0x0cecce; |
| + return kStatsHistogramChecksum; |
| +} |
| } // namespace disk_cache |