| Index: base/metrics/statistics_recorder.cc
|
| diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
|
| index ba2101bccf50489ab4284801fd483e06f222fabc..409e6374be130ba50a2a805177c000b5559aa31c 100644
|
| --- a/base/metrics/statistics_recorder.cc
|
| +++ b/base/metrics/statistics_recorder.cc
|
| @@ -431,8 +431,24 @@ size_t StatisticsRecorder::GetHistogramCount() {
|
|
|
| // static
|
| void StatisticsRecorder::ForgetHistogramForTesting(base::StringPiece name) {
|
| - if (histograms_)
|
| - histograms_->erase(name);
|
| + if (!histograms_)
|
| + return;
|
| +
|
| + HistogramMap::iterator found = histograms_->find(name);
|
| + if (found == histograms_->end())
|
| + return;
|
| +
|
| + HistogramBase* base = found->second;
|
| + if (base->GetHistogramType() != SPARSE_HISTOGRAM) {
|
| + // When forgetting a histogram, it's likely that other information is
|
| + // also becoming invalid. Clear the persistent reference that may no
|
| + // longer be valid. There's no danger in this as, at worst, duplicates
|
| + // will be created in persistent memory.
|
| + Histogram* histogram = static_cast<Histogram*>(base);
|
| + histogram->bucket_ranges()->set_persistent_reference(0);
|
| + }
|
| +
|
| + histograms_->erase(found);
|
| }
|
|
|
| // static
|
|
|