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..f07edd8ad20226606b1b044564ac10c16c0520a8 100644 |
--- a/chrome/browser/android/metrics/uma_session_stats.cc |
+++ b/chrome/browser/android/metrics/uma_session_stats.cc |
@@ -104,23 +104,29 @@ static void UpdateMetricsServiceState(JNIEnv* env, |
const JavaParamRef<jobject>& obj, |
jboolean may_record, |
jboolean may_upload) { |
- metrics::MetricsService* metrics = g_browser_process->metrics_service(); |
- DCHECK(metrics); |
+ // Used to detect when consent to record changes. Initiallized to false to |
+ // treat the startup path as a change when consent has been given. |
Alexei Svitkine (slow)
2016/08/18 06:16:39
Hmm, I am bit confused by this.
In my CL that add
jwd
2016/08/18 15:47:56
Shoot, yeah, should have caught that. But I do bel
Alexei Svitkine (slow)
2016/08/18 16:00:30
I think we should try to get to (4) eventually - m
jwd
2016/08/18 21:00:47
Currently, non-trivial, since the Update call is d
jwd
2016/08/23 18:40:03
Added the is_change parameter, and made it so that
|
+ static bool last_may_record = false; |
+ |
+ if (last_may_record != may_record) { |
+ last_may_record = may_record; |
- 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. |
+ // This function ensures a consent file in the data directory is either |
+ // created, or deleted, depending on may_record. 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), |
may_record)); |
} |
- 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. |