summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/metrics/histogram.cc19
-rw-r--r--base/metrics/histogram.h12
-rw-r--r--net/disk_cache/stats_histogram.cc2
3 files changed, 15 insertions, 18 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
diff --git a/net/disk_cache/stats_histogram.cc b/net/disk_cache/stats_histogram.cc
index d859899..028ae17 100644
--- a/net/disk_cache/stats_histogram.cc
+++ b/net/disk_cache/stats_histogram.cc
@@ -36,7 +36,7 @@ scoped_refptr<StatsHistogram> StatsHistogram::StatsHistogramFactoryGet(
bucket_count);
stats_histogram->InitializeBucketRange();
histogram = stats_histogram;
- StatisticsRecorder::RegisterOrDiscardDuplicate(&histogram);
+ StatisticsRecorder::Register(&histogram);
}
DCHECK(HISTOGRAM == histogram->histogram_type());