| 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_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/metrics/user_metrics.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 16 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/installer/util/google_update_settings.h" | 19 #include "chrome/installer/util/google_update_settings.h" |
| 19 #include "components/metrics/metrics_pref_names.h" | 20 #include "components/metrics/metrics_pref_names.h" |
| 20 #include "components/metrics/metrics_service.h" | 21 #include "components/metrics/metrics_service.h" |
| 21 #include "components/metrics_services_manager/metrics_services_manager.h" | 22 #include "components/metrics_services_manager/metrics_services_manager.h" |
| 22 #include "components/prefs/pref_service.h" | 23 #include "components/prefs/pref_service.h" |
| 23 #include "components/ukm/ukm_service.h" | 24 #include "components/ukm/ukm_service.h" |
| 24 #include "components/variations/metrics_util.h" | 25 #include "components/variations/metrics_util.h" |
| 25 #include "components/variations/variations_associated_data.h" | 26 #include "components/variations/variations_associated_data.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/user_metrics.h" | |
| 28 #include "jni/UmaSessionStats_jni.h" | 28 #include "jni/UmaSessionStats_jni.h" |
| 29 | 29 |
| 30 using base::android::ConvertJavaStringToUTF8; | 30 using base::android::ConvertJavaStringToUTF8; |
| 31 using base::android::JavaParamRef; | 31 using base::android::JavaParamRef; |
| 32 using base::UserMetricsAction; | 32 using base::UserMetricsAction; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 UmaSessionStats* g_uma_session_stats = NULL; | 35 UmaSessionStats* g_uma_session_stats = NULL; |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 const JavaParamRef<jclass>&, | 216 const JavaParamRef<jclass>&, |
| 217 jint num_tabs) { | 217 jint num_tabs) { |
| 218 // Record how many tabs total are open. | 218 // Record how many tabs total are open. |
| 219 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.TabCountPerLoad", num_tabs, 1, 200, 50); | 219 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.TabCountPerLoad", num_tabs, 1, 200, 50); |
| 220 } | 220 } |
| 221 | 221 |
| 222 static void RecordPageLoaded(JNIEnv*, | 222 static void RecordPageLoaded(JNIEnv*, |
| 223 const JavaParamRef<jclass>&, | 223 const JavaParamRef<jclass>&, |
| 224 jboolean is_desktop_user_agent) { | 224 jboolean is_desktop_user_agent) { |
| 225 // Should be called whenever a page has been loaded. | 225 // Should be called whenever a page has been loaded. |
| 226 content::RecordAction(UserMetricsAction("MobilePageLoaded")); | 226 base::RecordAction(UserMetricsAction("MobilePageLoaded")); |
| 227 if (is_desktop_user_agent) { | 227 if (is_desktop_user_agent) { |
| 228 content::RecordAction( | 228 base::RecordAction(UserMetricsAction("MobilePageLoadedDesktopUserAgent")); |
| 229 UserMetricsAction("MobilePageLoadedDesktopUserAgent")); | |
| 230 } | 229 } |
| 231 } | 230 } |
| 232 | 231 |
| 233 static void RecordPageLoadedWithKeyboard(JNIEnv*, const JavaParamRef<jclass>&) { | 232 static void RecordPageLoadedWithKeyboard(JNIEnv*, const JavaParamRef<jclass>&) { |
| 234 content::RecordAction(UserMetricsAction("MobilePageLoadedWithKeyboard")); | 233 base::RecordAction(UserMetricsAction("MobilePageLoadedWithKeyboard")); |
| 235 } | 234 } |
| 236 | 235 |
| 237 static jlong Init(JNIEnv* env, const JavaParamRef<jclass>& obj) { | 236 static jlong Init(JNIEnv* env, const JavaParamRef<jclass>& obj) { |
| 238 // We should have only one UmaSessionStats instance. | 237 // We should have only one UmaSessionStats instance. |
| 239 DCHECK(!g_uma_session_stats); | 238 DCHECK(!g_uma_session_stats); |
| 240 g_uma_session_stats = new UmaSessionStats(); | 239 g_uma_session_stats = new UmaSessionStats(); |
| 241 return reinterpret_cast<intptr_t>(g_uma_session_stats); | 240 return reinterpret_cast<intptr_t>(g_uma_session_stats); |
| 242 } | 241 } |
| 243 | 242 |
| 244 // Register native methods | 243 // Register native methods |
| 245 bool RegisterUmaSessionStats(JNIEnv* env) { | 244 bool RegisterUmaSessionStats(JNIEnv* env) { |
| 246 return RegisterNativesImpl(env); | 245 return RegisterNativesImpl(env); |
| 247 } | 246 } |
| OLD | NEW |