Bug 684091. Add the ability to subtract values from Histograms. r=taras

This is a copy of Add where we Accumulate with -1 instead of 1.
I'm doing this as a copy instead of factoring out the common code
to make this file easier to compare with chromium's histrogram.cc
This commit is contained in:
Jeff Muizelaar 2011-09-08 14:05:06 -04:00
parent 91be730933
commit 6969654308
2 changed files with 12 additions and 0 deletions

View File

@ -130,6 +130,17 @@ void Histogram::Add(int value) {
Accumulate(value, 1, index);
}
void Histogram::Subtract(int value) {
if (value > kSampleType_MAX - 1)
value = kSampleType_MAX - 1;
if (value < 0)
value = 0;
size_t index = BucketIndex(value);
DCHECK_GE(value, ranges(index));
DCHECK_LT(value, ranges(index + 1));
Accumulate(value, -1, index);
}
void Histogram::AddBoolean(bool value) {
DCHECK(false);
}

View File

@ -381,6 +381,7 @@ class Histogram {
Flags flags);
void Add(int value);
void Subtract(int value);
// This method is an interface, used only by BooleanHistogram.
virtual void AddBoolean(bool value);