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

Unified Diff: base/metrics/histogram.h

Issue 6975027: Add metrics for DHCP WPAD feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 9 years, 7 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 | base/metrics/histogram.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram.h
diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h
index bc58ee576bf64dea93e466fa429bfc1200a3544e..29004e4ec7ca59ce31d21176bd17a79d8dace744 100644
--- a/base/metrics/histogram.h
+++ b/base/metrics/histogram.h
@@ -108,7 +108,6 @@ class Lock;
// Support histograming of an enumerated value. The samples should always be
// less than boundary_value.
-
#define HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \
static base::Histogram* counter(NULL); \
if (!counter) \
@@ -118,6 +117,10 @@ class Lock;
counter->Add(sample); \
} while (0)
+// Support histograming of an enumerated value. Samples should be one of the
+// std::vector<int> list provided via |custom_ranges|. You can use the helper
+// function |base::CustomHistogram::ArrayToCustomRanges(samples, num_samples)|
+// to transform a C-style array of valid sample values to a std::vector<int>.
#define HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) do { \
static base::Histogram* counter(NULL); \
if (!counter) \
@@ -664,6 +667,14 @@ class BASE_API CustomHistogram : public Histogram {
// Overridden from Histogram:
virtual ClassType histogram_type() const;
+ // Helper method for transforming an array of valid enumeration values
+ // to the std::vector<int> expected by HISTOGRAM_CUSTOM_ENUMERATION.
+ // This function ensures that a guard bucket exists right after any
+ // valid sample value (unless the next higher sample is also a valid value),
+ // so that invalid samples never fall into the same bucket as valid samples.
+ static std::vector<Sample> ArrayToCustomRanges(const Sample* values,
+ size_t num_values);
+
protected:
CustomHistogram(const std::string& name,
const std::vector<Sample>& custom_ranges);
« no previous file with comments | « no previous file | base/metrics/histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698