Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: chrome/browser/android/metrics/uma_session_stats.cc

Issue 2142983002: Add desktop engagement metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698