summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 00:10:20 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-03 00:10:20 +0000
commit9bf0f906c4c5fd954ed424f52bc2d2ee48cf538c (patch)
tree1afde61b0d1a6d037b80bfc3404411aac1f782e1 /net/disk_cache
parent29ffc1d3e414afacbaff55b9ec74bbcccef6eb66 (diff)
downloadchromium_src-9bf0f906c4c5fd954ed424f52bc2d2ee48cf538c.zip
chromium_src-9bf0f906c4c5fd954ed424f52bc2d2ee48cf538c.tar.gz
chromium_src-9bf0f906c4c5fd954ed424f52bc2d2ee48cf538c.tar.bz2
Revert 76239 - Crash when we notice a corruption of the histogram range-vector
Reason for revert: This patch might have resulted in some flakiness in the sync bots on the chromium waterfall. The range vector is calculated once when a histogram is constructed, and should never change over the lifetime of the histogram. When it does change, it means that memory is being overwritten. We now crash (via CHECK) when there is any detected corruption of the range vector. This CL uses a more robust check-sum algorithm to detect corruption of the vector. The previous algorithm just did a sum, and was too easilly tricked by small (offsetting) changes in several ranges. Hopefully, this CRC-32 implementation will not be so easilly fooled. I had to refactor the class to ensure that each histogram was completely constructed before I registered it. The old code could sometimes register a base class (tradtional Histogram, with exponential bucket spread) and then run the derived constructor (such as when creating a LinearHistogram, with a second construction of the ranges and checksum). I now carefully avoid generating the checksum until fully constructing the instance, and then I run InitializeBuckets only once on the instance before registering it. bug=73939,74467 r=mbelshe Review URL: http://codereview.chromium.org/6577013 TBR=jar@chromium.org Review URL: http://codereview.chromium.org/6611001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/stats_histogram.cc19
-rw-r--r--net/disk_cache/stats_histogram.h1
2 files changed, 6 insertions, 14 deletions
diff --git a/net/disk_cache/stats_histogram.cc b/net/disk_cache/stats_histogram.cc
index 028ae17..39c9056 100644
--- a/net/disk_cache/stats_histogram.cc
+++ b/net/disk_cache/stats_histogram.cc
@@ -32,11 +32,12 @@ scoped_refptr<StatsHistogram> StatsHistogram::StatsHistogramFactoryGet(
if (StatisticsRecorder::FindHistogram(name, &histogram)) {
DCHECK(histogram.get() != NULL);
} else {
- StatsHistogram* stats_histogram = new StatsHistogram(name, minimum, maximum,
- bucket_count);
- stats_histogram->InitializeBucketRange();
- histogram = stats_histogram;
- StatisticsRecorder::Register(&histogram);
+ 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;
}
DCHECK(HISTOGRAM == histogram->histogram_type());
@@ -47,9 +48,6 @@ scoped_refptr<StatsHistogram> StatsHistogram::StatsHistogramFactoryGet(
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;
}
@@ -93,10 +91,5 @@ Histogram::Inconsistencies StatsHistogram::FindCorruption(
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
diff --git a/net/disk_cache/stats_histogram.h b/net/disk_cache/stats_histogram.h
index 249327c..499784c 100644
--- a/net/disk_cache/stats_histogram.h
+++ b/net/disk_cache/stats_histogram.h
@@ -45,7 +45,6 @@ class StatsHistogram : public base::Histogram {
virtual size_t bucket_count() const;
virtual void SnapshotSample(SampleSet* sample) const;
virtual Inconsistencies FindCorruption(const SampleSet& snapshot) const;
- virtual uint32 CalculateRangeChecksum() const;
private:
bool init_;