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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 if (metrics->recording_active() != may_record) { | 110 if (metrics->recording_active() != may_record) { |
111 // This function puts a consent file with the ClientID in the | 111 // This function puts a consent file with the ClientID in the |
112 // data directory. The ID is passed to the renderer for crash | 112 // data directory. The ID is passed to the renderer for crash |
113 // reporting when things go wrong. | 113 // reporting when things go wrong. |
114 content::BrowserThread::GetBlockingPool()->PostTask(FROM_HERE, | 114 content::BrowserThread::GetBlockingPool()->PostTask(FROM_HERE, |
115 base::Bind( | 115 base::Bind( |
116 base::IgnoreResult(GoogleUpdateSettings::SetCollectStatsConsent), | 116 base::IgnoreResult(GoogleUpdateSettings::SetCollectStatsConsent), |
117 may_record)); | 117 may_record)); |
118 } | 118 } |
119 | 119 |
| 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 |
120 g_browser_process->GetMetricsServicesManager()->UpdatePermissions( | 131 g_browser_process->GetMetricsServicesManager()->UpdatePermissions( |
121 may_record, may_upload); | 132 may_record, may_upload); |
122 } | 133 } |
123 | 134 |
124 // Renderer process crashed in the foreground. | 135 // Renderer process crashed in the foreground. |
125 static void LogRendererCrash(JNIEnv*, const JavaParamRef<jclass>&) { | 136 static void LogRendererCrash(JNIEnv*, const JavaParamRef<jclass>&) { |
126 DCHECK(g_browser_process); | 137 DCHECK(g_browser_process); |
127 // Increment the renderer crash count in stability metrics. | 138 // Increment the renderer crash count in stability metrics. |
128 PrefService* pref = g_browser_process->local_state(); | 139 PrefService* pref = g_browser_process->local_state(); |
129 DCHECK(pref); | 140 DCHECK(pref); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // We should have only one UmaSessionStats instance. | 226 // We should have only one UmaSessionStats instance. |
216 DCHECK(!g_uma_session_stats); | 227 DCHECK(!g_uma_session_stats); |
217 g_uma_session_stats = new UmaSessionStats(); | 228 g_uma_session_stats = new UmaSessionStats(); |
218 return reinterpret_cast<intptr_t>(g_uma_session_stats); | 229 return reinterpret_cast<intptr_t>(g_uma_session_stats); |
219 } | 230 } |
220 | 231 |
221 // Register native methods | 232 // Register native methods |
222 bool RegisterUmaSessionStats(JNIEnv* env) { | 233 bool RegisterUmaSessionStats(JNIEnv* env) { |
223 return RegisterNativesImpl(env); | 234 return RegisterNativesImpl(env); |
224 } | 235 } |
OLD | NEW |