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

Unified Diff: base/metrics/statistics_recorder.cc

Issue 1748403003: Log histograms on shutdown when verbose logging is on (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 5 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/statistics_recorder.h ('k') | base/metrics/statistics_recorder_unittest.cc » ('j') | 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 1279bae6e0b60a26cd8e43d4a29ec12f684efc2a..a53f8f2a3c82f9a52f5e84a0930d158af0e189f8 100644
--- a/base/metrics/statistics_recorder.cc
+++ b/base/metrics/statistics_recorder.cc
@@ -338,6 +338,14 @@ StatisticsRecorder::HistogramIterator StatisticsRecorder::end() {
}
// static
+void StatisticsRecorder::InitLogOnShutdown() {
+ if (lock_ == nullptr)
+ return;
+ base::AutoLock auto_lock(*lock_);
+ g_statistics_recorder_.Get().InitLogOnShutdownWithoutLock();
+}
+
+// static
void StatisticsRecorder::GetSnapshot(const std::string& query,
Histograms* snapshot) {
if (lock_ == NULL)
@@ -482,8 +490,14 @@ StatisticsRecorder::StatisticsRecorder() {
callbacks_ = new CallbackMap;
ranges_ = new RangesMap;
- if (VLOG_IS_ON(1))
+ InitLogOnShutdownWithoutLock();
+}
+
+void StatisticsRecorder::InitLogOnShutdownWithoutLock() {
+ if (!vlog_initialized_ && VLOG_IS_ON(1)) {
+ vlog_initialized_ = true;
AtExitManager::RegisterCallback(&DumpHistogramsToVlog, this);
+ }
}
// static
« no previous file with comments | « base/metrics/statistics_recorder.h ('k') | base/metrics/statistics_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698