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

Unified Diff: base/metrics/histogram.cc

Issue 10857025: Add more code for debugging. We will revert this change when we find out the reason of corruption. (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 | « base/metrics/bucket_ranges.cc ('k') | 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 151415)
+++ base/metrics/histogram.cc (working copy)
@@ -133,7 +133,7 @@
}
// TODO(rtenneti): delete this code after debugging.
-void CheckCorruption(const Histogram& histogram) {
+void CheckCorruption(const Histogram& histogram, bool new_histogram) {
const std::string& histogram_name = histogram.histogram_name();
char histogram_name_buf[128];
base::strlcpy(histogram_name_buf,
@@ -141,18 +141,18 @@
arraysize(histogram_name_buf));
base::debug::Alias(histogram_name_buf);
+ bool debug_new_histogram[1];
+ debug_new_histogram[0] = new_histogram;
+ base::debug::Alias(debug_new_histogram);
+
Sample previous_range = -1; // Bottom range is always 0.
for (size_t index = 0; index < histogram.bucket_count(); ++index) {
int new_range = histogram.ranges(index);
- if (previous_range >= new_range) {
- CHECK(false); // Crash for the bucket order corruption.
- }
+ CHECK_LT(previous_range, new_range);
previous_range = new_range;
}
- if (!histogram.bucket_ranges()->HasValidChecksum()) {
- CHECK(false); // Crash for the checksum corruption.
- }
+ CHECK(histogram.bucket_ranges()->HasValidChecksum());
}
Histogram* Histogram::FactoryGet(const string& name,
@@ -174,12 +174,14 @@
Histogram* tentative_histogram =
new Histogram(name, minimum, maximum, bucket_count, registered_ranges);
+ CheckCorruption(*tentative_histogram, true);
+
tentative_histogram->SetFlags(flags);
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
// TODO(rtenneti): delete this code after debugging.
- CheckCorruption(*histogram);
+ CheckCorruption(*histogram, false);
CHECK_EQ(HISTOGRAM, histogram->histogram_type());
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
@@ -728,12 +730,14 @@
LinearHistogram* tentative_histogram =
new LinearHistogram(name, minimum, maximum, bucket_count,
registered_ranges);
+ CheckCorruption(*tentative_histogram, true);
+
tentative_histogram->SetFlags(flags);
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
// TODO(rtenneti): delete this code after debugging.
- CheckCorruption(*histogram);
+ CheckCorruption(*histogram, false);
CHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type());
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
@@ -821,12 +825,14 @@
BooleanHistogram* tentative_histogram =
new BooleanHistogram(name, registered_ranges);
+ CheckCorruption(*tentative_histogram, true);
+
tentative_histogram->SetFlags(flags);
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
// TODO(rtenneti): delete this code after debugging.
- CheckCorruption(*histogram);
+ CheckCorruption(*histogram, false);
CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type());
return histogram;
@@ -862,13 +868,15 @@
// To avoid racy destruction at shutdown, the following will be leaked.
CustomHistogram* tentative_histogram =
new CustomHistogram(name, registered_ranges);
+ CheckCorruption(*tentative_histogram, true);
+
tentative_histogram->SetFlags(flags);
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
// TODO(rtenneti): delete this code after debugging.
- CheckCorruption(*histogram);
+ CheckCorruption(*histogram, false);
CHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM);
return histogram;
« no previous file with comments | « base/metrics/bucket_ranges.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698