diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 13:59:58 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-24 13:59:58 +0000 |
commit | 961fefb5612835ff15c81790b8e2944501a13223 (patch) | |
tree | fd5688a85f3619f38e54000a85c58cbe2f489929 /base/metrics | |
parent | 73fe1b8d125cad66f30cec70040730618557b66e (diff) | |
download | chromium_src-961fefb5612835ff15c81790b8e2944501a13223.zip chromium_src-961fefb5612835ff15c81790b8e2944501a13223.tar.gz chromium_src-961fefb5612835ff15c81790b8e2944501a13223.tar.bz2 |
Add metrics for DHCP WPAD feature. Fix memory overwrite.
BUG=18575
TEST=net_unittests
Review URL: http://codereview.chromium.org/6975027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86421 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics')
-rw-r--r-- | base/metrics/histogram.cc | 15 | ||||
-rw-r--r-- | base/metrics/histogram.h | 13 |
2 files changed, 27 insertions, 1 deletions
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc index 4262853..6fd30be 100644 --- a/base/metrics/histogram.cc +++ b/base/metrics/histogram.cc @@ -940,6 +940,21 @@ Histogram::ClassType CustomHistogram::histogram_type() const { return CUSTOM_HISTOGRAM; } +// static +std::vector<Histogram::Sample> CustomHistogram::ArrayToCustomRanges( + const Sample* values, size_t num_values) { + std::vector<Sample> all_values; + for (size_t i = 0; i < num_values; ++i) { + Sample value = values[i]; + all_values.push_back(value); + + // Ensure that a guard bucket is added. If we end up with duplicate + // values, FactoryGet will take care of removing them. + all_values.push_back(value + 1); + } + return all_values; +} + CustomHistogram::CustomHistogram(const std::string& name, const std::vector<Sample>& custom_ranges) : Histogram(name, custom_ranges[1], custom_ranges.back(), diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h index bc58ee5..29004e4 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); |