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

Unified Diff: base/metrics/histogram.cc

Issue 10826293: Histogram - Checks to cacth corruption in bucket ranges (Closed) Base URL: svn://chrome-svn/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 150971)
+++ base/metrics/histogram.cc (working copy)
@@ -14,10 +14,13 @@
#include <algorithm>
#include <string>
+#include "base/compiler_specific.h"
+#include "base/debug/alias.h"
#include "base/logging.h"
#include "base/metrics/statistics_recorder.h"
#include "base/pickle.h"
#include "base/stringprintf.h"
+#include "base/string_util.h"
#include "base/synchronization/lock.h"
using std::string;
@@ -129,6 +132,29 @@
return count == redundant_count_;
}
+// TODO(rtenneti): delete this code after debugging.
+void CheckCorruption(const Histogram& histogram) {
+ const std::string& histogram_name = histogram.histogram_name();
+ char histogram_name_buf[128];
+ base::strlcpy(histogram_name_buf,
+ histogram_name.c_str(),
+ arraysize(histogram_name_buf));
+ base::debug::Alias(histogram_name_buf);
+
+ Sample previous_range = -1; // Bottom range is always 0.
+ for (size_t index = 0; index < histogram.bucket_count(); ++index) {
kaiwang 2012/08/14 01:23:35 index < histogram.bucket_count() + 1; num of rang
ramant (doing other things) 2012/08/14 01:28:47 kaewang and I have talked. We will leave this as i
kaiwang 2012/08/14 01:37:40 This is temporary code, so I think it's not necess
kaiwang 2012/08/14 01:40:13 thinking it again, fix the behavior may lead to mo
ramant (doing other things) 2012/08/14 01:49:45 +1. I agree.
+ int new_range = histogram.ranges(index);
+ if (previous_range >= new_range) {
+ CHECK(false); // Crash for the bucket order corruption.
+ }
+ previous_range = new_range;
+ }
+
+ if (!histogram.bucket_ranges()->HasValidChecksum()) {
+ CHECK(false); // Crash for the checksum corruption.
+ }
+}
+
Histogram* Histogram::FactoryGet(const string& name,
Sample minimum,
Sample maximum,
@@ -152,6 +178,8 @@
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
+ // TODO(rtenneti): delete this code after debugging.
+ CheckCorruption(*histogram);
CHECK_EQ(HISTOGRAM, histogram->histogram_type());
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
@@ -704,6 +732,8 @@
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
+ // TODO(rtenneti): delete this code after debugging.
+ CheckCorruption(*histogram);
CHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type());
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
@@ -795,6 +825,8 @@
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
+ // TODO(rtenneti): delete this code after debugging.
+ CheckCorruption(*histogram);
CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type());
return 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