Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / chrome / browser / media / android / remote / record_cast_action.cc
blob7f9b5ad3a68fefc45ecde59d571ced73a8615445
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.
5 #include "chrome/browser/media/android/remote/record_cast_action.h"
7 #include <jni.h>
9 #include "base/metrics/histogram.h"
10 #include "content/public/browser/user_metrics.h"
11 #include "jni/RecordCastAction_jni.h"
12 #include "media/base/container_names.h"
14 using base::UserMetricsAction;
15 using content::RecordAction;
17 namespace {
19 // When updating these values, remember to also update
20 // tools/histograms/histograms.xml.
21 enum CastPlayBackState {
22 YT_PLAYER_SUCCESS = 0,
23 YT_PLAYER_FAILURE = 1,
24 DEFAULT_PLAYER_SUCCESS = 2,
25 DEFAULT_PLAYER_FAILURE = 3,
26 CAST_PLAYBACK_STATE_COUNT = 4
29 // When updating these values, remember to also update
30 // tools/histograms/histograms.xml.
32 // This is actually a misnomer, it should be RemotePlaybackPlayerType, but it is
33 // more important that it matches the histogram name in histograms.xml.
34 // TODO(aberent) Change this once we are upstream, when can change it both here
35 // and in histogram.xml in the same CL.
36 enum RemotePlaybackDeviceType {
37 CAST_GENERIC = 0,
38 CAST_YOUTUBE = 1,
39 NON_CAST_YOUTUBE = 2,
40 REMOTE_PLAYBACK_DEVICE_TYPE_COUNT = 3
43 } // namespace
45 namespace remote_media {
46 static void RecordRemotePlaybackDeviceSelected(JNIEnv*,
47 const JavaParamRef<jclass>&,
48 jint device_type) {
49 UMA_HISTOGRAM_ENUMERATION(
50 "Cast.Sender.DeviceType", device_type, REMOTE_PLAYBACK_DEVICE_TYPE_COUNT);
53 static void RecordCastPlayRequested(JNIEnv*, const JavaParamRef<jclass>&) {
54 RecordAction(UserMetricsAction("Cast_Sender_CastPlayRequested"));
57 static void RecordCastDefaultPlayerResult(JNIEnv*,
58 const JavaParamRef<jclass>&,
59 jboolean cast_success) {
60 if (cast_success) {
61 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult",
62 DEFAULT_PLAYER_SUCCESS,
63 CAST_PLAYBACK_STATE_COUNT);
64 } else {
65 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult",
66 DEFAULT_PLAYER_FAILURE,
67 CAST_PLAYBACK_STATE_COUNT);
71 static void RecordCastYouTubePlayerResult(JNIEnv*,
72 const JavaParamRef<jclass>&,
73 jboolean cast_success) {
74 if (cast_success) {
75 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_SUCCESS,
76 CAST_PLAYBACK_STATE_COUNT);
77 } else {
78 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_FAILURE,
79 CAST_PLAYBACK_STATE_COUNT);
83 static void RecordCastMediaType(JNIEnv*,
84 const JavaParamRef<jclass>&,
85 jint media_type) {
86 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastMediaType", media_type,
87 media::container_names::CONTAINER_MAX);
90 static void RecordCastEndedTimeRemaining(JNIEnv*,
91 const JavaParamRef<jclass>&,
92 jint video_total_time,
93 jint time_left_in_video) {
94 int percent_remaining = 100;
95 if (video_total_time > 0) {
96 // Get the percentage of video remaining, but bucketize into groups of 10
97 // since we don't really need that granular of data.
98 percent_remaining = static_cast<int>(
99 10.0 * time_left_in_video / video_total_time) * 10;
102 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage",
103 percent_remaining, 101);
106 // Register native methods
107 bool RegisterRecordCastAction(JNIEnv* env) {
108 return RegisterNativesImpl(env);
111 } // namespace remote_media