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

Unified Diff: base/metrics/histogram_samples.h

Issue 2853853002: Fix overflow when logging MaxInt32 to a sparse histogram. (Closed)
Patch Set: Created 3 years, 8 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_samples.cc » ('j') | base/metrics/persistent_sample_map.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_samples.h
diff --git a/base/metrics/histogram_samples.h b/base/metrics/histogram_samples.h
index 0e24c4f160e7a2a29f83eefc554efbf2dffc80f4..9a4829ae84a594f54f78ca2054b571ca7bfd46da 100644
--- a/base/metrics/histogram_samples.h
+++ b/base/metrics/histogram_samples.h
@@ -198,9 +198,12 @@ class BASE_EXPORT SampleCountIterator {
// Get the sample and count at current position.
// |min| |max| and |count| can be NULL if the value is not of interest.
+ // Note: |max| is int64_t because histograms support logged values in the
+ // full int32_t range and bucket max is exclusive, so it needs to support
+ // values up to MAXINT32+1.
Ilya Sherman 2017/05/02 21:37:49 Could you add a compile-time assertion somewhere t
Alexei Svitkine (slow) 2017/05/03 15:21:53 Done.
// Requires: !Done();
virtual void Get(HistogramBase::Sample* min,
- HistogramBase::Sample* max,
+ int64_t* max,
HistogramBase::Count* count) const = 0;
// Get the index of current histogram bucket.
@@ -212,10 +215,10 @@ class BASE_EXPORT SampleCountIterator {
class BASE_EXPORT SingleSampleIterator : public SampleCountIterator {
public:
SingleSampleIterator(HistogramBase::Sample min,
- HistogramBase::Sample max,
+ int64_t max,
HistogramBase::Count count);
SingleSampleIterator(HistogramBase::Sample min,
- HistogramBase::Sample max,
+ int64_t max,
HistogramBase::Count count,
size_t bucket_index);
~SingleSampleIterator() override;
@@ -224,7 +227,7 @@ class BASE_EXPORT SingleSampleIterator : public SampleCountIterator {
bool Done() const override;
void Next() override;
void Get(HistogramBase::Sample* min,
- HistogramBase::Sample* max,
+ int64_t* max,
HistogramBase::Count* count) const override;
// SampleVector uses predefined buckets so iterator can return bucket index.
@@ -233,7 +236,7 @@ class BASE_EXPORT SingleSampleIterator : public SampleCountIterator {
private:
// Information about the single value to return.
const HistogramBase::Sample min_;
- const HistogramBase::Sample max_;
+ const int64_t max_;
const size_t bucket_index_;
HistogramBase::Count count_;
};
« no previous file with comments | « no previous file | base/metrics/histogram_samples.cc » ('j') | base/metrics/persistent_sample_map.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698