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

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
« no previous file with comments | « no previous file | chromecast/base/metrics/cast_metrics_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 virtual void OnAction(const std::string& action) = 0; 38 virtual void OnAction(const std::string& action) = 0;
39 virtual void OnEnumerationEvent(const std::string& name, 39 virtual void OnEnumerationEvent(const std::string& name,
40 int value, int num_buckets) = 0; 40 int value, int num_buckets) = 0;
41 virtual void OnTimeEvent(const std::string& name, 41 virtual void OnTimeEvent(const std::string& name,
42 const base::TimeDelta& value, 42 const base::TimeDelta& value,
43 const base::TimeDelta& min, 43 const base::TimeDelta& min,
44 const base::TimeDelta& max, 44 const base::TimeDelta& max,
45 int num_buckets) = 0; 45 int num_buckets) = 0;
46 }; 46 };
47 47
48 // Decodes action_name/app_id/session_id/sdk_version from metrics name.
49 // Return false if the metrics name is not generated from
50 // EncodeAppInfoIntoMetricsName() with correct format.
51 static bool DecodeAppInfoFromMetricsName(
52 const std::string& metrics_name,
53 std::string* action_name,
54 std::string* app_id,
55 std::string* session_id,
56 std::string* sdk_version);
57
48 static CastMetricsHelper* GetInstance(); 58 static CastMetricsHelper* GetInstance();
49 59
50 explicit CastMetricsHelper( 60 explicit CastMetricsHelper(
51 scoped_refptr<base::MessageLoopProxy> message_loop_proxy); 61 scoped_refptr<base::MessageLoopProxy> message_loop_proxy);
52 virtual ~CastMetricsHelper(); 62 virtual ~CastMetricsHelper();
53 63
54 // This function stores the name and startup time of the active application. 64 // This function stores the name and startup time of the active application.
55 virtual void TagAppStart(const std::string& app_name); 65 virtual void TagAppStart(const std::string& app_name);
66 // This function updates the info for current active application.
67 virtual void UpdateCurrentAppInfo(const std::string& app_id,
68 const std::string& session_id,
69 const std::string& sdk_version);
56 70
57 // Logs UMA record for media play/pause user actions. 71 // Logs UMA record for media play/pause user actions.
58 virtual void LogMediaPlay(); 72 virtual void LogMediaPlay();
59 virtual void LogMediaPause(); 73 virtual void LogMediaPause();
60 74
61 // Logs a simple UMA user action. 75 // Logs a simple UMA user action.
62 // This is used as an in-place replacement of content::RecordComputedAction(). 76 // This is used as an in-place replacement of content::RecordComputedAction().
63 virtual void RecordSimpleAction(const std::string& action); 77 virtual void RecordSimpleAction(const std::string& action);
64 78
65 // Logs UMA record of the elapsed time from the app launch 79 // Logs UMA record of the elapsed time from the app launch
(...skipping 28 matching lines...) Expand all
94 // CastMetricsHelper only honors the last one. 108 // CastMetricsHelper only honors the last one.
95 virtual void SetRecordActionCallback(const RecordActionCallback& callback); 109 virtual void SetRecordActionCallback(const RecordActionCallback& callback);
96 110
97 protected: 111 protected:
98 // Creates a CastMetricsHelper instance with no MessageLoopProxy. This should 112 // Creates a CastMetricsHelper instance with no MessageLoopProxy. This should
99 // only be used by tests, since invoking any non-overridden methods on this 113 // only be used by tests, since invoking any non-overridden methods on this
100 // instance will cause a failure. 114 // instance will cause a failure.
101 CastMetricsHelper(); 115 CastMetricsHelper();
102 116
103 private: 117 private:
118 static std::string EncodeAppInfoIntoMetricsName(
119 const std::string& action_name,
120 const std::string& app_id,
121 const std::string& session_id,
122 const std::string& sdk_version);
123
104 void LogEnumerationHistogramEvent(const std::string& name, 124 void LogEnumerationHistogramEvent(const std::string& name,
105 int value, int num_buckets); 125 int value, int num_buckets);
106 void LogTimeHistogramEvent(const std::string& name, 126 void LogTimeHistogramEvent(const std::string& name,
107 const base::TimeDelta& value, 127 const base::TimeDelta& value,
108 const base::TimeDelta& min, 128 const base::TimeDelta& min,
109 const base::TimeDelta& max, 129 const base::TimeDelta& max,
110 int num_buckets); 130 int num_buckets);
111 void LogMediumTimeHistogramEvent(const std::string& name, 131 void LogMediumTimeHistogramEvent(const std::string& name,
112 const base::TimeDelta& value); 132 const base::TimeDelta& value);
113 133
114 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 134 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
115 135
116 // Start time of the most recent app. 136 // Start time of the most recent app.
117 base::TimeTicks app_start_time_; 137 base::TimeTicks app_start_time_;
118 138
119 // Currently running app name. Used to construct histogram name. 139 // Currently running app name. Used to construct histogram name.
120 std::string app_name_; 140 std::string app_name_;
141 std::string app_id_;
142 std::string session_id_;
143 std::string sdk_version_;
121 144
122 // Whether a new app start time has been stored but not recorded. 145 // 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, 146 // After the startup time has been used to generate an UMA event,
124 // this is set to false. 147 // this is set to false.
125 bool new_startup_time_; 148 bool new_startup_time_;
126 149
127 base::TimeTicks previous_video_stat_sample_time_; 150 base::TimeTicks previous_video_stat_sample_time_;
128 151
129 MetricsSink* metrics_sink_; 152 MetricsSink* metrics_sink_;
130 // Default RecordAction callback when metrics_sink_ is not set. 153 // Default RecordAction callback when metrics_sink_ is not set.
131 RecordActionCallback record_action_callback_; 154 RecordActionCallback record_action_callback_;
132 155
133 DISALLOW_COPY_AND_ASSIGN(CastMetricsHelper); 156 DISALLOW_COPY_AND_ASSIGN(CastMetricsHelper);
134 }; 157 };
135 158
136 } // namespace metrics 159 } // namespace metrics
137 } // namespace chromecast 160 } // namespace chromecast
138 161
139 #endif // CHROMECAST_BASE_METRICS_CAST_METRICS_HELPER_H_ 162 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698