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

Unified Diff: base/metrics/statistics_recorder.cc

Issue 2794073002: De-duplicate ranges information in persistent memory. (Closed)
Patch Set: addressed final review comments 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
« no previous file with comments | « base/metrics/persistent_histogram_allocator_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/metrics/persistent_histogram_allocator_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698