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

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

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 years, 5 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
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_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/metrics/user_metrics.h" 10 #include "base/metrics/user_metrics.h"
(...skipping 27 matching lines...) Expand all
38 NON_CAST_YOUTUBE = 2, 38 NON_CAST_YOUTUBE = 2,
39 REMOTE_PLAYBACK_DEVICE_TYPE_COUNT = 3 39 REMOTE_PLAYBACK_DEVICE_TYPE_COUNT = 3
40 }; 40 };
41 41
42 } // namespace 42 } // namespace
43 43
44 namespace remote_media { 44 namespace remote_media {
45 static void RecordRemotePlaybackDeviceSelected(JNIEnv*, 45 static void RecordRemotePlaybackDeviceSelected(JNIEnv*,
46 const JavaParamRef<jclass>&, 46 const JavaParamRef<jclass>&,
47 jint device_type) { 47 jint device_type) {
48 UMA_HISTOGRAM_ENUMERATION( 48 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.DeviceType",
49 "Cast.Sender.DeviceType", device_type, REMOTE_PLAYBACK_DEVICE_TYPE_COUNT); 49 static_cast<RemotePlaybackDeviceType>(device_type),
50 REMOTE_PLAYBACK_DEVICE_TYPE_COUNT);
50 } 51 }
51 52
52 static void RecordCastPlayRequested(JNIEnv*, const JavaParamRef<jclass>&) { 53 static void RecordCastPlayRequested(JNIEnv*, const JavaParamRef<jclass>&) {
53 base::RecordAction(base::UserMetricsAction("Cast_Sender_CastPlayRequested")); 54 base::RecordAction(base::UserMetricsAction("Cast_Sender_CastPlayRequested"));
54 } 55 }
55 56
56 static void RecordCastDefaultPlayerResult(JNIEnv*, 57 static void RecordCastDefaultPlayerResult(JNIEnv*,
57 const JavaParamRef<jclass>&, 58 const JavaParamRef<jclass>&,
58 jboolean cast_success) { 59 jboolean cast_success) {
59 if (cast_success) { 60 if (cast_success) {
(...skipping 15 matching lines...) Expand all
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*, 83 static void RecordCastMediaType(JNIEnv*,
83 const JavaParamRef<jclass>&, 84 const JavaParamRef<jclass>&,
84 jint media_type) { 85 jint media_type) {
85 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastMediaType", media_type, 86 UMA_HISTOGRAM_ENUMERATION(
87 "Cast.Sender.CastMediaType",
88 static_cast<media::container_names::MediaContainerName>(media_type),
86 media::container_names::CONTAINER_MAX); 89 media::container_names::CONTAINER_MAX);
87 } 90 }
88 91
89 static void RecordCastEndedTimeRemaining(JNIEnv*, 92 static void RecordCastEndedTimeRemaining(JNIEnv*,
90 const JavaParamRef<jclass>&, 93 const JavaParamRef<jclass>&,
91 jint video_total_time, 94 jint video_total_time,
92 jint time_left_in_video) { 95 jint time_left_in_video) {
93 int percent_remaining = 100; 96 int percent_remaining = 100;
94 if (video_total_time > 0) { 97 if (video_total_time > 0) {
95 // Get the percentage of video remaining, but bucketize into groups of 10 98 // Get the percentage of video remaining, but bucketize into groups of 10
96 // since we don't really need that granular of data. 99 // since we don't really need that granular of data.
97 percent_remaining = static_cast<int>( 100 percent_remaining = static_cast<int>(
98 10.0 * time_left_in_video / video_total_time) * 10; 101 10.0 * time_left_in_video / video_total_time) * 10;
99 } 102 }
100 103
101 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage", 104 UMA_HISTOGRAM_ENUMERATION("Cast.Sender.CastTimeRemainingPercentage",
102 percent_remaining, 101); 105 percent_remaining, 101);
103 } 106 }
104 107
105 // Register native methods 108 // Register native methods
106 bool RegisterRecordCastAction(JNIEnv* env) { 109 bool RegisterRecordCastAction(JNIEnv* env) {
107 return RegisterNativesImpl(env); 110 return RegisterNativesImpl(env);
108 } 111 }
109 112
110 } // namespace remote_media 113 } // namespace remote_media
OLDNEW
« no previous file with comments | « chrome/browser/engagement/important_sites_util.cc ('k') | chrome/browser/metrics/android_metrics_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698