OLD | NEW |
---|---|
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 }; | 46 }; |
47 | 47 |
48 static CastMetricsHelper* GetInstance(); | 48 static CastMetricsHelper* GetInstance(); |
49 | 49 |
50 explicit CastMetricsHelper( | 50 explicit CastMetricsHelper( |
51 scoped_refptr<base::MessageLoopProxy> message_loop_proxy); | 51 scoped_refptr<base::MessageLoopProxy> message_loop_proxy); |
52 virtual ~CastMetricsHelper(); | 52 virtual ~CastMetricsHelper(); |
53 | 53 |
54 // This function stores the name and startup time of the active application. | 54 // This function stores the name and startup time of the active application. |
55 virtual void TagAppStart(const std::string& app_name); | 55 virtual void TagAppStart(const std::string& app_name); |
56 // This function update the info of current active application. | |
gunsch
2014/12/10 16:54:18
Remove "This function"
"update" --> "Updates"
"o
gfhuang
2014/12/10 22:02:41
Done.
| |
57 virtual void UpdateCurrentAppInfo(const std::string& app_id, | |
58 const std::string& session_id, | |
59 const std::string& sdk_version); | |
56 | 60 |
57 // Logs UMA record for media play/pause user actions. | 61 // Logs UMA record for media play/pause user actions. |
58 virtual void LogMediaPlay(); | 62 virtual void LogMediaPlay(); |
59 virtual void LogMediaPause(); | 63 virtual void LogMediaPause(); |
60 | 64 |
61 // Logs a simple UMA user action. | 65 // Logs a simple UMA user action. |
62 // This is used as an in-place replacement of content::RecordComputedAction(). | 66 // This is used as an in-place replacement of content::RecordComputedAction(). |
63 virtual void RecordSimpleAction(const std::string& action); | 67 virtual void RecordSimpleAction(const std::string& action); |
64 | 68 |
65 // Logs UMA record of the elapsed time from the app launch | 69 // Logs UMA record of the elapsed time from the app launch |
66 // to the time first video frame is displayed. | 70 // to the time first video frame is displayed. |
67 virtual void LogTimeToDisplayVideo(); | 71 virtual void LogTimeToDisplayVideo(); |
68 | 72 |
69 // Logs UMA record of the time needed to re-buffer A/V. | 73 // Logs UMA record of the time needed to re-buffer A/V. |
70 virtual void LogTimeToBufferAv(BufferingType buffering_type, | 74 virtual void LogTimeToBufferAv(BufferingType buffering_type, |
71 base::TimeDelta time); | 75 base::TimeDelta time); |
72 | 76 |
73 virtual void ResetVideoFrameSampling(); | 77 virtual void ResetVideoFrameSampling(); |
74 | 78 |
75 // Logs UMA statistics for video decoder and rendering data. | 79 // Logs UMA statistics for video decoder and rendering data. |
76 // Negative values are considered invalid and will not be logged. | 80 // Negative values are considered invalid and will not be logged. |
77 virtual void LogFramesPer5Seconds(int displayed_frames, int dropped_frames, | 81 virtual void LogFramesPer5Seconds(int displayed_frames, int dropped_frames, |
78 int delayed_frames, int error_frames); | 82 int delayed_frames, int error_frames); |
79 | 83 |
80 // Returns metrics name with app name between prefix and suffix. | 84 // Returns metrics name with app name between prefix and suffix. |
85 // This is used by histograms. | |
81 virtual std::string GetMetricsNameWithAppName( | 86 virtual std::string GetMetricsNameWithAppName( |
82 const std::string& prefix, | 87 const std::string& prefix, |
83 const std::string& suffix) const; | 88 const std::string& suffix) const; |
89 // Returns metrics name with app_id/session_id/sdk_version. | |
90 // This is used by actions, so far MediaPlay/MediaPause only. | |
gunsch
2014/12/10 16:54:19
This comment is bound to become obsolete. Can you
gfhuang
2014/12/10 22:02:41
Done.
| |
91 virtual std::string GetMetricsNameWithAppInfo( | |
gunsch
2014/12/10 22:43:58
does anyone call this externally? seems to me like
| |
92 const std::string& action_name) const; | |
84 | 93 |
85 // Provides a MetricsSink instance to delegate UMA event logging. | 94 // Provides a MetricsSink instance to delegate UMA event logging. |
86 // Once the delegate interface is set, CastMetricsHelper will not log UMA | 95 // Once the delegate interface is set, CastMetricsHelper will not log UMA |
87 // events internally unless SetMetricsSink(NULL) is called. | 96 // events internally unless SetMetricsSink(NULL) is called. |
88 // CastMetricsHelper can only hold one MetricsSink instance. | 97 // CastMetricsHelper can only hold one MetricsSink instance. |
89 // Caller retains ownership of MetricsSink. | 98 // Caller retains ownership of MetricsSink. |
90 virtual void SetMetricsSink(MetricsSink* delegate); | 99 virtual void SetMetricsSink(MetricsSink* delegate); |
91 | 100 |
92 // Sets a default callback to record user action when MetricsSink is not set. | 101 // Sets a default callback to record user action when MetricsSink is not set. |
93 // This function could be called multiple times (in unittests), and | 102 // This function could be called multiple times (in unittests), and |
(...skipping 17 matching lines...) Expand all Loading... | |
111 void LogMediumTimeHistogramEvent(const std::string& name, | 120 void LogMediumTimeHistogramEvent(const std::string& name, |
112 const base::TimeDelta& value); | 121 const base::TimeDelta& value); |
113 | 122 |
114 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 123 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
115 | 124 |
116 // Start time of the most recent app. | 125 // Start time of the most recent app. |
117 base::TimeTicks app_start_time_; | 126 base::TimeTicks app_start_time_; |
118 | 127 |
119 // Currently running app name. Used to construct histogram name. | 128 // Currently running app name. Used to construct histogram name. |
120 std::string app_name_; | 129 std::string app_name_; |
130 std::string app_id_; | |
131 std::string session_id_; | |
132 std::string sdk_version_; | |
121 | 133 |
122 // Whether a new app start time has been stored but not recorded. | 134 // 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, | 135 // After the startup time has been used to generate an UMA event, |
124 // this is set to false. | 136 // this is set to false. |
125 bool new_startup_time_; | 137 bool new_startup_time_; |
126 | 138 |
127 base::TimeTicks previous_video_stat_sample_time_; | 139 base::TimeTicks previous_video_stat_sample_time_; |
128 | 140 |
129 MetricsSink* metrics_sink_; | 141 MetricsSink* metrics_sink_; |
130 // Default RecordAction callback when metrics_sink_ is not set. | 142 // Default RecordAction callback when metrics_sink_ is not set. |
131 RecordActionCallback default_record_action_callback_; | 143 RecordActionCallback default_record_action_callback_; |
132 | 144 |
133 DISALLOW_COPY_AND_ASSIGN(CastMetricsHelper); | 145 DISALLOW_COPY_AND_ASSIGN(CastMetricsHelper); |
134 }; | 146 }; |
135 | 147 |
136 } // namespace metrics | 148 } // namespace metrics |
137 } // namespace chromecast | 149 } // namespace chromecast |
138 | 150 |
139 #endif // CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_ | 151 #endif // CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_ |
OLD | NEW |