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

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

Issue 2722113004: Flush UKM metrics when backgrounded on Android and iOS. (Closed)
Patch Set: address comment 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') | no next file with comments »
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..7e18f8a1449e18168de074cca724564d88a153e0 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,13 @@ 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) {
+ if (metrics)
metrics->OnAppEnterForeground();
- }
+ ukm::UkmService* ukm_service = g_browser_process->ukm_service();
+ if (ukm_service)
+ ukm_service->OnAppEnterForeground();
}
++active_session_count_;
}
@@ -70,11 +73,13 @@ 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) {
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698