Index: base/metrics/histogram.cc |
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc |
index 7ff1b16184f10c9e54dd501b1b95a1f34fefc253..fb9ca9d4473d8e1c7b2811bcf3edae5c13c47e67 100644 |
--- a/base/metrics/histogram.cc |
+++ b/base/metrics/histogram.cc |
@@ -271,17 +271,28 @@ bool Histogram::HasConstructionArguments(Sample expected_minimum, |
(expected_bucket_count == bucket_count())); |
} |
+int ClampValue(int value) { |
Alexei Svitkine (slow)
2015/08/03 18:15:42
Put this in the anon namespace at the top of the f
amohammadkhan
2015/08/04 18:22:51
Done.
|
+ if (value > Histogram::kSampleType_MAX - 1) |
+ return Histogram::kSampleType_MAX - 1; |
+ if (value < 0) |
+ return 0; |
+ return value; |
+} |
+ |
void Histogram::Add(int value) { |
+ AddCount(value, 1); |
+} |
+ |
+void Histogram::AddCount(int value, int count) { |
DCHECK_EQ(0, ranges(0)); |
DCHECK_EQ(kSampleType_MAX, ranges(bucket_count())); |
+ if (count < 0) { |
Alexei Svitkine (slow)
2015/08/03 18:15:42
If the body is a single line, no need for {}'s.
amohammadkhan
2015/08/04 18:22:51
Done.
|
+ count = 0; |
Alexei Svitkine (slow)
2015/08/03 18:15:42
Seems like a count of 0 would actually not change
amohammadkhan
2015/08/04 18:22:51
Done.
|
+ } |
+ int clamped_value = ClampValue(value); |
+ samples_->Accumulate(clamped_value, count); |
- if (value > kSampleType_MAX - 1) |
- value = kSampleType_MAX - 1; |
- if (value < 0) |
- value = 0; |
- samples_->Accumulate(value, 1); |
- |
- FindAndRunCallback(value); |
+ FindAndRunCallback(clamped_value); |
} |
scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const { |