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

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

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 #include "chromecast/base/metrics/cast_metrics_helper.h" 5 #include "chromecast/base/metrics/cast_metrics_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 CastMetricsHelper::~CastMetricsHelper() { 61 CastMetricsHelper::~CastMetricsHelper() {
62 DCHECK_EQ(g_instance, this); 62 DCHECK_EQ(g_instance, this);
63 g_instance = NULL; 63 g_instance = NULL;
64 } 64 }
65 65
66 void CastMetricsHelper::TagAppStart(const std::string& arg_app_name) { 66 void CastMetricsHelper::TagAppStart(const std::string& arg_app_name) {
67 MAKE_SURE_THREAD(TagAppStart, arg_app_name); 67 MAKE_SURE_THREAD(TagAppStart, arg_app_name);
68 app_name_ = arg_app_name; 68 app_name_ = arg_app_name;
69 app_start_time_ = base::TimeTicks::Now(); 69 app_start_time_ = base::TimeTicks::Now();
70 new_startup_time_ = true; 70 new_startup_time_ = true;
71 // Clear app info
72 app_id_ = "";
byungchul 2014/12/10 05:39:41 app_id_.clear();
gunsch 2014/12/10 16:54:18 Alternately, you could use UpdateCurrentAppInfo(""
gfhuang 2014/12/10 22:02:41 Done.
73 session_id_ = "";
byungchul 2014/12/10 05:39:41 ditto
74 sdk_version_ = "";
byungchul 2014/12/10 05:39:40 ditto
75 }
76
77 void CastMetricsHelper::UpdateCurrentAppInfo(const std::string& app_id,
78 const std::string& session_id,
79 const std::string& sdk_version) {
80 MAKE_SURE_THREAD(UpdateCurrentAppInfo, app_id, session_id, sdk_version);
81 app_id_ = app_id;
82 session_id_ = session_id;
83 sdk_version_ = sdk_version;
71 } 84 }
72 85
73 void CastMetricsHelper::LogMediaPlay() { 86 void CastMetricsHelper::LogMediaPlay() {
74 RecordSimpleAction(GetMetricsNameWithAppName("MediaPlay", "")); 87 RecordSimpleAction(GetMetricsNameWithAppInfo("MediaPlay"));
75 } 88 }
76 89
77 void CastMetricsHelper::LogMediaPause() { 90 void CastMetricsHelper::LogMediaPause() {
78 RecordSimpleAction(GetMetricsNameWithAppName("MediaPause", "")); 91 RecordSimpleAction(GetMetricsNameWithAppInfo("MediaPause"));
79 } 92 }
80 93
81 void CastMetricsHelper::LogTimeToDisplayVideo() { 94 void CastMetricsHelper::LogTimeToDisplayVideo() {
82 if (!new_startup_time_) { // For faster check. 95 if (!new_startup_time_) { // For faster check.
83 return; 96 return;
84 } 97 }
85 MAKE_SURE_THREAD(LogTimeToDisplayVideo); 98 MAKE_SURE_THREAD(LogTimeToDisplayVideo);
86 new_startup_time_ = false; 99 new_startup_time_ = false;
87 base::TimeDelta launch_time = base::TimeTicks::Now() - app_start_time_; 100 base::TimeDelta launch_time = base::TimeTicks::Now() - app_start_time_;
88 const std::string uma_name(GetMetricsNameWithAppName("Startup", 101 const std::string uma_name(GetMetricsNameWithAppName("Startup",
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 metrics_name.append(app_name_); 192 metrics_name.append(app_name_);
180 } 193 }
181 if (!suffix.empty()) { 194 if (!suffix.empty()) {
182 if (!metrics_name.empty()) 195 if (!metrics_name.empty())
183 metrics_name.push_back('.'); 196 metrics_name.push_back('.');
184 metrics_name.append(suffix); 197 metrics_name.append(suffix);
185 } 198 }
186 return metrics_name; 199 return metrics_name;
187 } 200 }
188 201
202 std::string CastMetricsHelper::GetMetricsNameWithAppInfo(
203 const std::string& action_name) const {
204 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
205 return action_name + "#" + app_id_ + "#" + session_id_ + "#" + sdk_version_;
byungchul 2014/12/10 05:39:40 Please define a constant for delimiter, '#' for so
gunsch 2014/12/10 16:54:18 Aside: I saw that you're parsing this in a differe
gfhuang 2014/12/10 22:02:41 Done.
206 }
207
189 void CastMetricsHelper::SetMetricsSink(MetricsSink* delegate) { 208 void CastMetricsHelper::SetMetricsSink(MetricsSink* delegate) {
190 MAKE_SURE_THREAD(SetMetricsSink, delegate); 209 MAKE_SURE_THREAD(SetMetricsSink, delegate);
191 metrics_sink_ = delegate; 210 metrics_sink_ = delegate;
192 } 211 }
193 212
194 void CastMetricsHelper::SetRecordActionCallback( 213 void CastMetricsHelper::SetRecordActionCallback(
195 const RecordActionCallback& callback) { 214 const RecordActionCallback& callback) {
196 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 215 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
197 default_record_action_callback_ = callback; 216 default_record_action_callback_ = callback;
198 } 217 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const base::TimeDelta& value) { 256 const base::TimeDelta& value) {
238 // Follow UMA_HISTOGRAM_MEDIUM_TIMES definition. 257 // Follow UMA_HISTOGRAM_MEDIUM_TIMES definition.
239 LogTimeHistogramEvent(name, value, 258 LogTimeHistogramEvent(name, value,
240 base::TimeDelta::FromMilliseconds(10), 259 base::TimeDelta::FromMilliseconds(10),
241 base::TimeDelta::FromMinutes(3), 260 base::TimeDelta::FromMinutes(3),
242 50); 261 50);
243 } 262 }
244 263
245 } // namespace metrics 264 } // namespace metrics
246 } // namespace chromecast 265 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698