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

Side by Side Diff: chrome/browser/media/android/remote/record_cast_action.cc

Issue 928643003: Upstream Chrome for Android Cast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix dependencies (second attempt). Created 5 years, 9 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
OLDNEW
(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
7 #include <jni.h>
8
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"
13
14 using base::UserMetricsAction;
15 using content::RecordAction;
16
17 namespace {
18
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
27 };
28
29 // When updating these values, remember to also update
30 // tools/histograms/histograms.xml.
31
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
41 };
42
43 } // namespace
44
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);
50 }
51
52 static void RecordCastPlayRequested(JNIEnv*, jclass) {
53 RecordAction(UserMetricsAction("Cast_Sender_CastPlayRequested"));
54 }
55
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);
67 }
68 }
69
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);
79 }
80 }
81
82 static void RecordCastMediaType(JNIEnv*, jclass, jint media_type) {
83 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastMediaType", media_type,
84 media::container_names::CONTAINER_MAX);
85 }
86
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;
97 }
98
99 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage",
100 percent_remaining, 101);
101 }
102
103 // Register native methods
104 bool RegisterRecordCastAction(JNIEnv* env) {
105 return RegisterNativesImpl(env);
106 }
107
108 } // namespace remote_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698