Histogram argument related change
1. HistogramBase supports HasConstructionArguments.
2. Move Histogram::InspectConstructionArguments() to public, so chromeos
does not need to extend Histogram to do arguments checking.
Also grouped OVERRIDE functions in histogram.cc/h together.
[email protected]
Review URL: https://chromiumcodereview.appspot.com/11231025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163788 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/chromeos/external_metrics.cc b/chrome/browser/chromeos/external_metrics.cc
index 9277616..ccc12b5 100644
--- a/chrome/browser/chromeos/external_metrics.cc
+++ b/chrome/browser/chromeos/external_metrics.cc
@@ -32,28 +32,31 @@
namespace chromeos {
+namespace {
+
+bool CheckValues(const std::string& name,
+ int minimum,
+ int maximum,
+ size_t bucket_count) {
+ if (!base::Histogram::InspectConstructionArguments(
+ name, &minimum, &maximum, &bucket_count))
+ return false;
+ base::HistogramBase* histogram =
+ base::StatisticsRecorder::FindHistogram(name);
+ if (!histogram)
+ return true;
+ return histogram->HasConstructionArguments(minimum, maximum, bucket_count);
+}
+
+bool CheckLinearValues(const std::string& name, int maximum) {
+ return CheckValues(name, 1, maximum, maximum + 1);
+}
+
+} // namespace
+
// 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) {
- if (!base::Histogram::InspectConstructionArguments(
- name, &minimum, &maximum, &bucket_count))
- return false;
- Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
- if (!histogram)
- return true;
- return histogram->HasConstructionArguments(minimum, maximum, bucket_count);
- }
- static bool CheckLinearValues(const std::string& name, int maximum) {
- return CheckValues(name, 1, maximum, maximum + 1);
- }
-};
-
ExternalMetrics::ExternalMetrics()
: test_recorder_(NULL) {
}
@@ -110,7 +113,7 @@
return;
}
- if (!SystemHistogram::CheckValues(name, min, max, nbuckets)) {
+ if (!CheckValues(name, min, max, nbuckets)) {
LOG(ERROR) << "Invalid histogram " << name
<< ", min=" << min
<< ", max=" << max
@@ -133,7 +136,7 @@
return;
}
- if (!SystemHistogram::CheckLinearValues(name, max)) {
+ if (!CheckLinearValues(name, max)) {
LOG(ERROR) << "Invalid linear histogram " << name
<< ", max=" << max;
return;