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

Unified Diff: chrome/browser/chromeos/external_metrics.cc

Issue 10825169: Added check for invalid histogram data, added additional diagnostics to find the source of troubles… (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: chrome/browser/chromeos/external_metrics.cc
diff --git a/chrome/browser/chromeos/external_metrics.cc b/chrome/browser/chromeos/external_metrics.cc
index ab5d2b4f8209760cb3ae4b00e180861f2768cc1d..01a91d632a3f08fa541af7e76d9a877c20d77c60 100644
--- a/chrome/browser/chromeos/external_metrics.cc
+++ b/chrome/browser/chromeos/external_metrics.cc
@@ -34,6 +34,17 @@ namespace chromeos {
// The interval between external metrics collections in seconds
static const int kExternalMetricsCollectionIntervalSeconds = 30;
+class SystemHistogram : public base::Histogram {
+ public:
+ static bool CheckValues(const std::string& name,
+ int minimum,
+ int maximum,
+ size_t bucket_count) {
hshi1 2012/08/03 02:24:24 nit: please vertically left-align the arguments
zel 2012/08/03 02:29:45 Done.
+ return base::Histogram::InspectConstructionArguments(
+ name, &minimum, &maximum, &bucket_count);
+ }
+};
+
ExternalMetrics::ExternalMetrics()
: test_recorder_(NULL) {
}
@@ -89,6 +100,14 @@ void ExternalMetrics::RecordHistogram(const char* histogram_data) {
LOG(ERROR) << "bad histogram request: " << histogram_data;
return;
}
+
+ if (!SystemHistogram::CheckValues(name, min, max, nbuckets)) {
+ LOG(ERROR) << "Invalid histogram " << name
+ << ", min=" << min
+ << ", max=" << max
+ << ", nbuckets=" << nbuckets;
+ return;
+ }
// Do not use the UMA_HISTOGRAM_... macros here. They cache the Histogram
// instance and thus only work if |name| is constant.
base::Histogram* counter = base::Histogram::FactoryGet(
« 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