diff options
author | hshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-23 00:08:22 +0000 |
---|---|---|
committer | hshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-23 00:08:22 +0000 |
commit | 86c2b87066c442964d583b09403b1f24c72f548d (patch) | |
tree | 40cadcbda32f304826f0406d78c8309f74d3ad2a /base/metrics/histogram.cc | |
parent | a8eff493c9188e0f8916aece721402ba221f575e (diff) | |
download | chromium_src-86c2b87066c442964d583b09403b1f24c72f548d.zip chromium_src-86c2b87066c442964d583b09403b1f24c72f548d.tar.gz chromium_src-86c2b87066c442964d583b09403b1f24c72f548d.tar.bz2 |
Histogram - add checks to catch cases of duplicate histogram names.
This is temporary to catch the duplicate histogram name. We will
back out this change once debug is complete.
BUG=143714
Review URL: https://chromiumcodereview.appspot.com/10875016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics/histogram.cc')
-rw-r--r-- | base/metrics/histogram.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc index dbc76ef..481bf38 100644 --- a/base/metrics/histogram.cc +++ b/base/metrics/histogram.cc @@ -155,6 +155,20 @@ void CheckCorruption(const Histogram& histogram, bool new_histogram) { CHECK(histogram.bucket_ranges()->HasValidChecksum()); } +// TODO(hshi): delete this code after debugging. +void CheckConstructionArguments(const Histogram& histogram, + bool has_construction_arguments) { + if (!has_construction_arguments) { + const std::string& histogram_name = histogram.histogram_name(); + char histogram_name_buf[128]; + base::strlcpy(histogram_name_buf, + histogram_name.c_str(), + arraysize(histogram_name_buf)); + base::debug::Alias(histogram_name_buf); + CHECK(false); + } +} + Histogram* Histogram::FactoryGet(const string& name, Sample minimum, Sample maximum, @@ -184,7 +198,11 @@ Histogram* Histogram::FactoryGet(const string& name, CheckCorruption(*histogram, false); CHECK_EQ(HISTOGRAM, histogram->histogram_type()); - CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); + + // TODO(hshi): delete this code after debugging. + bool has_construction_arguments = + histogram->HasConstructionArguments(minimum, maximum, bucket_count); + CheckConstructionArguments(*histogram, has_construction_arguments); return histogram; } @@ -740,7 +758,11 @@ Histogram* LinearHistogram::FactoryGet(const string& name, CheckCorruption(*histogram, false); CHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type()); - CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); + + // TODO(hshi): delete this code after debugging. + bool has_construction_arguments = + histogram->HasConstructionArguments(minimum, maximum, bucket_count); + CheckConstructionArguments(*histogram, has_construction_arguments); return histogram; } |