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

Unified Diff: base/metrics/statistics_recorder.cc

Issue 1537743006: Persist setup metrics and have Chrome report them during UMA upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: test needs to clear out statistics-recorder before releasing histogram memory Created 4 years, 10 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 7efe16b10c15596f968a4fcced8ad4ae4d7d9ee4..a2296da109da9bcf46495bb97980783863f0eeaa 100644
--- a/base/metrics/statistics_recorder.cc
+++ b/base/metrics/statistics_recorder.cc
@@ -393,24 +393,24 @@ StatisticsRecorder::StatisticsRecorder() {
// static
void StatisticsRecorder::ResetForTesting() {
- if (histograms_) {
- STLDeleteValues(histograms_);
- delete histograms_;
- histograms_= nullptr;
- }
- if (ranges_) {
- for (auto& iter : *ranges_) {
- STLDeleteElements(iter.second);
- delete iter.second;
- }
- delete ranges_;
- ranges_ = nullptr;
- }
+ // This leaks a lot of objects but they've allready been annotated for such.
grt (UTC plus 2) 2016/02/15 15:42:39 "already"
bcwhite 2016/02/15 19:22:10 Done.
+ // Deleting them isn't possible because there could be other pointers to
+ // them somewhere.
+ delete histograms_;
+ histograms_= nullptr;
+ delete ranges_;
+ ranges_ = nullptr;
delete callbacks_;
callbacks_ = nullptr;
}
// static
+void StatisticsRecorder::ForgetHistogramForTesting(const std::string& name) {
+ if (histograms_)
+ histograms_->erase(HashMetricName(name));
+}
+
+// static
void StatisticsRecorder::DumpHistogramsToVlog(void* instance) {
std::string output;
StatisticsRecorder::WriteGraph(std::string(), &output);

Powered by Google App Engine
This is Rietveld 408576698