Chromium Code Reviews| Index: base/metrics/statistics_recorder.cc |
| diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc |
| index ba2101bccf50489ab4284801fd483e06f222fabc..f0ca72c100fbee8dbb5a4f23e7d24ed0baab3c1b 100644 |
| --- a/base/metrics/statistics_recorder.cc |
| +++ b/base/metrics/statistics_recorder.cc |
| @@ -431,8 +431,20 @@ 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) { |
|
Alexei Svitkine (slow)
2017/04/04 17:45:09
Nit: Add a comment about this logic.
bcwhite
2017/04/05 13:41:30
Done.
|
| + Histogram* histogram = static_cast<Histogram*>(base); |
| + histogram->bucket_ranges()->set_persistent_reference(0); |
| + } |
| + |
| + histograms_->erase(found); |
| } |
| // static |