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

Unified Diff: ios/chrome/browser/application_context_impl.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 | « ios/chrome/browser/application_context_impl.h ('k') | ios/chrome/test/testing_application_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/application_context_impl.cc
diff --git a/ios/chrome/browser/application_context_impl.cc b/ios/chrome/browser/application_context_impl.cc
index 8b4ac1bc66c064087da6308432d386ddac1ef9f4..2ac82a1690bdef62b31078b91d12051049c90655 100644
--- a/ios/chrome/browser/application_context_impl.cc
+++ b/ios/chrome/browser/application_context_impl.cc
@@ -31,6 +31,7 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/translate/core/browser/translate_download_manager.h"
+#include "components/ukm/ukm_service.h"
#include "components/update_client/configurator.h"
#include "components/update_client/update_query_params.h"
#include "components/variations/service/variations_service.h"
@@ -131,16 +132,18 @@ void ApplicationContextImpl::OnAppEnterForeground() {
PrefService* local_state = GetLocalState();
local_state->SetBoolean(prefs::kLastSessionExitedCleanly, false);
- // Tell the metrics service that the application resumes.
+ // Tell the metrics services that the application resumes.
metrics::MetricsService* metrics_service = GetMetricsService();
if (metrics_service && local_state) {
metrics_service->OnAppEnterForeground();
local_state->CommitPendingWrite();
}
-
variations::VariationsService* variations_service = GetVariationsService();
if (variations_service)
variations_service->OnAppEnterForeground();
+ ukm::UkmService* ukm_service = GetUkmService();
+ if (ukm_service)
+ ukm_service->OnAppEnterForeground();
}
void ApplicationContextImpl::OnAppEnterBackground() {
@@ -163,10 +166,13 @@ void ApplicationContextImpl::OnAppEnterBackground() {
PrefService* local_state = GetLocalState();
local_state->SetBoolean(prefs::kLastSessionExitedCleanly, true);
- // Tell the metrics service it was cleanly shutdown.
+ // Tell the metrics services they were cleanly shutdown.
metrics::MetricsService* metrics_service = GetMetricsService();
if (metrics_service && local_state)
metrics_service->OnAppEnterBackground();
+ ukm::UkmService* ukm_service = GetUkmService();
+ if (ukm_service)
+ ukm_service->OnAppEnterBackground();
// Persisting to disk is protected by a critical task, so no other special
// handling is necessary on iOS.
@@ -223,6 +229,11 @@ metrics::MetricsService* ApplicationContextImpl::GetMetricsService() {
return GetMetricsServicesManager()->GetMetricsService();
}
+ukm::UkmService* ApplicationContextImpl::GetUkmService() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ return GetMetricsServicesManager()->GetUkmService();
+}
+
variations::VariationsService* ApplicationContextImpl::GetVariationsService() {
DCHECK(thread_checker_.CalledOnValidThread());
return GetMetricsServicesManager()->GetVariationsService();
« no previous file with comments | « ios/chrome/browser/application_context_impl.h ('k') | ios/chrome/test/testing_application_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698