| 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.
|
|
|