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

Unified Diff: chrome/browser/android/metrics/uma_session_stats.cc

Issue 2722113004: Flush UKM metrics when backgrounded on Android and iOS. (Closed)
Patch Set: add missing newline Created 3 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
« no previous file with comments | « no previous file | components/ukm/ukm_service.h » ('j') | components/ukm/ukm_service.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/metrics/uma_session_stats.cc
diff --git a/chrome/browser/android/metrics/uma_session_stats.cc b/chrome/browser/android/metrics/uma_session_stats.cc
index 854f9fc6614f54716800ddf3b2e07130f4314fb5..8e82df4f11b4814fca49ba520c997ccbf2fd1de6 100644
--- a/chrome/browser/android/metrics/uma_session_stats.cc
+++ b/chrome/browser/android/metrics/uma_session_stats.cc
@@ -20,6 +20,7 @@
#include "components/metrics/metrics_service.h"
#include "components/metrics_services_manager/metrics_services_manager.h"
#include "components/prefs/pref_service.h"
+#include "components/ukm/ukm_service.h"
#include "components/variations/metrics_util.h"
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_thread.h"
@@ -48,11 +49,15 @@ void UmaSessionStats::UmaResumeSession(JNIEnv* env,
if (active_session_count_ == 0) {
session_start_time_ = base::TimeTicks::Now();
- // Tell the metrics service that the application resumes.
+ // Tell the metrics services that the application resumes.
metrics::MetricsService* metrics = g_browser_process->metrics_service();
if (metrics) {
metrics->OnAppEnterForeground();
}
+ ukm::UkmService* ukm_service = g_browser_process->ukm_service();
+ if (ukm_service) {
Alexei Svitkine (slow) 2017/03/01 22:56:13 Nit: No {}s Remove them from metrics service case
Bryan McQuade 2017/03/01 23:06:50 Done
+ ukm_service->OnAppEnterForeground();
+ }
}
++active_session_count_;
}
@@ -70,11 +75,15 @@ void UmaSessionStats::UmaEndSession(JNIEnv* env,
UMA_HISTOGRAM_LONG_TIMES("Session.TotalDuration", duration);
DCHECK(g_browser_process);
- // Tell the metrics service it was cleanly shutdown.
+ // Tell the metrics services they were cleanly shutdown.
metrics::MetricsService* metrics = g_browser_process->metrics_service();
if (metrics) {
metrics->OnAppEnterBackground();
}
+ ukm::UkmService* ukm_service = g_browser_process->ukm_service();
+ if (ukm_service) {
+ ukm_service->OnAppEnterBackground();
+ }
}
}
« no previous file with comments | « no previous file | components/ukm/ukm_service.h » ('j') | components/ukm/ukm_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698