Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / media / android / remote / record_cast_action.cc
blob386083be0ffa72030a9a6e6914374ac160a3f470
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(
47 JNIEnv*, jclass, jint device_type) {
48 UMA_HISTOGRAM_ENUMERATION(
49 "Cast.Sender.DeviceType", device_type, REMOTE_PLAYBACK_DEVICE_TYPE_COUNT);
52 static void RecordCastPlayRequested(JNIEnv*, jclass) {
53 RecordAction(UserMetricsAction("Cast_Sender_CastPlayRequested"));
56 static void RecordCastDefaultPlayerResult(JNIEnv*,
57 jclass,
58 jboolean cast_success) {
59 if (cast_success) {
60 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult",
61 DEFAULT_PLAYER_SUCCESS,
62 CAST_PLAYBACK_STATE_COUNT);
63 } else {
64 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult",
65 DEFAULT_PLAYER_FAILURE,
66 CAST_PLAYBACK_STATE_COUNT);
70 static void RecordCastYouTubePlayerResult(JNIEnv*,
71 jclass,
72 jboolean cast_success) {
73 if (cast_success) {
74 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_SUCCESS,
75 CAST_PLAYBACK_STATE_COUNT);
76 } else {
77 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_FAILURE,
78 CAST_PLAYBACK_STATE_COUNT);
82 static void RecordCastMediaType(JNIEnv*, jclass, jint media_type) {
83 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastMediaType", media_type,
84 media::container_names::CONTAINER_MAX);
87 static void RecordCastEndedTimeRemaining(JNIEnv*,
88 jclass,
89 jint video_total_time,
90 jint time_left_in_video) {
91 int percent_remaining = 100;
92 if (video_total_time > 0) {
93 // Get the percentage of video remaining, but bucketize into groups of 10
94 // since we don't really need that granular of data.
95 percent_remaining = static_cast<int>(
96 10.0 * time_left_in_video / video_total_time) * 10;
99 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage",
100 percent_remaining, 101);
103 // Register native methods
104 bool RegisterRecordCastAction(JNIEnv* env) {
105 return RegisterNativesImpl(env);
108 } // namespace remote_media