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> |
| 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 |
| 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 static void RecordRemotePlaybackDeviceSelected( |
| 44 JNIEnv*, jclass, jint device_type) { |
| 45 UMA_HISTOGRAM_ENUMERATION( |
| 46 "Cast.Sender.DeviceType", device_type, REMOTE_PLAYBACK_DEVICE_TYPE_COUNT); |
| 47 } |
| 48 |
| 49 static void RecordCastPlayRequested(JNIEnv*, jclass) { |
| 50 RecordAction(UserMetricsAction("Cast_Sender_CastPlayRequested")); |
| 51 } |
| 52 |
| 53 static void RecordCastDefaultPlayerResult(JNIEnv*, jclass, jboolean cast_success
) { |
| 54 if (cast_success) { |
| 55 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", DEFAULT_PLAYER_SUC
CESS, |
| 56 CAST_PLAYBACK_STATE_COUNT); |
| 57 } else { |
| 58 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", DEFAULT_PLAYER_FAI
LURE, |
| 59 CAST_PLAYBACK_STATE_COUNT); |
| 60 } |
| 61 } |
| 62 |
| 63 static void RecordCastYouTubePlayerResult(JNIEnv*, jclass, jboolean cast_success
) { |
| 64 if (cast_success) { |
| 65 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_SUCCESS, |
| 66 CAST_PLAYBACK_STATE_COUNT); |
| 67 } else { |
| 68 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastPlayerResult", YT_PLAYER_FAILURE, |
| 69 CAST_PLAYBACK_STATE_COUNT); |
| 70 } |
| 71 } |
| 72 |
| 73 static void RecordCastMediaType(JNIEnv*, jclass, jint media_type) { |
| 74 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastMediaType", media_type, |
| 75 media::container_names::CONTAINER_MAX); |
| 76 } |
| 77 |
| 78 static void RecordCastEndedTimeRemaining(JNIEnv*, jclass, jint video_total_time, |
| 79 jint time_left_in_video) { |
| 80 |
| 81 int percent_remaining = 100; |
| 82 if (video_total_time > 0) { |
| 83 // Get the percentage of video remaining, but bucketize into groups of 10 |
| 84 // since we don't really need that granular of data. |
| 85 percent_remaining = static_cast<int>( |
| 86 10.0 * time_left_in_video / video_total_time) * 10; |
| 87 } |
| 88 |
| 89 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage", |
| 90 percent_remaining, 101); |
| 91 } |
| 92 |
| 93 // Register native methods |
| 94 bool RegisterRecordCastAction(JNIEnv* env) { |
| 95 return RegisterNativesImpl(env); |
| 96 } |
OLD | NEW |