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

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

Issue 2248243002: Enabling sampling of UMA and crash reports on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some of Ilya's comments Created 4 years, 4 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: 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 e209d4fddba7e04dd1df6da2e6c62fa15ad0fb12..268de0be1cfd5cfe2716bf921dc751dc4030bbab 100644
--- a/chrome/browser/android/metrics/uma_session_stats.cc
+++ b/chrome/browser/android/metrics/uma_session_stats.cc
@@ -93,6 +93,22 @@ void UmaSessionStats::RegisterSyntheticMultiGroupFieldTrial(
trial_name, group_name_hashes);
}
+// Updates metrics reporting state managed by native code.
+static void ChangeMetricsReportingConsent(JNIEnv*,
+ const JavaParamRef<jclass>&,
+ jboolean consent) {
+ UpdateMetricsPrefsOnPermissionChange(consent);
+
+ // This function ensures a consent file in the data directory is either
+ // created, or deleted, depending on consent. Starting up metrics services
+ // will ensure that the consent file contains the ClientID. The ID is passed
+ // to the renderer for crash reporting when things go wrong.
+ content::BrowserThread::GetBlockingPool()->PostTask(
+ FROM_HERE, base::Bind(base::IgnoreResult(
+ GoogleUpdateSettings::SetCollectStatsConsent),
+ consent));
+}
+
// Starts/stops the MetricsService when permissions have changed.
// There are three possible states:
// * Logs are being recorded and being uploaded to the server.
@@ -100,27 +116,16 @@ void UmaSessionStats::RegisterSyntheticMultiGroupFieldTrial(
// This happens when we've got permission to upload on Wi-Fi but we're on a
// mobile connection (for example).
// * Logs are neither being recorded or uploaded.
-static void UpdateMetricsServiceState(JNIEnv* env,
- const JavaParamRef<jobject>& obj,
+static void UpdateMetricsServiceState(JNIEnv*,
+ const JavaParamRef<jclass>&,
jboolean may_record,
jboolean may_upload) {
- metrics::MetricsService* metrics = g_browser_process->metrics_service();
- DCHECK(metrics);
-
- if (metrics->recording_active() != may_record) {
- UpdateMetricsPrefsOnPermissionChange(may_record);
-
- // This function puts a consent file with the ClientID in the
- // data directory. The ID is passed to the renderer for crash
- // reporting when things go wrong.
- content::BrowserThread::GetBlockingPool()->PostTask(FROM_HERE,
- base::Bind(
- base::IgnoreResult(GoogleUpdateSettings::SetCollectStatsConsent),
- may_record));
- }
+ DCHECK(may_record || !may_upload);
- g_browser_process->GetMetricsServicesManager()->UpdatePermissions(
- may_record, may_upload);
+ // This will also apply the consent state, taken from Chrome Local State
+ // prefs.
+ g_browser_process->GetMetricsServicesManager()->UpdateUploadPermissions(
+ may_upload);
}
// Renderer process crashed in the foreground.

Powered by Google App Engine
This is Rietveld 408576698