summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorkaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-01 03:53:25 +0000
committerkaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-01 03:53:25 +0000
commitcc7dec210cd2a325e65eaab44e4569846de72862 (patch)
tree4915e44672e83300f625e2bc991a4ff856dd5ff2 /base
parent2e588269fd005262bf53f96ab4e436919469ce90 (diff)
downloadchromium_src-cc7dec210cd2a325e65eaab44e4569846de72862.zip
chromium_src-cc7dec210cd2a325e65eaab44e4569846de72862.tar.gz
chromium_src-cc7dec210cd2a325e65eaab44e4569846de72862.tar.bz2
Connect SparseHistogram with the rest of stats system
With this CL, SparseHistogram is usable with SparseHistogram::FactoryGet. Next step is to implement a Histogram like macro and implement WriteHTMLGraph and WriteAscii to have a nice output. BUG=139612 Review URL: https://chromiumcodereview.appspot.com/12207058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185451 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/metrics/histogram.cc56
-rw-r--r--base/metrics/histogram.h12
-rw-r--r--base/metrics/histogram_base.cc5
-rw-r--r--base/metrics/histogram_base.h15
-rw-r--r--base/metrics/histogram_base_unittest.cc21
-rw-r--r--base/metrics/histogram_flattener.h10
-rw-r--r--base/metrics/histogram_snapshot_manager.cc14
-rw-r--r--base/metrics/histogram_snapshot_manager.h6
-rw-r--r--base/metrics/histogram_unittest.cc19
-rw-r--r--base/metrics/sparse_histogram.cc13
-rw-r--r--base/metrics/statistics_recorder.cc9
-rw-r--r--base/metrics/statistics_recorder.h10
12 files changed, 96 insertions, 94 deletions
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index 2e94841..1f26829 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -84,29 +84,6 @@ typedef HistogramBase::Sample Sample;
// static
const size_t Histogram::kBucketCount_MAX = 16384u;
-// TODO(rtenneti): delete this code after debugging.
-void CheckCorruption(const Histogram& histogram, bool new_histogram) {
- 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);
-
- bool debug_new_histogram[1];
- debug_new_histogram[0] = new_histogram;
- base::debug::Alias(debug_new_histogram);
-
- Sample previous_range = -1; // Bottom range is always 0.
- for (size_t index = 0; index < histogram.bucket_count(); ++index) {
- int new_range = histogram.ranges(index);
- CHECK_LT(previous_range, new_range);
- previous_range = new_range;
- }
-
- CHECK(histogram.bucket_ranges()->HasValidChecksum());
-}
-
HistogramBase* Histogram::FactoryGet(const string& name,
Sample minimum,
Sample maximum,
@@ -116,7 +93,7 @@ HistogramBase* Histogram::FactoryGet(const string& name,
InspectConstructionArguments(name, &minimum, &maximum, &bucket_count);
DCHECK(valid_arguments);
- Histogram* histogram = StatisticsRecorder::FindHistogram(name);
+ HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
if (!histogram) {
// To avoid racy destruction at shutdown, the following will be leaked.
BucketRanges* ranges = new BucketRanges(bucket_count + 1);
@@ -126,16 +103,13 @@ HistogramBase* Histogram::FactoryGet(const string& name,
Histogram* tentative_histogram =
new Histogram(name, minimum, maximum, bucket_count, registered_ranges);
- CheckCorruption(*tentative_histogram, true);
tentative_histogram->SetFlags(flags);
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
- // TODO(rtenneti): delete this code after debugging.
- CheckCorruption(*histogram, false);
- CHECK_EQ(HISTOGRAM, histogram->GetHistogramType());
+ DCHECK_EQ(HISTOGRAM, histogram->GetHistogramType());
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
return histogram;
}
@@ -200,8 +174,7 @@ void Histogram::InitializeBucketRanges(Sample minimum,
// static
const int Histogram::kCommonRaceBasedCountMismatch = 5;
-Histogram::Inconsistencies Histogram::FindCorruption(
- const HistogramSamples& samples) const {
+int Histogram::FindCorruption(const HistogramSamples& samples) const {
int inconsistencies = NO_INCONSISTENCIES;
Sample previous_range = -1; // Bottom range is always 0.
for (size_t index = 0; index < bucket_count(); ++index) {
@@ -230,7 +203,7 @@ Histogram::Inconsistencies Histogram::FindCorruption(
inconsistencies |= COUNT_LOW_ERROR;
}
}
- return static_cast<Inconsistencies>(inconsistencies);
+ return inconsistencies;
}
Sample Histogram::ranges(size_t i) const {
@@ -599,7 +572,7 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
name, &minimum, &maximum, &bucket_count);
DCHECK(valid_arguments);
- Histogram* histogram = StatisticsRecorder::FindHistogram(name);
+ HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
if (!histogram) {
// To avoid racy destruction at shutdown, the following will be leaked.
BucketRanges* ranges = new BucketRanges(bucket_count + 1);
@@ -610,7 +583,6 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
LinearHistogram* tentative_histogram =
new LinearHistogram(name, minimum, maximum, bucket_count,
registered_ranges);
- CheckCorruption(*tentative_histogram, true);
// Set range descriptions.
if (descriptions) {
@@ -624,10 +596,8 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
- // TODO(rtenneti): delete this code after debugging.
- CheckCorruption(*histogram, false);
- CHECK_EQ(LINEAR_HISTOGRAM, histogram->GetHistogramType());
+ DCHECK_EQ(LINEAR_HISTOGRAM, histogram->GetHistogramType());
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
return histogram;
}
@@ -710,7 +680,7 @@ HistogramBase* LinearHistogram::DeserializeInfoImpl(PickleIterator* iter) {
//------------------------------------------------------------------------------
HistogramBase* BooleanHistogram::FactoryGet(const string& name, int32 flags) {
- Histogram* histogram = StatisticsRecorder::FindHistogram(name);
+ HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
if (!histogram) {
// To avoid racy destruction at shutdown, the following will be leaked.
BucketRanges* ranges = new BucketRanges(4);
@@ -720,16 +690,13 @@ HistogramBase* BooleanHistogram::FactoryGet(const string& name, int32 flags) {
BooleanHistogram* tentative_histogram =
new BooleanHistogram(name, registered_ranges);
- CheckCorruption(*tentative_histogram, true);
tentative_histogram->SetFlags(flags);
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
- // TODO(rtenneti): delete this code after debugging.
- CheckCorruption(*histogram, false);
- CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->GetHistogramType());
+ DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->GetHistogramType());
return histogram;
}
@@ -772,7 +739,7 @@ HistogramBase* CustomHistogram::FactoryGet(const string& name,
int32 flags) {
CHECK(ValidateCustomRanges(custom_ranges));
- Histogram* histogram = StatisticsRecorder::FindHistogram(name);
+ HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
if (!histogram) {
BucketRanges* ranges = CreateBucketRangesFromCustomRanges(custom_ranges);
const BucketRanges* registered_ranges =
@@ -781,17 +748,14 @@ HistogramBase* CustomHistogram::FactoryGet(const string& name,
// To avoid racy destruction at shutdown, the following will be leaked.
CustomHistogram* tentative_histogram =
new CustomHistogram(name, registered_ranges);
- CheckCorruption(*tentative_histogram, true);
tentative_histogram->SetFlags(flags);
histogram =
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
}
- // TODO(rtenneti): delete this code after debugging.
- CheckCorruption(*histogram, false);
- CHECK_EQ(histogram->GetHistogramType(), CUSTOM_HISTOGRAM);
+ DCHECK_EQ(histogram->GetHistogramType(), CUSTOM_HISTOGRAM);
return histogram;
}
diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h
index 47db608..fe7b794 100644
--- a/base/metrics/histogram.h
+++ b/base/metrics/histogram.h
@@ -369,16 +369,6 @@ class BASE_EXPORT Histogram : public HistogramBase {
typedef std::vector<Count> Counts;
- enum Inconsistencies {
- NO_INCONSISTENCIES = 0x0,
- RANGE_CHECKSUM_ERROR = 0x1,
- BUCKET_ORDER_ERROR = 0x2,
- COUNT_HIGH_ERROR = 0x4,
- COUNT_LOW_ERROR = 0x8,
-
- NEVER_EXCEEDED_VALUE = 0x10
- };
-
//----------------------------------------------------------------------------
// For a valid histogram, input should follow these restrictions:
// minimum > 0 (if a minimum below 1 is specified, it will implicitly be
@@ -423,7 +413,7 @@ class BASE_EXPORT Histogram : public HistogramBase {
// produce a false-alarm if a race occurred in the reading of the data during
// a SnapShot process, but should otherwise be false at all times (unless we
// have memory over-writes, or DRAM failures).
- virtual Inconsistencies FindCorruption(const HistogramSamples& samples) const;
+ virtual int FindCorruption(const HistogramSamples& samples) const OVERRIDE;
//----------------------------------------------------------------------------
// Accessors for factory constuction, serialization and testing.
diff --git a/base/metrics/histogram_base.cc b/base/metrics/histogram_base.cc
index 403303a..835a05b 100644
--- a/base/metrics/histogram_base.cc
+++ b/base/metrics/histogram_base.cc
@@ -100,6 +100,11 @@ bool HistogramBase::SerializeInfo(Pickle* pickle) const {
return SerializeInfoImpl(pickle);
}
+int HistogramBase::FindCorruption(const HistogramSamples& samples) const {
+ // Not supported by default.
+ return NO_INCONSISTENCIES;
+}
+
void HistogramBase::WriteJSON(std::string* output) const {
Count count;
scoped_ptr<ListValue> buckets(new ListValue());
diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h
index 729670c..12d126d 100644
--- a/base/metrics/histogram_base.h
+++ b/base/metrics/histogram_base.h
@@ -70,6 +70,17 @@ class BASE_EXPORT HistogramBase {
kHexRangePrintingFlag = 0x8000,
};
+ // Histogram data inconsistency types.
+ enum Inconsistency {
+ NO_INCONSISTENCIES = 0x0,
+ RANGE_CHECKSUM_ERROR = 0x1,
+ BUCKET_ORDER_ERROR = 0x2,
+ COUNT_HIGH_ERROR = 0x4,
+ COUNT_LOW_ERROR = 0x8,
+
+ NEVER_EXCEEDED_VALUE = 0x10
+ };
+
explicit HistogramBase(const std::string& name);
virtual ~HistogramBase();
@@ -103,6 +114,10 @@ class BASE_EXPORT HistogramBase {
// does not serialize the samples.
bool SerializeInfo(Pickle* pickle) const;
+ // Try to find out data corruption from histogram and the samples.
+ // The returned value is a combination of Inconsistency enum.
+ virtual int FindCorruption(const HistogramSamples& samples) const;
+
// Snapshot the current complete set of sample data.
// Override with atomic/locked snapshot if needed.
virtual scoped_ptr<HistogramSamples> SnapshotSamples() const = 0;
diff --git a/base/metrics/histogram_base_unittest.cc b/base/metrics/histogram_base_unittest.cc
index 4944f31..0e19d56 100644
--- a/base/metrics/histogram_base_unittest.cc
+++ b/base/metrics/histogram_base_unittest.cc
@@ -167,6 +167,25 @@ TEST_F(HistogramBaseTest, DeserializeCustomHistogram) {
EXPECT_EQ(0, deserialized->flags());
}
-// TODO(kaiwang): Add SparseHistogram test.
+TEST_F(HistogramBaseTest, DeserializeSparseHistogram) {
+ HistogramBase* histogram = SparseHistogram::FactoryGet(
+ "TestHistogram", HistogramBase::kIPCSerializationSourceFlag);
+
+ Pickle pickle;
+ ASSERT_TRUE(histogram->SerializeInfo(&pickle));
+
+ PickleIterator iter(pickle);
+ HistogramBase* deserialized = DeserializeHistogramInfo(&iter);
+ EXPECT_EQ(histogram, deserialized);
+
+ ResetStatisticsRecorder();
+
+ PickleIterator iter2(pickle);
+ deserialized = DeserializeHistogramInfo(&iter2);
+ EXPECT_TRUE(deserialized);
+ EXPECT_NE(histogram, deserialized);
+ EXPECT_EQ("TestHistogram", deserialized->histogram_name());
+ EXPECT_EQ(0, deserialized->flags());
+}
} // namespace base
diff --git a/base/metrics/histogram_flattener.h b/base/metrics/histogram_flattener.h
index 137ce98..ca05a4f 100644
--- a/base/metrics/histogram_flattener.h
+++ b/base/metrics/histogram_flattener.h
@@ -24,14 +24,14 @@ class BASE_EXPORT HistogramFlattener {
virtual void RecordDelta(const HistogramBase& histogram,
const HistogramSamples& snapshot) = 0;
- // Will be called each time a type of Inconsistenies is seen on a histogram,
+ // Will be called each time a type of Inconsistency is seen on a histogram,
// during inspections done internally in HistogramSnapshotManager class.
- virtual void InconsistencyDetected(Histogram::Inconsistencies problem) = 0;
+ virtual void InconsistencyDetected(HistogramBase::Inconsistency problem) = 0;
- // Will be called when a type of Inconsistenies is seen for the first time
- // on a histogram.
+ // Will be called when a type of Inconsistency is seen for the first time on
+ // a histogram.
virtual void UniqueInconsistencyDetected(
- Histogram::Inconsistencies problem) = 0;
+ HistogramBase::Inconsistency problem) = 0;
// Will be called when the total logged sample count of a histogram
// differs from the sum of logged sample count in all the buckets. The
diff --git a/base/metrics/histogram_snapshot_manager.cc b/base/metrics/histogram_snapshot_manager.cc
index ad054b1..2301819 100644
--- a/base/metrics/histogram_snapshot_manager.cc
+++ b/base/metrics/histogram_snapshot_manager.cc
@@ -25,7 +25,7 @@ HistogramSnapshotManager::~HistogramSnapshotManager() {
STLDeleteValues(&logged_samples_);
}
-void HistogramSnapshotManager::PrepareDeltas(Histogram::Flags flag_to_set,
+void HistogramSnapshotManager::PrepareDeltas(HistogramBase::Flags flag_to_set,
bool record_only_uma) {
StatisticsRecorder::Histograms histograms;
StatisticsRecorder::GetHistograms(&histograms);
@@ -40,7 +40,7 @@ void HistogramSnapshotManager::PrepareDeltas(Histogram::Flags flag_to_set,
}
}
-void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
+void HistogramSnapshotManager::PrepareDelta(const HistogramBase& histogram) {
DCHECK(histogram_flattener_);
// Get up-to-date snapshot of sample stats.
@@ -52,13 +52,13 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
// Crash if we detect that our histograms have been overwritten. This may be
// a fair distance from the memory smasher, but we hope to correlate these
// crashes with other events, such as plugins, or usage patterns, etc.
- if (Histogram::BUCKET_ORDER_ERROR & corruption) {
+ if (HistogramBase::BUCKET_ORDER_ERROR & corruption) {
// The checksum should have caught this, so crash separately if it didn't.
- CHECK_NE(0, Histogram::RANGE_CHECKSUM_ERROR & corruption);
+ CHECK_NE(0, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
CHECK(false); // Crash for the bucket order corruption.
}
// Checksum corruption might not have caused order corruption.
- CHECK_EQ(0, Histogram::RANGE_CHECKSUM_ERROR & corruption);
+ CHECK_EQ(0, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
// Note, at this point corruption can only be COUNT_HIGH_ERROR or
// COUNT_LOW_ERROR and they never arise together, so we don't need to extract
@@ -67,14 +67,14 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
DLOG(ERROR) << "Histogram: " << histogram_name
<< " has data corruption: " << corruption;
histogram_flattener_->InconsistencyDetected(
- static_cast<Histogram::Inconsistencies>(corruption));
+ static_cast<HistogramBase::Inconsistency>(corruption));
// Don't record corrupt data to metrics services.
int old_corruption = inconsistencies_[histogram_name];
if (old_corruption == (corruption | old_corruption))
return; // We've already seen this corruption for this histogram.
inconsistencies_[histogram_name] |= corruption;
histogram_flattener_->UniqueInconsistencyDetected(
- static_cast<Histogram::Inconsistencies>(corruption));
+ static_cast<HistogramBase::Inconsistency>(corruption));
return;
}
diff --git a/base/metrics/histogram_snapshot_manager.h b/base/metrics/histogram_snapshot_manager.h
index 0ec1ac3..3c70508 100644
--- a/base/metrics/histogram_snapshot_manager.h
+++ b/base/metrics/histogram_snapshot_manager.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/basictypes.h"
-#include "base/metrics/histogram.h"
+#include "base/metrics/histogram_base.h"
namespace base {
@@ -31,11 +31,11 @@ class BASE_EXPORT HistogramSnapshotManager {
// Snapshot all histograms, and ask |histogram_flattener_| to record the
// delta. The arguments allow selecting only a subset of histograms for
// recording, or to set a flag in each recorded histogram.
- void PrepareDeltas(Histogram::Flags flags_to_set, bool record_only_uma);
+ void PrepareDeltas(HistogramBase::Flags flags_to_set, bool record_only_uma);
private:
// Snapshot this histogram, and record the delta.
- void PrepareDelta(const Histogram& histogram);
+ void PrepareDelta(const HistogramBase& histogram);
// Try to detect and fix count inconsistency of logged samples.
void InspectLoggedSamplesInconsistency(
diff --git a/base/metrics/histogram_unittest.cc b/base/metrics/histogram_unittest.cc
index 27c0faf..b5081b6 100644
--- a/base/metrics/histogram_unittest.cc
+++ b/base/metrics/histogram_unittest.cc
@@ -315,21 +315,21 @@ TEST_F(HistogramTest, CorruptSampleCounts) {
histogram->Add(40);
scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
- EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
+ EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
histogram->FindCorruption(*snapshot));
EXPECT_EQ(2, snapshot->redundant_count());
EXPECT_EQ(2, snapshot->TotalCount());
snapshot->counts_[3] += 100; // Sample count won't match redundant count.
- EXPECT_EQ(Histogram::COUNT_LOW_ERROR,
+ EXPECT_EQ(HistogramBase::COUNT_LOW_ERROR,
histogram->FindCorruption(*snapshot));
snapshot->counts_[2] -= 200;
- EXPECT_EQ(Histogram::COUNT_HIGH_ERROR,
+ EXPECT_EQ(HistogramBase::COUNT_HIGH_ERROR,
histogram->FindCorruption(*snapshot));
// But we can't spot a corruption if it is compensated for.
snapshot->counts_[1] += 100;
- EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
+ EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
histogram->FindCorruption(*snapshot));
}
@@ -338,7 +338,7 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
Histogram::FactoryGet("Histogram", 1, 64, 8, HistogramBase::kNoFlags));
scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
- EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
+ EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
histogram->FindCorruption(*snapshot));
BucketRanges* bucket_ranges =
@@ -346,8 +346,9 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
HistogramBase::Sample tmp = bucket_ranges->range(1);
bucket_ranges->set_range(1, bucket_ranges->range(2));
bucket_ranges->set_range(2, tmp);
- EXPECT_EQ(Histogram::BUCKET_ORDER_ERROR | Histogram::RANGE_CHECKSUM_ERROR,
- histogram->FindCorruption(*snapshot));
+ EXPECT_EQ(
+ HistogramBase::BUCKET_ORDER_ERROR | HistogramBase::RANGE_CHECKSUM_ERROR,
+ histogram->FindCorruption(*snapshot));
bucket_ranges->set_range(2, bucket_ranges->range(1));
bucket_ranges->set_range(1, tmp);
@@ -355,11 +356,11 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
// Show that two simple changes don't offset each other
bucket_ranges->set_range(3, bucket_ranges->range(3) + 1);
- EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR,
+ EXPECT_EQ(HistogramBase::RANGE_CHECKSUM_ERROR,
histogram->FindCorruption(*snapshot));
bucket_ranges->set_range(4, bucket_ranges->range(4) - 1);
- EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR,
+ EXPECT_EQ(HistogramBase::RANGE_CHECKSUM_ERROR,
histogram->FindCorruption(*snapshot));
// Repair histogram so that destructor won't DCHECK().
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc
index c64f7cb..2952673 100644
--- a/base/metrics/sparse_histogram.cc
+++ b/base/metrics/sparse_histogram.cc
@@ -19,9 +19,16 @@ typedef HistogramBase::Sample Sample;
// static
HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) {
- // TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder.
- HistogramBase* histogram = new SparseHistogram(name);
- histogram->SetFlags(flags);
+ HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
+
+ if (!histogram) {
+ // To avoid racy destruction at shutdown, the following will be leaked.
+ HistogramBase* tentative_histogram = new SparseHistogram(name);
+ tentative_histogram->SetFlags(flags);
+ histogram =
+ StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
+ }
+ DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType());
return histogram;
}
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
index 39a6275..f6174f3 100644
--- a/base/metrics/statistics_recorder.cc
+++ b/base/metrics/statistics_recorder.cc
@@ -45,7 +45,8 @@ bool StatisticsRecorder::IsActive() {
}
// static
-Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) {
+HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
+ HistogramBase* histogram) {
// As per crbug.com/79322 the histograms are intentionally leaked, so we need
// to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once
// for an object, the duplicates should not be annotated.
@@ -56,8 +57,8 @@ Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) {
return histogram;
}
- Histogram* histogram_to_delete = NULL;
- Histogram* histogram_to_return = NULL;
+ HistogramBase* histogram_to_delete = NULL;
+ HistogramBase* histogram_to_return = NULL;
{
base::AutoLock auto_lock(*lock_);
if (histograms_ == NULL) {
@@ -254,7 +255,7 @@ void StatisticsRecorder::GetBucketRanges(
}
// static
-Histogram* StatisticsRecorder::FindHistogram(const std::string& name) {
+HistogramBase* StatisticsRecorder::FindHistogram(const std::string& name) {
if (lock_ == NULL)
return NULL;
base::AutoLock auto_lock(*lock_);
diff --git a/base/metrics/statistics_recorder.h b/base/metrics/statistics_recorder.h
index 6d40aff..4bb2548 100644
--- a/base/metrics/statistics_recorder.h
+++ b/base/metrics/statistics_recorder.h
@@ -23,12 +23,12 @@
namespace base {
class BucketRanges;
-class Histogram;
+class HistogramBase;
class Lock;
class BASE_EXPORT StatisticsRecorder {
public:
- typedef std::vector<Histogram*> Histograms;
+ typedef std::vector<HistogramBase*> Histograms;
// Initializes the StatisticsRecorder system.
static void Initialize();
@@ -40,7 +40,7 @@ class BASE_EXPORT StatisticsRecorder {
// identically named histogram is already registered, then the argument
// |histogram| will deleted. The returned value is always the registered
// histogram (either the argument, or the pre-existing registered histogram).
- static Histogram* RegisterOrDeleteDuplicate(Histogram* histogram);
+ static HistogramBase* RegisterOrDeleteDuplicate(HistogramBase* histogram);
// Register, or add a new BucketRanges. If an identically BucketRanges is
// already registered, then the argument |ranges| will deleted. The returned
@@ -68,7 +68,7 @@ class BASE_EXPORT StatisticsRecorder {
// Find a histogram by name. It matches the exact name. This method is thread
// safe. It returns NULL if a matching histogram is not found.
- static Histogram* FindHistogram(const std::string& name);
+ static HistogramBase* FindHistogram(const std::string& name);
static bool dump_on_exit() { return dump_on_exit_; }
@@ -82,7 +82,7 @@ class BASE_EXPORT StatisticsRecorder {
private:
// We keep all registered histograms in a map, from name to histogram.
- typedef std::map<std::string, Histogram*> HistogramMap;
+ typedef std::map<std::string, HistogramBase*> HistogramMap;
// We keep all |bucket_ranges_| in a map, from checksum to a list of
// |bucket_ranges_|. Checksum is calculated from the |ranges_| in