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

Unified Diff: base/metrics/histogram.h

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
« no previous file with comments | « no previous file | base/metrics/histogram.cc » ('j') | base/metrics/histogram.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram.h
===================================================================
--- base/metrics/histogram.h (revision 75929)
+++ base/metrics/histogram.h (working copy)
@@ -411,7 +411,7 @@
Sample declared_min() const { return declared_min_; }
Sample declared_max() const { return declared_max_; }
virtual Sample ranges(size_t i) const;
- Sample range_checksum() const { return range_checksum_; }
+ uint32 range_checksum() const { return range_checksum_; }
virtual size_t bucket_count() const;
// Snapshot the current complete set of sample data.
// Override with atomic/locked snapshot if needed.
@@ -473,6 +473,8 @@
// Allow tests to corrupt our innards for testing purposes.
FRIEND_TEST(HistogramTest, CorruptBucketBounds);
FRIEND_TEST(HistogramTest, CorruptSampleCounts);
+ FRIEND_TEST(HistogramTest, Crc32SampleHash);
+ FRIEND_TEST(HistogramTest, Crc32TableTest);
// Post constructor initialization.
void Initialize();
@@ -480,8 +482,11 @@
// Return true iff the range_checksum_ matches current ranges_ vector.
bool HasValidRangeChecksum() const;
- Sample CalculateRangeChecksum() const;
+ uint32 CalculateRangeChecksum() const;
+ // Checksum function for accumulating range values into a checksum.
+ static uint32 Crc32(uint32 sum, Sample range);
+
//----------------------------------------------------------------------------
// Helpers for emitting Ascii graphic. Each method appends data to output.
@@ -508,6 +513,9 @@
std::string* output) const;
//----------------------------------------------------------------------------
+ // Table for generating Crc32 values.
+ static const uint32 kCrcTable[256];
+ //----------------------------------------------------------------------------
// Invariant values set at/near construction time
// ASCII version of original name given to the constructor. All identically
@@ -526,10 +534,10 @@
// The dimension of ranges_ is bucket_count + 1.
Ranges ranges_;
- // For redundancy, we store the sum of all the sample ranges when ranges are
- // generated. If ever there is ever a difference, then the histogram must
+ // For redundancy, we store a checksum of all the sample ranges when ranges
+ // are generated. If ever there is ever a difference, then the histogram must
// have been corrupted.
- Sample range_checksum_;
+ uint32 range_checksum_;
// Finally, provide the state that changes with the addition of each new
// sample.
« no previous file with comments | « no previous file | base/metrics/histogram.cc » ('j') | base/metrics/histogram.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698