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

Side by Side Diff: base/metrics/bucket_ranges.h

Issue 10834011: Refactor of Histogram related code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // BucketRanges stores the vector of ranges that delimit what samples are 5 // BucketRanges stores the vector of ranges that delimit what samples are
6 // tallied in the corresponding buckets of a histogram. Histograms that have 6 // tallied in the corresponding buckets of a histogram. Histograms that have
7 // same ranges for all their corresponding buckets should share the same 7 // same ranges for all their corresponding buckets should share the same
8 // BucketRanges object. 8 // BucketRanges object.
9 // 9 //
10 // E.g. A 5 buckets LinearHistogram with 1 as minimal value and 4 as maximal 10 // E.g. A 5 buckets LinearHistogram with 1 as minimal value and 4 as maximal
(...skipping 23 matching lines...) Expand all
34 ~BucketRanges(); 34 ~BucketRanges();
35 35
36 size_t size() const { return ranges_.size(); } 36 size_t size() const { return ranges_.size(); }
37 HistogramBase::Sample range(size_t i) const { return ranges_[i]; } 37 HistogramBase::Sample range(size_t i) const { return ranges_[i]; }
38 void set_range(size_t i, HistogramBase::Sample value); 38 void set_range(size_t i, HistogramBase::Sample value);
39 uint32 checksum() const { return checksum_; } 39 uint32 checksum() const { return checksum_; }
40 void set_checksum(uint32 checksum) { checksum_ = checksum; } 40 void set_checksum(uint32 checksum) { checksum_ = checksum; }
41 41
42 // Checksum methods to verify whether the ranges are corrupted (e.g. bad 42 // Checksum methods to verify whether the ranges are corrupted (e.g. bad
43 // memory access). 43 // memory access).
44 uint32 CalculateChecksum(); 44 uint32 CalculateChecksum() const;
45 bool HasValidChecksum(); 45 bool HasValidChecksum() const;
46 void ResetChecksum(); 46 void ResetChecksum();
47 47
48 // Return true iff |other| object has same ranges_ as |this| object's ranges_. 48 // Return true iff |other| object has same ranges_ as |this| object's ranges_.
49 bool Equals(const BucketRanges* other) const; 49 bool Equals(const BucketRanges* other) const;
50 50
51 private: 51 private:
52 // A monotonically increasing list of values which determine which bucket to 52 // A monotonically increasing list of values which determine which bucket to
53 // put a sample into. For each index, show the smallest sample that can be 53 // put a sample into. For each index, show the smallest sample that can be
54 // added to the corresponding bucket. 54 // added to the corresponding bucket.
55 Ranges ranges_; 55 Ranges ranges_;
56 56
57 // Checksum for the conntents of ranges_. Used to detect random over-writes 57 // Checksum for the conntents of ranges_. Used to detect random over-writes
58 // of our data, and to quickly see if some other BucketRanges instance is 58 // of our data, and to quickly see if some other BucketRanges instance is
59 // possibly Equal() to this instance. 59 // possibly Equal() to this instance.
60 // TODO(kaiwang): Consider change this to uint64. Because we see a lot of 60 // TODO(kaiwang): Consider change this to uint64. Because we see a lot of
61 // noise on UMA dashboard. 61 // noise on UMA dashboard.
62 uint32 checksum_; 62 uint32 checksum_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(BucketRanges); 64 DISALLOW_COPY_AND_ASSIGN(BucketRanges);
65 }; 65 };
66 66
67 //////////////////////////////////////////////////////////////////////////////
68 // Expose only for test.
69 BASE_EXPORT_PRIVATE extern const uint32 kCrcTable[256];
70
67 } // namespace base 71 } // namespace base
68 72
69 #endif // BASE_METRICS_BUCKET_RANGES_H_ 73 #endif // BASE_METRICS_BUCKET_RANGES_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/metrics/bucket_ranges.cc » ('j') | base/metrics/histogram.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698