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

Side by Side Diff: ui/file_manager/video_player/js/video_player_metrics.js

Issue 760853003: Adds histograms for casting feature of Video Player (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modify the description of the histogram Created 6 years 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 (c) 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 /**
6 * @fileoverview Utility methods for accessing chrome.metricsPrivate API.
7 *
8 * To be included as a first script in main.html
9 */
10
11 /**
12 * @extends {metricsBase}
13 */
14 var metrics = metricsBase;
15
16 /**
17 * Values for "VideoPlayer.CastExtensionStaus" metrics.
18 * @enum {number}
19 */
20 metrics.CAST_EXTENSION = {
21 EXTENSION_UNAVAILABLE: 0,
22 API_INSTALLATION_FAILED: 1,
23 API_LOAD_FAILED: 2,
24 API_INSTALLED_AND_LOADED: 3,
25 API_AVAILABLE_AND_LOADED: 4,
26 MAX_VALUE: 4,
27 };
28
29 /**
30 * Values for "VideoPlayer.PlayType" metrics.
31 * @enum {number}
32 */
33 metrics.PLAY_TYPE = {
34 LOCAL: 0,
35 CAST: 1,
36 MAX_VALUE: 1,
Ilya Sherman 2014/12/09 01:57:49 Unless the JS metrics API is different from the C+
yoshiki 2014/12/10 03:20:50 In the base class, the final value is passed with
37 };
38
39 /**
40 * Utility function to check if the given value is in the given values.
41 * @param {Object} values
42 * @param {*} value
43 * @reutrn {boolean} True if one or more elements of the given values hash have
44 * the given value as value. False otherwise.
45 */
46 metrics.hasValue_ = function(values, value) {
47 return Object.keys(values).some(function(key) {
48 return values[key] === value;
49 });
50 };
51
52 /**
53 * Record "VideoPlayer.CastExtensionStatsu" metrics.
54 * @param {metrics.CAST_EXTENSION} status Status to be recorded.
55 */
56 metrics.recordCastExtensionStatus = function(status) {
57 if (!metrics.hasValue_(metrics.CAST_EXTENSION, status)) {
58 console.error('The given value "' + status + '" is invalid.');
59 return;
60 }
61
62 metrics.recordEnum('CastExtensionStatus',
63 status,
64 metrics.CAST_EXTENSION.MAX_VALUE);
65 };
66
67 /**
68 * Record "VideoPlayer.NumberOfCastDevices" metrics.
69 * @param {number} number Value to be recorded.
70 */
71 metrics.recordNumberOfCastDevices = function(number) {
72 metrics.recordSmallCount('NumberOfCastDevices', number);
73 };
74
75 /**
76 * Record "VideoPlayer.NumberOfOpenedFile" metrics.
77 * @param {number} number Value to be recorded.
78 */
79 metrics.recordNumberOfOpenedFiles = function(number) {
80 metrics.recordSmallCount('NumberOfOpenedFiles', number);
81 };
82
83 /**
84 * Record "VideoPlayer.CastedVideoLength" metrics.
85 * @param {number} seconds Value to be recorded.
86 */
87 metrics.recordCastedVideoLength = function(seconds) {
88 metrics.recordMediumCount('CastedVideoLength', seconds);
89 };
90
91 /**
92 * Record "VideoPlayer.CastVideoError" metrics.
93 */
94 metrics.recordCastVideoErrorAction = function() {
95 metrics.recordUserAction('CastVideoError');
Ilya Sherman 2014/12/09 01:57:49 I don't see this defined in actions.xml
yoshiki 2014/12/10 03:20:50 I accidentally removed. Added.
96 };
97
98 /**
99 * Record "VideoPlayer.OpenVideoPlayer" action.
100 */
101 metrics.recordOpenVideoPlayerAction = function() {
102 metrics.recordUserAction('OpenVideoPlayer');
103 };
104
105 /**
106 * Record "VideoPlayer.PlayType" metrics.
107 * @param {metrics.PLAY_TYPE} type Value to be recorded.
108 */
109 metrics.recordPlayType = function(type) {
110 if (!metrics.hasValue_(metrics.PLAY_TYPE, type)) {
111 console.error('The given value "' + status + '" is invalid.');
112 return;
113 }
114
115 metrics.recordEnum('PlayType',
116 type,
117 metrics.PLAY_TYPE.MAX_VALUE);
118 };
119
120 /**
121 * Convert a short metric name to the full format.
122 *
123 * @param {string} name Short metric name.
124 * @return {string} Full metric name.
125 * @override
126 * @private
127 */
128 metrics.convertName_ = function(name) {
129 return 'VideoPlayer.' + name;
130 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698