summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 03:00:22 +0000
committerdpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 03:00:22 +0000
commitb17e19920b54ca8b92d73dcb1cc03dae1d6b7ad0 (patch)
tree2d27c7d9155537e97658de58f05ed67574a08fc9
parent8a6fff63eb3652086fa86bfc23f0d65aa2ee4547 (diff)
downloadchromium_src-b17e19920b54ca8b92d73dcb1cc03dae1d6b7ad0.zip
chromium_src-b17e19920b54ca8b92d73dcb1cc03dae1d6b7ad0.tar.gz
chromium_src-b17e19920b54ca8b92d73dcb1cc03dae1d6b7ad0.tar.bz2
Revert 63011 - Convert a lot of DCHECK()s to DCHECK_EQ() and similar, so that when they fail they print the values in question.
BUG=none TEST=none Review URL: http://codereview.chromium.org/3828013 TBR=pkasting@chromium.org, jamesr@chromium.org Review URL: http://codereview.chromium.org/3854004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63012 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/metrics/histogram.cc91
1 files changed, 45 insertions, 46 deletions
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index e07b3a8..9746e9c 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -28,9 +28,9 @@ scoped_refptr<Histogram> Histogram::FactoryGet(const std::string& name,
scoped_refptr<Histogram> histogram(NULL);
// Defensive code.
- if (minimum < 1)
+ if (minimum <= 0)
minimum = 1;
- if (maximum > kSampleType_MAX - 1)
+ if (maximum >= kSampleType_MAX)
maximum = kSampleType_MAX - 1;
if (!StatisticsRecorder::FindHistogram(name, &histogram)) {
@@ -38,7 +38,7 @@ scoped_refptr<Histogram> Histogram::FactoryGet(const std::string& name,
StatisticsRecorder::FindHistogram(name, &histogram);
}
- DCHECK_EQ(HISTOGRAM, histogram->histogram_type());
+ DCHECK(HISTOGRAM == histogram->histogram_type());
DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
histogram->SetFlags(flags);
return histogram;
@@ -93,13 +93,13 @@ bool Histogram::PrintEmptyBucket(size_t index) const {
}
void Histogram::Add(int value) {
- if (value > kSampleType_MAX - 1)
+ if (value >= kSampleType_MAX)
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));
+ DCHECK(value >= ranges(index));
+ DCHECK(value < ranges(index + 1));
Accumulate(value, 1, index);
}
@@ -184,30 +184,30 @@ void Histogram::WriteAscii(bool graph_it, const std::string& newline,
output->append(newline);
past += current;
}
- DCHECK_EQ(sample_count, past);
+ DCHECK(past == sample_count);
}
bool Histogram::ValidateBucketRanges() const {
// Standard assertions that all bucket ranges should satisfy.
- DCHECK_EQ(bucket_count_ + 1, ranges_.size());
- DCHECK_EQ(0, ranges_[0]);
- DCHECK_EQ(declared_min(), ranges_[1]);
- DCHECK_EQ(declared_max(), ranges_[bucket_count_ - 1]);
- DCHECK_EQ(kSampleType_MAX, ranges_[bucket_count_]);
+ DCHECK(ranges_.size() == bucket_count_ + 1);
+ DCHECK_EQ(ranges_[0], 0);
+ DCHECK(declared_min() == ranges_[1]);
+ DCHECK(declared_max() == ranges_[bucket_count_ - 1]);
+ DCHECK(kSampleType_MAX == ranges_[bucket_count_]);
return true;
}
void Histogram::Initialize() {
sample_.Resize(*this);
- if (declared_min_ < 1)
+ if (declared_min_ <= 0)
declared_min_ = 1;
- if (declared_max_ > kSampleType_MAX - 1)
+ if (declared_max_ >= kSampleType_MAX)
declared_max_ = kSampleType_MAX - 1;
- DCHECK_LE(declared_min_, declared_max_);
+ DCHECK(declared_min_ <= declared_max_);
DCHECK_GT(bucket_count_, 1u);
size_t maximal_bucket_count = declared_max_ - declared_min_ + 2;
- DCHECK_LE(bucket_count_, maximal_bucket_count);
- DCHECK_EQ(0, ranges_[0]);
+ DCHECK(bucket_count_ <= maximal_bucket_count);
+ DCHECK_EQ(ranges_[0], 0);
ranges_[bucket_count_] = kSampleType_MAX;
InitializeBucketRange();
DCHECK(ValidateBucketRanges());
@@ -245,20 +245,20 @@ void Histogram::InitializeBucketRange() {
SetBucketRange(bucket_index, current);
}
- DCHECK_EQ(bucket_count(), bucket_index);
+ DCHECK(bucket_count() == bucket_index);
}
size_t Histogram::BucketIndex(Sample value) const {
// Use simple binary search. This is very general, but there are better
// approaches if we knew that the buckets were linearly distributed.
- DCHECK_LE(ranges(0), value);
- DCHECK_GT(ranges(bucket_count()), value);
+ DCHECK(ranges(0) <= value);
+ DCHECK(ranges(bucket_count()) > value);
size_t under = 0;
size_t over = bucket_count();
size_t mid;
do {
- DCHECK_GE(over, under);
+ DCHECK(over >= under);
mid = (over + under)/2;
if (mid == under)
break;
@@ -268,8 +268,7 @@ size_t Histogram::BucketIndex(Sample value) const {
over = mid;
} while (true);
- DCHECK_LE(ranges(mid), value);
- DCHECK_GT(ranges(mid+1), value);
+ DCHECK(ranges(mid) <= value && ranges(mid+1) > value);
return mid;
}
@@ -279,7 +278,7 @@ size_t Histogram::BucketIndex(Sample value) const {
// buckets), so we need this to make it possible to see what is going on and
// not have 0-graphical-height buckets.
double Histogram::GetBucketSize(Count current, size_t i) const {
- DCHECK_GT(ranges(i + 1), ranges(i));
+ DCHECK(ranges(i + 1) > ranges(i));
static const double kTransitionWidth = 5;
double denominator = ranges(i + 1) - ranges(i);
if (denominator > kTransitionWidth)
@@ -326,7 +325,7 @@ bool Histogram::HasConstructorTimeDeltaArguments(TimeDelta minimum,
// Accessor methods
void Histogram::SetBucketRange(size_t i, Sample value) {
- DCHECK_GT(bucket_count_, i);
+ DCHECK(bucket_count_ > i);
ranges_[i] = value;
}
@@ -410,7 +409,7 @@ void Histogram::WriteAsciiBucketGraph(double current_size, double max_size,
// static
std::string Histogram::SerializeHistogramInfo(const Histogram& histogram,
const SampleSet& snapshot) {
- DCHECK_NE(NOT_VALID_IN_RENDERER, histogram.histogram_type());
+ DCHECK(histogram.histogram_type() != NOT_VALID_IN_RENDERER);
Pickle pickle;
pickle.WriteString(histogram.histogram_name());
@@ -462,7 +461,7 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) {
Flags flags = static_cast<Flags>(pickle_flags & ~kIPCSerializationSourceFlag);
- DCHECK_NE(NOT_VALID_IN_RENDERER, histogram_type);
+ DCHECK(histogram_type != NOT_VALID_IN_RENDERER);
scoped_refptr<Histogram> render_histogram(NULL);
@@ -475,21 +474,21 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) {
} else if (histogram_type == BOOLEAN_HISTOGRAM) {
render_histogram = BooleanHistogram::FactoryGet(histogram_name, flags);
} else {
- LOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: "
- << histogram_type;
+ LOG(ERROR) << "Error Deserializing Histogram Unknown histogram_type: " <<
+ histogram_type;
return false;
}
- DCHECK_EQ(render_histogram->declared_min(), declared_min);
- DCHECK_EQ(render_histogram->declared_max(), declared_max);
- DCHECK_EQ(render_histogram->bucket_count(), bucket_count);
- DCHECK_EQ(render_histogram->histogram_type(), histogram_type);
+ DCHECK(declared_min == render_histogram->declared_min());
+ DCHECK(declared_max == render_histogram->declared_max());
+ DCHECK(bucket_count == render_histogram->bucket_count());
+ DCHECK(histogram_type == render_histogram->histogram_type());
if (render_histogram->flags() & kIPCSerializationSourceFlag) {
- DVLOG(1) << "Single process mode, histogram observed and not copied: "
- << histogram_name;
+ DLOG(INFO) << "Single process mode, histogram observed and not copied: " <<
+ histogram_name;
} else {
- DCHECK_EQ(flags & render_histogram->flags(), flags);
+ DCHECK(flags == (flags & render_histogram->flags()));
render_histogram->AddSampleSet(sample);
}
@@ -514,7 +513,7 @@ void Histogram::SampleSet::Resize(const Histogram& histogram) {
}
void Histogram::SampleSet::CheckSize(const Histogram& histogram) const {
- DCHECK_EQ(histogram.bucket_count(), counts_.size());
+ DCHECK(counts_.size() == histogram.bucket_count());
}
@@ -540,7 +539,7 @@ Count Histogram::SampleSet::TotalCount() const {
}
void Histogram::SampleSet::Add(const SampleSet& other) {
- DCHECK_EQ(counts_.size(), other.counts_.size());
+ DCHECK(counts_.size() == other.counts_.size());
sum_ += other.sum_;
square_sum_ += other.square_sum_;
for (size_t index = 0; index < counts_.size(); ++index)
@@ -548,7 +547,7 @@ void Histogram::SampleSet::Add(const SampleSet& other) {
}
void Histogram::SampleSet::Subtract(const SampleSet& other) {
- DCHECK_EQ(counts_.size(), other.counts_.size());
+ DCHECK(counts_.size() == other.counts_.size());
// Note: Race conditions in snapshotting a sum or square_sum may lead to
// (temporary) negative values when snapshots are later combined (and deltas
// calculated). As a result, we don't currently CHCEK() for positive values.
@@ -610,9 +609,9 @@ scoped_refptr<Histogram> LinearHistogram::FactoryGet(const std::string& name,
Flags flags) {
scoped_refptr<Histogram> histogram(NULL);
- if (minimum < 1)
+ if (minimum <= 0)
minimum = 1;
- if (maximum > kSampleType_MAX - 1)
+ if (maximum >= kSampleType_MAX)
maximum = kSampleType_MAX - 1;
if (!StatisticsRecorder::FindHistogram(name, &histogram)) {
@@ -620,7 +619,7 @@ scoped_refptr<Histogram> LinearHistogram::FactoryGet(const std::string& name,
StatisticsRecorder::FindHistogram(name, &histogram);
}
- DCHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type());
+ DCHECK(LINEAR_HISTOGRAM == histogram->histogram_type());
DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count));
histogram->SetFlags(flags);
return histogram;
@@ -697,7 +696,7 @@ void LinearHistogram::InitializeBucketRange() {
}
double LinearHistogram::GetBucketSize(Count current, size_t i) const {
- DCHECK_GT(ranges(i + 1), ranges(i));
+ DCHECK(ranges(i + 1) > ranges(i));
// Adjacent buckets with different widths would have "surprisingly" many (few)
// samples in a histogram if we didn't normalize this way.
double denominator = ranges(i + 1) - ranges(i);
@@ -717,7 +716,7 @@ scoped_refptr<Histogram> BooleanHistogram::FactoryGet(const std::string& name,
StatisticsRecorder::FindHistogram(name, &histogram);
}
- DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type());
+ DCHECK(BOOLEAN_HISTOGRAM == histogram->histogram_type());
histogram->SetFlags(flags);
return histogram;
}
@@ -786,7 +785,7 @@ CustomHistogram::CustomHistogram(const std::string& name,
}
void CustomHistogram::InitializeBucketRange() {
- DCHECK_LE(ranges_vector_->size(), bucket_count());
+ DCHECK(ranges_vector_->size() <= bucket_count());
for (size_t index = 0; index < ranges_vector_->size(); ++index)
SetBucketRange(index, (*ranges_vector_)[index]);
}
@@ -897,7 +896,7 @@ void StatisticsRecorder::GetHistograms(Histograms* output) {
for (HistogramMap::iterator it = histograms_->begin();
histograms_->end() != it;
++it) {
- DCHECK_EQ(it->first, it->second->histogram_name());
+ DCHECK(it->second->histogram_name() == it->first);
output->push_back(it->second);
}
}