| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 ++active_session_count_; | 55 ++active_session_count_; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void UmaSessionStats::UmaEndSession(JNIEnv* env, | 58 void UmaSessionStats::UmaEndSession(JNIEnv* env, |
| 59 const JavaParamRef<jobject>& obj) { | 59 const JavaParamRef<jobject>& obj) { |
| 60 --active_session_count_; | 60 --active_session_count_; |
| 61 DCHECK_GE(active_session_count_, 0); | 61 DCHECK_GE(active_session_count_, 0); |
| 62 | 62 |
| 63 if (active_session_count_ == 0) { | 63 if (active_session_count_ == 0) { |
| 64 base::TimeDelta duration = base::TimeTicks::Now() - session_start_time_; | 64 base::TimeDelta duration = base::TimeTicks::Now() - session_start_time_; |
| 65 |
| 66 // Note: This metric is recorded separately on desktop in |
| 67 // DesktopEngagementService::EndSession. |
| 65 UMA_HISTOGRAM_LONG_TIMES("Session.TotalDuration", duration); | 68 UMA_HISTOGRAM_LONG_TIMES("Session.TotalDuration", duration); |
| 66 | 69 |
| 67 DCHECK(g_browser_process); | 70 DCHECK(g_browser_process); |
| 68 // Tell the metrics service it was cleanly shutdown. | 71 // Tell the metrics service it was cleanly shutdown. |
| 69 metrics::MetricsService* metrics = g_browser_process->metrics_service(); | 72 metrics::MetricsService* metrics = g_browser_process->metrics_service(); |
| 70 if (metrics) { | 73 if (metrics) { |
| 71 metrics->OnAppEnterBackground(); | 74 metrics->OnAppEnterBackground(); |
| 72 } | 75 } |
| 73 } | 76 } |
| 74 } | 77 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // We should have only one UmaSessionStats instance. | 207 // We should have only one UmaSessionStats instance. |
| 205 DCHECK(!g_uma_session_stats); | 208 DCHECK(!g_uma_session_stats); |
| 206 g_uma_session_stats = new UmaSessionStats(); | 209 g_uma_session_stats = new UmaSessionStats(); |
| 207 return reinterpret_cast<intptr_t>(g_uma_session_stats); | 210 return reinterpret_cast<intptr_t>(g_uma_session_stats); |
| 208 } | 211 } |
| 209 | 212 |
| 210 // Register native methods | 213 // Register native methods |
| 211 bool RegisterUmaSessionStats(JNIEnv* env) { | 214 bool RegisterUmaSessionStats(JNIEnv* env) { |
| 212 return RegisterNativesImpl(env); | 215 return RegisterNativesImpl(env); |
| 213 } | 216 } |
| OLD | NEW |