OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/media/android/remote/record_cast_action.h" | 5 #include "chrome/browser/media/android/remote/record_cast_action.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/public/browser/user_metrics.h" | 10 #include "content/public/browser/user_metrics.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 enum RemotePlaybackDeviceType { | 36 enum RemotePlaybackDeviceType { |
37 CAST_GENERIC = 0, | 37 CAST_GENERIC = 0, |
38 CAST_YOUTUBE = 1, | 38 CAST_YOUTUBE = 1, |
39 NON_CAST_YOUTUBE = 2, | 39 NON_CAST_YOUTUBE = 2, |
40 REMOTE_PLAYBACK_DEVICE_TYPE_COUNT = 3 | 40 REMOTE_PLAYBACK_DEVICE_TYPE_COUNT = 3 |
41 }; | 41 }; |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 namespace remote_media { | 45 namespace remote_media { |
46 static void RecordRemotePlaybackDeviceSelected( | 46 static void RecordRemotePlaybackDeviceSelected(JNIEnv*, |
47 JNIEnv*, jclass, jint device_type) { | 47 const JavaParamRef<jclass>&, |
| 48 jint device_type) { |
48 UMA_HISTOGRAM_ENUMERATION( | 49 UMA_HISTOGRAM_ENUMERATION( |
49 "Cast.Sender.DeviceType", device_type, REMOTE_PLAYBACK_DEVICE_TYPE_COUNT); | 50 "Cast.Sender.DeviceType", device_type, REMOTE_PLAYBACK_DEVICE_TYPE_COUNT); |
50 } | 51 } |
51 | 52 |
52 static void RecordCastPlayRequested(JNIEnv*, jclass) { | 53 static void RecordCastPlayRequested(JNIEnv*, const JavaParamRef<jclass>&) { |
53 RecordAction(UserMetricsAction("Cast_Sender_CastPlayRequested")); | 54 RecordAction(UserMetricsAction("Cast_Sender_CastPlayRequested")); |
54 } | 55 } |
55 | 56 |
56 static void RecordCastDefaultPlayerResult(JNIEnv*, | 57 static void RecordCastDefaultPlayerResult(JNIEnv*, |
57 jclass, | 58 const JavaParamRef<jclass>&, |
58 jboolean cast_success) { | 59 jboolean cast_success) { |
59 if (cast_success) { | 60 if (cast_success) { |
60 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", | 61 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", |
61 DEFAULT_PLAYER_SUCCESS, | 62 DEFAULT_PLAYER_SUCCESS, |
62 CAST_PLAYBACK_STATE_COUNT); | 63 CAST_PLAYBACK_STATE_COUNT); |
63 } else { | 64 } else { |
64 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", | 65 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", |
65 DEFAULT_PLAYER_FAILURE, | 66 DEFAULT_PLAYER_FAILURE, |
66 CAST_PLAYBACK_STATE_COUNT); | 67 CAST_PLAYBACK_STATE_COUNT); |
67 } | 68 } |
68 } | 69 } |
69 | 70 |
70 static void RecordCastYouTubePlayerResult(JNIEnv*, | 71 static void RecordCastYouTubePlayerResult(JNIEnv*, |
71 jclass, | 72 const JavaParamRef<jclass>&, |
72 jboolean cast_success) { | 73 jboolean cast_success) { |
73 if (cast_success) { | 74 if (cast_success) { |
74 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_SUCCESS, | 75 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_SUCCESS, |
75 CAST_PLAYBACK_STATE_COUNT); | 76 CAST_PLAYBACK_STATE_COUNT); |
76 } else { | 77 } else { |
77 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_FAILURE, | 78 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_FAILURE, |
78 CAST_PLAYBACK_STATE_COUNT); | 79 CAST_PLAYBACK_STATE_COUNT); |
79 } | 80 } |
80 } | 81 } |
81 | 82 |
82 static void RecordCastMediaType(JNIEnv*, jclass, jint media_type) { | 83 static void RecordCastMediaType(JNIEnv*, |
| 84 const JavaParamRef<jclass>&, |
| 85 jint media_type) { |
83 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastMediaType", media_type, | 86 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastMediaType", media_type, |
84 media::container_names::CONTAINER_MAX); | 87 media::container_names::CONTAINER_MAX); |
85 } | 88 } |
86 | 89 |
87 static void RecordCastEndedTimeRemaining(JNIEnv*, | 90 static void RecordCastEndedTimeRemaining(JNIEnv*, |
88 jclass, | 91 const JavaParamRef<jclass>&, |
89 jint video_total_time, | 92 jint video_total_time, |
90 jint time_left_in_video) { | 93 jint time_left_in_video) { |
91 int percent_remaining = 100; | 94 int percent_remaining = 100; |
92 if (video_total_time > 0) { | 95 if (video_total_time > 0) { |
93 // Get the percentage of video remaining, but bucketize into groups of 10 | 96 // Get the percentage of video remaining, but bucketize into groups of 10 |
94 // since we don't really need that granular of data. | 97 // since we don't really need that granular of data. |
95 percent_remaining = static_cast<int>( | 98 percent_remaining = static_cast<int>( |
96 10.0 * time_left_in_video / video_total_time) * 10; | 99 10.0 * time_left_in_video / video_total_time) * 10; |
97 } | 100 } |
98 | 101 |
99 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage", | 102 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage", |
100 percent_remaining, 101); | 103 percent_remaining, 101); |
101 } | 104 } |
102 | 105 |
103 // Register native methods | 106 // Register native methods |
104 bool RegisterRecordCastAction(JNIEnv* env) { | 107 bool RegisterRecordCastAction(JNIEnv* env) { |
105 return RegisterNativesImpl(env); | 108 return RegisterNativesImpl(env); |
106 } | 109 } |
107 | 110 |
108 } // namespace remote_media | 111 } // namespace remote_media |
OLD | NEW |