summaryrefslogtreecommitdiffstats
path: root/base/metrics
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 02:54:14 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 02:54:14 +0000
commit141ba0fbc6d11e6b2d4e7411d266037d1bac11cf (patch)
tree377291ceb325ae7f8825b40fc6e51d35b1774034 /base/metrics
parent5d2b449b4f0b3d13c75e540c834c550ed38c0912 (diff)
downloadchromium_src-141ba0fbc6d11e6b2d4e7411d266037d1bac11cf.zip
chromium_src-141ba0fbc6d11e6b2d4e7411d266037d1bac11cf.tar.gz
chromium_src-141ba0fbc6d11e6b2d4e7411d266037d1bac11cf.tar.bz2
Small cleanup for previous histogram checkin
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76345 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics')
-rw-r--r--base/metrics/histogram.cc19
-rw-r--r--base/metrics/histogram.h12
2 files changed, 17 insertions, 14 deletions
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index 2d16582..c8d7b5f 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::Register(&histogram);
+ StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram);
}
DCHECK_EQ(HISTOGRAM, histogram->histogram_type());
@@ -415,10 +415,6 @@ 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
@@ -454,6 +450,10 @@ 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::Register(&histogram);
+ StatisticsRecorder::RegisterOrDiscardDuplicate(&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::Register(&histogram);
+ StatisticsRecorder::RegisterOrDiscardDuplicate(&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::Register(&histogram);
+ StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram);
}
DCHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM);
@@ -1023,7 +1023,8 @@ 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::Register(scoped_refptr<Histogram>* histogram) {
+void StatisticsRecorder::RegisterOrDiscardDuplicate(
+ scoped_refptr<Histogram>* histogram) {
DCHECK((*histogram)->HasValidRangeChecksum());
if (lock_ == NULL)
return;
diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h
index 7217617..d6ec94d 100644
--- a/base/metrics/histogram.h
+++ b/base/metrics/histogram.h
@@ -435,14 +435,15 @@ 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].
@@ -576,7 +577,7 @@ class LinearHistogram : public Histogram {
TimeDelta maximum, size_t bucket_count);
// Initialize ranges_ mapping.
- virtual void InitializeBucketRange();
+ void InitializeBucketRange();
virtual double GetBucketSize(Count current, size_t i) const;
// If we have a description for a bucket, then return that. Otherwise
@@ -656,8 +657,9 @@ 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.
- static void Register(scoped_refptr<Histogram>* histogram);
+ // |histogram| will be replaced by the previously registered value, discarding
+ // the referenced argument.
+ static void RegisterOrDiscardDuplicate(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