| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/metrics/uma_session_stats.h" | 5 #include "chrome/browser/android/metrics/uma_session_stats.h" |
| 6 | 6 |
| 7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // mobile connection (for example). | 101 // mobile connection (for example). |
| 102 // * Logs are neither being recorded or uploaded. | 102 // * Logs are neither being recorded or uploaded. |
| 103 static void UpdateMetricsServiceState(JNIEnv* env, | 103 static void UpdateMetricsServiceState(JNIEnv* env, |
| 104 const JavaParamRef<jobject>& obj, | 104 const JavaParamRef<jobject>& obj, |
| 105 jboolean may_record, | 105 jboolean may_record, |
| 106 jboolean may_upload) { | 106 jboolean may_upload) { |
| 107 metrics::MetricsService* metrics = g_browser_process->metrics_service(); | 107 metrics::MetricsService* metrics = g_browser_process->metrics_service(); |
| 108 DCHECK(metrics); | 108 DCHECK(metrics); |
| 109 | 109 |
| 110 if (metrics->recording_active() != may_record) { | 110 if (metrics->recording_active() != may_record) { |
| 111 UpdateMetricsPrefsOnPermissionChange(may_record); |
| 112 |
| 111 // This function puts a consent file with the ClientID in the | 113 // This function puts a consent file with the ClientID in the |
| 112 // data directory. The ID is passed to the renderer for crash | 114 // data directory. The ID is passed to the renderer for crash |
| 113 // reporting when things go wrong. | 115 // reporting when things go wrong. |
| 114 content::BrowserThread::GetBlockingPool()->PostTask(FROM_HERE, | 116 content::BrowserThread::GetBlockingPool()->PostTask(FROM_HERE, |
| 115 base::Bind( | 117 base::Bind( |
| 116 base::IgnoreResult(GoogleUpdateSettings::SetCollectStatsConsent), | 118 base::IgnoreResult(GoogleUpdateSettings::SetCollectStatsConsent), |
| 117 may_record)); | 119 may_record)); |
| 118 } | 120 } |
| 119 | 121 |
| 120 // Clear the client id pref when opting out. Note: Mirrors code in | |
| 121 // metrics_reporting_state.cc. TODO(asvitkine): Unify. | |
| 122 if (!may_record) { | |
| 123 // Note: Clearing client id will not affect the running state (e.g. field | |
| 124 // trial randomization), as the pref is only read on startup. | |
| 125 g_browser_process->local_state()->ClearPref( | |
| 126 metrics::prefs::kMetricsClientID); | |
| 127 g_browser_process->local_state()->ClearPref( | |
| 128 metrics::prefs::kMetricsReportingEnabledTimestamp); | |
| 129 } | |
| 130 | |
| 131 g_browser_process->GetMetricsServicesManager()->UpdatePermissions( | 122 g_browser_process->GetMetricsServicesManager()->UpdatePermissions( |
| 132 may_record, may_upload); | 123 may_record, may_upload); |
| 133 } | 124 } |
| 134 | 125 |
| 135 // Renderer process crashed in the foreground. | 126 // Renderer process crashed in the foreground. |
| 136 static void LogRendererCrash(JNIEnv*, const JavaParamRef<jclass>&) { | 127 static void LogRendererCrash(JNIEnv*, const JavaParamRef<jclass>&) { |
| 137 DCHECK(g_browser_process); | 128 DCHECK(g_browser_process); |
| 138 // Increment the renderer crash count in stability metrics. | 129 // Increment the renderer crash count in stability metrics. |
| 139 PrefService* pref = g_browser_process->local_state(); | 130 PrefService* pref = g_browser_process->local_state(); |
| 140 DCHECK(pref); | 131 DCHECK(pref); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // We should have only one UmaSessionStats instance. | 217 // We should have only one UmaSessionStats instance. |
| 227 DCHECK(!g_uma_session_stats); | 218 DCHECK(!g_uma_session_stats); |
| 228 g_uma_session_stats = new UmaSessionStats(); | 219 g_uma_session_stats = new UmaSessionStats(); |
| 229 return reinterpret_cast<intptr_t>(g_uma_session_stats); | 220 return reinterpret_cast<intptr_t>(g_uma_session_stats); |
| 230 } | 221 } |
| 231 | 222 |
| 232 // Register native methods | 223 // Register native methods |
| 233 bool RegisterUmaSessionStats(JNIEnv* env) { | 224 bool RegisterUmaSessionStats(JNIEnv* env) { |
| 234 return RegisterNativesImpl(env); | 225 return RegisterNativesImpl(env); |
| 235 } | 226 } |
| OLD | NEW |