diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 19:19:43 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-07 19:19:43 +0000 |
commit | 668fc1063e8cf948924825ff90268587d407c59c (patch) | |
tree | c3d64124a4a1d3e9f4a63473517dec0cb83e880d /base/histogram.h | |
parent | 83d86254647aea9dc212c4835b1d8a2104d92dba (diff) | |
download | chromium_src-668fc1063e8cf948924825ff90268587d407c59c.zip chromium_src-668fc1063e8cf948924825ff90268587d407c59c.tar.gz chromium_src-668fc1063e8cf948924825ff90268587d407c59c.tar.bz2 |
Add DCHECK to detect misuse of HISTOGRAM interface.
The interface (for perf reasons) snapshots the histogram
name, and reuses it in future calls. As a result, any attempt
to modulate (change) the name between call is ignored.
This change uses a DCHECK to detect such abuse.
BUG=43377
BUG=43375
r=vandebo
Review URL: http://codereview.chromium.org/2019001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/histogram.h')
-rw-r--r-- | base/histogram.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/base/histogram.h b/base/histogram.h index 1737b85..faac1ec 100644 --- a/base/histogram.h +++ b/base/histogram.h @@ -60,6 +60,7 @@ #define HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) do { \ static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ name, min, max, bucket_count, Histogram::kNoFlags); \ + DCHECK_EQ(name, counter->histogram_name()); \ counter->Add(sample); \ } while (0) @@ -71,6 +72,7 @@ #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ name, min, max, bucket_count, Histogram::kNoFlags); \ + DCHECK_EQ(name, counter->histogram_name()); \ counter->AddTime(sample); \ } while (0) @@ -78,6 +80,7 @@ #define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ name, min, max, bucket_count, Histogram::kNoFlags); \ + DCHECK_EQ(name, counter->histogram_name()); \ if ((sample) < (max)) counter->AddTime(sample); \ } while (0) @@ -87,12 +90,14 @@ #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \ static scoped_refptr<Histogram> counter = LinearHistogram::FactoryGet( \ name, 1, boundary_value, boundary_value + 1, Histogram::kNoFlags); \ + DCHECK_EQ(name, counter->histogram_name()); \ counter->Add(sample); \ } while (0) #define HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) do { \ static scoped_refptr<Histogram> counter = CustomHistogram::FactoryGet( \ name, custom_ranges, Histogram::kNoFlags); \ + DCHECK_EQ(name, counter->histogram_name()); \ counter->Add(sample); \ } while (0) @@ -155,6 +160,7 @@ #define UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ + DCHECK_EQ(name, counter->histogram_name()); \ counter->AddTime(sample); \ } while (0) @@ -162,6 +168,7 @@ #define UMA_HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ + DCHECK_EQ(name, counter->histogram_name()); \ if ((sample) < (max)) counter->AddTime(sample); \ } while (0) @@ -177,6 +184,7 @@ #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) do { \ static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ + DCHECK_EQ(name, counter->histogram_name()); \ counter->Add(sample); \ } while (0) @@ -193,12 +201,14 @@ static scoped_refptr<Histogram> counter = LinearHistogram::FactoryGet( \ name, 1, boundary_value, boundary_value + 1, \ Histogram::kUmaTargetedHistogramFlag); \ + DCHECK_EQ(name, counter->histogram_name()); \ counter->Add(sample); \ } while (0) #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) do { \ static scoped_refptr<Histogram> counter = CustomHistogram::FactoryGet( \ name, custom_ranges, Histogram::kUmaTargetedHistogramFlag); \ + DCHECK_EQ(name, counter->histogram_name()); \ counter->Add(sample); \ } while (0) |