Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Unified Diff: base/metrics/statistics_recorder.cc

Issue 2794073002: De-duplicate ranges information in persistent memory. (Closed)
Patch Set: comment improvements Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698