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

Side by Side Diff: chromecast/base/metrics/cast_metrics_helper.h

Issue 786233003: Add UpdateCurrentAppInfo() interface to record info about current app, including (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 #ifndef CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_ 5 #ifndef CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_
6 #define CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_ 6 #define CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 13 matching lines...) Expand all
24 class CastMetricsHelper { 24 class CastMetricsHelper {
25 public: 25 public:
26 enum BufferingType { 26 enum BufferingType {
27 kInitialBuffering, 27 kInitialBuffering,
28 kBufferingAfterUnderrun, 28 kBufferingAfterUnderrun,
29 kAbortedBuffering, 29 kAbortedBuffering,
30 }; 30 };
31 31
32 typedef base::Callback<void(const std::string&)> RecordActionCallback; 32 typedef base::Callback<void(const std::string&)> RecordActionCallback;
33 33
34 struct MetricsAppInfo {
35 MetricsAppInfo();
36 ~MetricsAppInfo();
byungchul 2014/12/11 00:15:26 Not necessary
gfhuang 2014/12/11 02:59:39 Done.
37
38 std::string action_name;
39 std::string app_id;
40 std::string session_id;
41 std::string sdk_version;
42 };
43
34 class MetricsSink { 44 class MetricsSink {
35 public: 45 public:
36 virtual ~MetricsSink() {} 46 virtual ~MetricsSink() {}
37 47
38 virtual void OnAction(const std::string& action) = 0; 48 virtual void OnAction(const std::string& action) = 0;
39 virtual void OnEnumerationEvent(const std::string& name, 49 virtual void OnEnumerationEvent(const std::string& name,
40 int value, int num_buckets) = 0; 50 int value, int num_buckets) = 0;
41 virtual void OnTimeEvent(const std::string& name, 51 virtual void OnTimeEvent(const std::string& name,
42 const base::TimeDelta& value, 52 const base::TimeDelta& value,
43 const base::TimeDelta& min, 53 const base::TimeDelta& min,
44 const base::TimeDelta& max, 54 const base::TimeDelta& max,
45 int num_buckets) = 0; 55 int num_buckets) = 0;
46 }; 56 };
47 57
58 // Delimiter character used in GetMetricsNameWithAppInfo().
59 static const char kMetricsNameAppInfoDelimiter;
gunsch 2014/12/10 22:43:58 will this be referenced outside this file? I would
gfhuang 2014/12/11 02:59:39 Done.
60
61 // Decodes action_name/app_id/session_id/sdk_version from metrics name
62 // generated from GetMetricsNameWithAppInfo().
63 static MetricsAppInfo GetAppInfoFromMetricsName(
64 const std::string& metrics_name);
byungchul 2014/12/11 00:15:26 Do we prefer structure copy? Why not get out param
gfhuang 2014/12/11 02:59:39 Done.
byungchul 2014/12/11 18:35:49 Though I meant passing the pointer of the structur
gfhuang 2014/12/11 19:20:26 Ack. define struct has an extra burden to maintain
65
48 static CastMetricsHelper* GetInstance(); 66 static CastMetricsHelper* GetInstance();
49 67
50 explicit CastMetricsHelper( 68 explicit CastMetricsHelper(
51 scoped_refptr<base::MessageLoopProxy> message_loop_proxy); 69 scoped_refptr<base::MessageLoopProxy> message_loop_proxy);
52 virtual ~CastMetricsHelper(); 70 virtual ~CastMetricsHelper();
53 71
54 // This function stores the name and startup time of the active application. 72 // This function stores the name and startup time of the active application.
55 virtual void TagAppStart(const std::string& app_name); 73 virtual void TagAppStart(const std::string& app_name);
74 // This function updates the info for current active application.
75 virtual void UpdateCurrentAppInfo(const std::string& app_id,
76 const std::string& session_id,
77 const std::string& sdk_version);
56 78
57 // Logs UMA record for media play/pause user actions. 79 // Logs UMA record for media play/pause user actions.
58 virtual void LogMediaPlay(); 80 virtual void LogMediaPlay();
59 virtual void LogMediaPause(); 81 virtual void LogMediaPause();
60 82
61 // Logs a simple UMA user action. 83 // Logs a simple UMA user action.
62 // This is used as an in-place replacement of content::RecordComputedAction(). 84 // This is used as an in-place replacement of content::RecordComputedAction().
63 virtual void RecordSimpleAction(const std::string& action); 85 virtual void RecordSimpleAction(const std::string& action);
64 86
65 // Logs UMA record of the elapsed time from the app launch 87 // Logs UMA record of the elapsed time from the app launch
66 // to the time first video frame is displayed. 88 // to the time first video frame is displayed.
67 virtual void LogTimeToDisplayVideo(); 89 virtual void LogTimeToDisplayVideo();
68 90
69 // Logs UMA record of the time needed to re-buffer A/V. 91 // Logs UMA record of the time needed to re-buffer A/V.
70 virtual void LogTimeToBufferAv(BufferingType buffering_type, 92 virtual void LogTimeToBufferAv(BufferingType buffering_type,
71 base::TimeDelta time); 93 base::TimeDelta time);
72 94
73 virtual void ResetVideoFrameSampling(); 95 virtual void ResetVideoFrameSampling();
74 96
75 // Logs UMA statistics for video decoder and rendering data. 97 // Logs UMA statistics for video decoder and rendering data.
76 // Negative values are considered invalid and will not be logged. 98 // Negative values are considered invalid and will not be logged.
77 virtual void LogFramesPer5Seconds(int displayed_frames, int dropped_frames, 99 virtual void LogFramesPer5Seconds(int displayed_frames, int dropped_frames,
78 int delayed_frames, int error_frames); 100 int delayed_frames, int error_frames);
79 101
80 // Returns metrics name with app name between prefix and suffix. 102 // Returns metrics name with app name between prefix and suffix.
81 virtual std::string GetMetricsNameWithAppName( 103 virtual std::string GetMetricsNameWithAppName(
82 const std::string& prefix, 104 const std::string& prefix,
83 const std::string& suffix) const; 105 const std::string& suffix) const;
106 // Returns metrics name with app_id/session_id/sdk_version.
107 virtual std::string GetMetricsNameWithAppInfo(
108 const std::string& action_name) const;
84 109
85 // Provides a MetricsSink instance to delegate UMA event logging. 110 // Provides a MetricsSink instance to delegate UMA event logging.
86 // Once the delegate interface is set, CastMetricsHelper will not log UMA 111 // Once the delegate interface is set, CastMetricsHelper will not log UMA
87 // events internally unless SetMetricsSink(NULL) is called. 112 // events internally unless SetMetricsSink(NULL) is called.
88 // CastMetricsHelper can only hold one MetricsSink instance. 113 // CastMetricsHelper can only hold one MetricsSink instance.
89 // Caller retains ownership of MetricsSink. 114 // Caller retains ownership of MetricsSink.
90 virtual void SetMetricsSink(MetricsSink* delegate); 115 virtual void SetMetricsSink(MetricsSink* delegate);
91 116
92 // Sets a default callback to record user action when MetricsSink is not set. 117 // Sets a default callback to record user action when MetricsSink is not set.
93 // This function could be called multiple times (in unittests), and 118 // This function could be called multiple times (in unittests), and
(...skipping 17 matching lines...) Expand all
111 void LogMediumTimeHistogramEvent(const std::string& name, 136 void LogMediumTimeHistogramEvent(const std::string& name,
112 const base::TimeDelta& value); 137 const base::TimeDelta& value);
113 138
114 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 139 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
115 140
116 // Start time of the most recent app. 141 // Start time of the most recent app.
117 base::TimeTicks app_start_time_; 142 base::TimeTicks app_start_time_;
118 143
119 // Currently running app name. Used to construct histogram name. 144 // Currently running app name. Used to construct histogram name.
120 std::string app_name_; 145 std::string app_name_;
146 std::string app_id_;
147 std::string session_id_;
148 std::string sdk_version_;
121 149
122 // Whether a new app start time has been stored but not recorded. 150 // Whether a new app start time has been stored but not recorded.
123 // After the startup time has been used to generate an UMA event, 151 // After the startup time has been used to generate an UMA event,
124 // this is set to false. 152 // this is set to false.
125 bool new_startup_time_; 153 bool new_startup_time_;
126 154
127 base::TimeTicks previous_video_stat_sample_time_; 155 base::TimeTicks previous_video_stat_sample_time_;
128 156
129 MetricsSink* metrics_sink_; 157 MetricsSink* metrics_sink_;
130 // Default RecordAction callback when metrics_sink_ is not set. 158 // Default RecordAction callback when metrics_sink_ is not set.
131 RecordActionCallback record_action_callback_; 159 RecordActionCallback record_action_callback_;
132 160
133 DISALLOW_COPY_AND_ASSIGN(CastMetricsHelper); 161 DISALLOW_COPY_AND_ASSIGN(CastMetricsHelper);
134 }; 162 };
135 163
136 } // namespace metrics 164 } // namespace metrics
137 } // namespace chromecast 165 } // namespace chromecast
138 166
139 #endif // CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_ 167 #endif // CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chromecast/base/metrics/cast_metrics_helper.cc » ('j') | chromecast/base/metrics/cast_metrics_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698