diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 23:38:00 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 23:38:00 +0000 |
commit | 7767bdbf906c1d9b3617cd99735bf247fed5c4ff (patch) | |
tree | 84a8a6510b957db497175e8fcf4c056a82e28c24 /base/metrics | |
parent | 309c9d7dd5c7cc31525abe97216f49019fdc382c (diff) | |
download | chromium_src-7767bdbf906c1d9b3617cd99735bf247fed5c4ff.zip chromium_src-7767bdbf906c1d9b3617cd99735bf247fed5c4ff.tar.gz chromium_src-7767bdbf906c1d9b3617cd99735bf247fed5c4ff.tar.bz2 |
Revert 76345 - Small cleanup for previous histogram checkin
Reason for revert: This patch might have resulted in some
flakiness in the sync bots on the chromium waterfall.
CL http://codereview.chromium.org/6577013/ had
a few changes suggested that were not incorporated.
This CL has those name changes etc.
r=rvargas
Review URL: http://codereview.chromium.org/6591052
BUG=74467
TBR=jar@chromium.org
Review URL: http://codereview.chromium.org/6591129
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics')
-rw-r--r-- | base/metrics/histogram.cc | 19 | ||||
-rw-r--r-- | base/metrics/histogram.h | 12 |
2 files changed, 14 insertions, 17 deletions
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc index 1d6f884..7f935a3 100644 --- a/base/metrics/histogram.cc +++ b/base/metrics/histogram.cc @@ -86,7 +86,7 @@ scoped_refptr<Histogram> Histogram::FactoryGet(const std::string& name, if (!StatisticsRecorder::FindHistogram(name, &histogram)) { histogram = new Histogram(name, minimum, maximum, bucket_count); histogram->InitializeBucketRange(); - StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); + StatisticsRecorder::Register(&histogram); } DCHECK_EQ(HISTOGRAM, histogram->histogram_type()); @@ -415,6 +415,10 @@ Histogram::~Histogram() { DCHECK(ValidateBucketRanges()); } +bool Histogram::PrintEmptyBucket(size_t index) const { + return true; +} + // Calculate what range of values are held in each bucket. // We have to be careful that we don't pick a ratio between starting points in // consecutive buckets that is sooo small, that the integer bounds are the same @@ -450,10 +454,6 @@ void Histogram::InitializeBucketRange() { DCHECK_EQ(bucket_count(), bucket_index); } -bool Histogram::PrintEmptyBucket(size_t index) const { - return true; -} - size_t Histogram::BucketIndex(Sample value) const { // Use simple binary search. This is very general, but there are better // approaches if we knew that the buckets were linearly distributed. @@ -791,7 +791,7 @@ scoped_refptr<Histogram> LinearHistogram::FactoryGet(const std::string& name, new LinearHistogram(name, minimum, maximum, bucket_count); linear_histogram->InitializeBucketRange(); histogram = linear_histogram; - StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); + StatisticsRecorder::Register(&histogram); } DCHECK_EQ(LINEAR_HISTOGRAM, histogram->histogram_type()); @@ -883,7 +883,7 @@ scoped_refptr<Histogram> BooleanHistogram::FactoryGet(const std::string& name, BooleanHistogram* boolean_histogram = new BooleanHistogram(name); boolean_histogram->InitializeBucketRange(); histogram = boolean_histogram; - StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); + StatisticsRecorder::Register(&histogram); } DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->histogram_type()); @@ -930,7 +930,7 @@ scoped_refptr<Histogram> CustomHistogram::FactoryGet( CustomHistogram* custom_histogram = new CustomHistogram(name, ranges); custom_histogram->InitializedCustomBucketRange(ranges); histogram = custom_histogram; - StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram); + StatisticsRecorder::Register(&histogram); } DCHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM); @@ -1023,8 +1023,7 @@ bool StatisticsRecorder::IsActive() { // was passed to us, decremented it when we returned, and the instance would be // destroyed before assignment (when value was returned by new). // static -void StatisticsRecorder::RegisterOrDiscardDuplicate( - scoped_refptr<Histogram>* histogram) { +void StatisticsRecorder::Register(scoped_refptr<Histogram>* histogram) { DCHECK((*histogram)->HasValidRangeChecksum()); if (lock_ == NULL) return; diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h index 347932a..94f219b 100644 --- a/base/metrics/histogram.h +++ b/base/metrics/histogram.h @@ -435,15 +435,14 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> { virtual ~Histogram(); - // Initialize ranges_ mapping. - void InitializeBucketRange(); - // Method to override to skip the display of the i'th bucket if it's empty. virtual bool PrintEmptyBucket(size_t index) const; //---------------------------------------------------------------------------- // Methods to override to create histogram with different bucket widths. //---------------------------------------------------------------------------- + // Initialize ranges_ mapping. + virtual void InitializeBucketRange(); // Find bucket to increment for sample value. virtual size_t BucketIndex(Sample value) const; // Get normalized size, relative to the ranges_[i]. @@ -577,7 +576,7 @@ class LinearHistogram : public Histogram { TimeDelta maximum, size_t bucket_count); // Initialize ranges_ mapping. - void InitializeBucketRange(); + virtual void InitializeBucketRange(); virtual double GetBucketSize(Count current, size_t i) const; // If we have a description for a bucket, then return that. Otherwise @@ -657,9 +656,8 @@ class StatisticsRecorder { // Register, or add a new histogram to the collection of statistics. If an // identically named histogram is already registered, then the argument - // |histogram| will be replaced by the previously registered value, discarding - // the referenced argument. - static void RegisterOrDiscardDuplicate(scoped_refptr<Histogram>* histogram); + // |histogram| will be replaced by the previously registered value. + static void Register(scoped_refptr<Histogram>* histogram); // Methods for printing histograms. Only histograms which have query as // a substring are written to output (an empty string will process all |