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

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

Issue 1510973007: [Chromecast] Set dummy metrics session ID for browser tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + use GUID format for dummy session ID Created 4 years, 10 months 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/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // static 85 // static
86 CastMetricsHelper* CastMetricsHelper::GetInstance() { 86 CastMetricsHelper* CastMetricsHelper::GetInstance() {
87 DCHECK(g_instance); 87 DCHECK(g_instance);
88 return g_instance; 88 return g_instance;
89 } 89 }
90 90
91 CastMetricsHelper::CastMetricsHelper( 91 CastMetricsHelper::CastMetricsHelper(
92 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 92 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
93 : task_runner_(task_runner), 93 : task_runner_(task_runner),
94 session_id_("00000000000000000000000000000000"),
95 metrics_sink_(NULL), 94 metrics_sink_(NULL),
96 logged_first_audio_(false), 95 logged_first_audio_(false),
97 record_action_callback_(base::Bind(&base::RecordComputedAction)) { 96 record_action_callback_(base::Bind(&base::RecordComputedAction)) {
98 DCHECK(task_runner_.get()); 97 DCHECK(task_runner_.get());
99 DCHECK(!g_instance); 98 DCHECK(!g_instance);
100 g_instance = this; 99 g_instance = this;
101 } 100 }
102 101
103 CastMetricsHelper::CastMetricsHelper() 102 CastMetricsHelper::CastMetricsHelper()
104 : metrics_sink_(NULL), logged_first_audio_(false) { 103 : metrics_sink_(NULL), logged_first_audio_(false) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 MAKE_SURE_THREAD(SetMetricsSink, delegate); 219 MAKE_SURE_THREAD(SetMetricsSink, delegate);
221 metrics_sink_ = delegate; 220 metrics_sink_ = delegate;
222 } 221 }
223 222
224 void CastMetricsHelper::SetRecordActionCallback( 223 void CastMetricsHelper::SetRecordActionCallback(
225 const RecordActionCallback& callback) { 224 const RecordActionCallback& callback) {
226 DCHECK(task_runner_->BelongsToCurrentThread()); 225 DCHECK(task_runner_->BelongsToCurrentThread());
227 record_action_callback_ = callback; 226 record_action_callback_ = callback;
228 } 227 }
229 228
229 void CastMetricsHelper::SetDummySessionIdForTesting() {
230 DCHECK(task_runner_->BelongsToCurrentThread());
231 session_id_ = "00000000-0000-0000-0000-000000000000";
232 }
233
230 void CastMetricsHelper::RecordSimpleAction(const std::string& action) { 234 void CastMetricsHelper::RecordSimpleAction(const std::string& action) {
231 MAKE_SURE_THREAD(RecordSimpleAction, action); 235 MAKE_SURE_THREAD(RecordSimpleAction, action);
232 236
233 if (metrics_sink_) { 237 if (metrics_sink_) {
234 metrics_sink_->OnAction(action); 238 metrics_sink_->OnAction(action);
235 } else { 239 } else {
236 record_action_callback_.Run(action); 240 record_action_callback_.Run(action);
237 } 241 }
238 } 242 }
239 243
(...skipping 27 matching lines...) Expand all
267 const base::TimeDelta& value) { 271 const base::TimeDelta& value) {
268 // Follow UMA_HISTOGRAM_MEDIUM_TIMES definition. 272 // Follow UMA_HISTOGRAM_MEDIUM_TIMES definition.
269 LogTimeHistogramEvent(name, value, 273 LogTimeHistogramEvent(name, value,
270 base::TimeDelta::FromMilliseconds(10), 274 base::TimeDelta::FromMilliseconds(10),
271 base::TimeDelta::FromMinutes(3), 275 base::TimeDelta::FromMinutes(3),
272 50); 276 50);
273 } 277 }
274 278
275 } // namespace metrics 279 } // namespace metrics
276 } // namespace chromecast 280 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/base/metrics/cast_metrics_helper.h ('k') | chromecast/browser/test/chromecast_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698