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

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

Issue 10917080: Histogram - add check for external LinearHistogram data with mismatching range. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error. Created 8 years, 3 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 bdb4b5e2486c1a5c28bde0a6b00951897618a373..138cfcca1cdef0c86ce5cceeb0a37cf9bbe052ce 100644
--- a/chrome/browser/chromeos/external_metrics.cc
+++ b/chrome/browser/chromeos/external_metrics.cc
@@ -19,6 +19,7 @@
#include "base/bind.h"
#include "base/eintr_wrapper.h"
#include "base/metrics/histogram.h"
+#include "base/metrics/statistics_recorder.h"
#include "base/perftimer.h"
#include "base/time.h"
#include "chrome/browser/browser_process.h"
@@ -43,6 +44,14 @@ class SystemHistogram : public base::Histogram {
return base::Histogram::InspectConstructionArguments(
name, &minimum, &maximum, &bucket_count);
}
+ static bool CheckLinearValues(const std::string& name, int maximum) {
+ if (!CheckValues(name, 1, maximum, maximum + 1))
+ return false;
+ Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
+ if (!histogram)
+ return true;
+ return histogram->HasConstructionArguments(1, maximum, maximum + 1);
+ }
};
ExternalMetrics::ExternalMetrics()
@@ -124,7 +133,7 @@ void ExternalMetrics::RecordLinearHistogram(const char* histogram_data) {
return;
}
- if (!SystemHistogram::CheckValues(name, 1, max, max + 1)) {
+ if (!SystemHistogram::CheckLinearValues(name, max)) {
LOG(ERROR) << "Invalid linear histogram " << name
<< ", max=" << max;
return;
« 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