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

Unified Diff: net/disk_cache/stats_histogram.cc

Issue 6577013: Crash when we notice a corruption of the histogram range-vector... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« base/metrics/histogram.h ('K') | « net/disk_cache/stats_histogram.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, &registered_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
« base/metrics/histogram.h ('K') | « net/disk_cache/stats_histogram.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698