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

Unified Diff: base/metrics/histogram.cc

Issue 10829212: CHECK -> DCHECK to prevent breaking exisitng histograms. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram.cc
===================================================================
--- base/metrics/histogram.cc (revision 150246)
+++ base/metrics/histogram.cc (working copy)
@@ -134,7 +134,9 @@
Sample maximum,
size_t bucket_count,
Flags flags) {
- CHECK(InspectConstructionArguments(name, &minimum, &maximum, &bucket_count));
+ bool valid_arguments =
+ InspectConstructionArguments(name, &minimum, &maximum, &bucket_count);
+ DCHECK(valid_arguments);
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
if (!histogram) {
@@ -465,9 +467,16 @@
DVLOG(1) << "Histogram: " << name << " has bad maximum: " << *maximum;
*maximum = kSampleType_MAX - 1;
}
+ if (*bucket_count >= kBucketCount_MAX) {
+ DVLOG(1) << "Histogram: " << name << " has bad bucket_count: "
+ << *bucket_count;
+ *bucket_count = kBucketCount_MAX - 1;
+ }
- if (*bucket_count < 3 || *bucket_count >= kBucketCount_MAX)
+ if (*minimum >= *maximum)
return false;
+ if (*bucket_count < 3)
+ return false;
if (*bucket_count > static_cast<size_t>(*maximum - *minimum + 2))
return false;
return true;
@@ -677,8 +686,9 @@
Sample maximum,
size_t bucket_count,
Flags flags) {
- CHECK(Histogram::InspectConstructionArguments(name, &minimum, &maximum,
- &bucket_count));
+ bool valid_arguments = Histogram::InspectConstructionArguments(
+ name, &minimum, &maximum, &bucket_count);
+ DCHECK(valid_arguments);
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
if (!histogram) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698