OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/media/android/remote/record_cast_action.h" | |
6 #include <jni.h> | |
scherkus (not reviewing)
2015/03/12 19:15:04
nit: you've got the #include ordering / spacing co
aberent
2015/03/13 19:04:35
Done.
| |
7 #include "base/metrics/histogram.h" | |
8 #include "content/public/browser/user_metrics.h" | |
9 #include "jni/RecordCastAction_jni.h" | |
10 #include "media/base/container_names.h" | |
11 | |
12 using base::UserMetricsAction; | |
13 using content::RecordAction; | |
14 | |
15 namespace { | |
16 | |
17 // When updating these values, remember to also update | |
18 // tools/histograms/histograms.xml. | |
19 enum CastPlayBackState { | |
20 YT_PLAYER_SUCCESS = 0, | |
21 YT_PLAYER_FAILURE = 1, | |
22 DEFAULT_PLAYER_SUCCESS = 2, | |
23 DEFAULT_PLAYER_FAILURE = 3, | |
24 CAST_PLAYBACK_STATE_COUNT = 4 | |
25 }; | |
26 | |
27 // When updating these values, remember to also update | |
28 // tools/histograms/histograms.xml. | |
29 | |
30 // This is actually a misnomer, it should be RemotePlaybackPlayerType, but it is | |
31 // more important that it matches the histogram name in histograms.xml. | |
32 // TODO (aberent) Change this once we are upstream, when can change it both here | |
Bernhard Bauer
2015/03/13 12:18:02
Super-nit: Use the style "TODO(ldap): [...]", as i
aberent
2015/03/13 19:04:35
Done.
| |
33 // and in histogram.xml in the same CL. | |
34 enum RemotePlaybackDeviceType { | |
35 CAST_GENERIC = 0, | |
36 CAST_YOUTUBE = 1, | |
37 NON_CAST_YOUTUBE = 2, | |
38 REMOTE_PLAYBACK_DEVICE_TYPE_COUNT = 3 | |
39 }; | |
40 | |
41 } // namespace | |
42 | |
43 namespace remote_media { | |
44 static void RecordRemotePlaybackDeviceSelected( | |
45 JNIEnv*, jclass, jint device_type) { | |
46 UMA_HISTOGRAM_ENUMERATION( | |
47 "Cast.Sender.DeviceType", device_type, REMOTE_PLAYBACK_DEVICE_TYPE_COUNT); | |
48 } | |
49 | |
50 static void RecordCastPlayRequested(JNIEnv*, jclass) { | |
51 RecordAction(UserMetricsAction("Cast_Sender_CastPlayRequested")); | |
52 } | |
53 | |
54 static void RecordCastDefaultPlayerResult(JNIEnv*, | |
55 jclass, | |
56 jboolean cast_success) { | |
57 if (cast_success) { | |
58 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", | |
59 DEFAULT_PLAYER_SUCCESS, | |
60 CAST_PLAYBACK_STATE_COUNT); | |
61 } else { | |
62 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", | |
63 DEFAULT_PLAYER_FAILURE, | |
64 CAST_PLAYBACK_STATE_COUNT); | |
65 } | |
66 } | |
67 | |
68 static void RecordCastYouTubePlayerResult(JNIEnv*, | |
69 jclass, | |
70 jboolean cast_success) { | |
71 if (cast_success) { | |
72 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_SUCCESS, | |
73 CAST_PLAYBACK_STATE_COUNT); | |
74 } else { | |
75 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_FAILURE, | |
76 CAST_PLAYBACK_STATE_COUNT); | |
77 } | |
78 } | |
79 | |
80 static void RecordCastMediaType(JNIEnv*, jclass, jint media_type) { | |
81 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastMediaType", media_type, | |
82 media::container_names::CONTAINER_MAX); | |
83 } | |
84 | |
85 static void RecordCastEndedTimeRemaining(JNIEnv*, jclass, jint video_total_time, | |
Bernhard Bauer
2015/03/13 12:18:02
In C++, put each parameter on a separate line if t
aberent
2015/03/13 19:04:35
Done.
| |
86 jint time_left_in_video) { | |
87 | |
88 int percent_remaining = 100; | |
89 if (video_total_time > 0) { | |
90 // Get the percentage of video remaining, but bucketize into groups of 10 | |
91 // since we don't really need that granular of data. | |
92 percent_remaining = static_cast<int>( | |
93 10.0 * time_left_in_video / video_total_time) * 10; | |
94 } | |
95 | |
96 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage", | |
97 percent_remaining, 101); | |
98 } | |
99 | |
100 // Register native methods | |
101 bool RegisterRecordCastAction(JNIEnv* env) { | |
102 return RegisterNativesImpl(env); | |
103 } | |
104 | |
105 } // namespace remote_media | |
OLD | NEW |