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

Unified Diff: components/metrics/metrics_service.cc

Issue 2175743002: Add MetricsProvider::OnAppEnterBackground callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment 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
Index: components/metrics/metrics_service.cc
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
index cad15984141323b821d374be362e103287d88dc8..5a3269fc3c823b07e587e50ec20a14a776cad053 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -474,6 +474,11 @@ void MetricsService::OnAppEnterBackground() {
// persisting all logs. Unlinke a shutdown, the state is primed to be ready
// to continue logging and uploading if the process does return.
if (recording_active() && state_ >= SENDING_LOGS) {
+ // Give providers a chance to persist histograms as part of being
+ // backgrounded.
+ for (MetricsProvider* provider : metrics_providers_)
Bryan McQuade 2016/07/27 13:18:34 I wasnt't sure if we should be informing providers
Alexei Svitkine (slow) 2016/07/27 17:41:11 It's debatable, but I somewhat prefer doing it out
Bryan McQuade 2016/07/27 18:25:15 Good point, I agree. I moved it.
+ provider->OnAppEnterBackground();
+
PushPendingLogsToPersistentStorage();
// Persisting logs closes the current log, so start recording a new log
// immediately to capture any background work that might be done before the
« components/metrics/metrics_provider.h ('K') | « components/metrics/metrics_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698