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

Side by Side Diff: chromecast/browser/metrics/cast_metrics_service_client.cc

Issue 1859213002: Move the thread hop for UMA user actions from content:: to base::. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Chromecast (I hope!) Created 4 years, 8 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/browser/metrics/cast_metrics_service_client.h" 5 #include "chromecast/browser/metrics/cast_metrics_service_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 16 matching lines...) Expand all
27 #include "components/metrics/metrics_service.h" 27 #include "components/metrics/metrics_service.h"
28 #include "components/metrics/metrics_state_manager.h" 28 #include "components/metrics/metrics_state_manager.h"
29 #include "components/metrics/net/net_metrics_log_uploader.h" 29 #include "components/metrics/net/net_metrics_log_uploader.h"
30 #include "components/metrics/net/network_metrics_provider.h" 30 #include "components/metrics/net/network_metrics_provider.h"
31 #include "components/metrics/profiler/profiler_metrics_provider.h" 31 #include "components/metrics/profiler/profiler_metrics_provider.h"
32 #include "components/metrics/ui/screen_info_metrics_provider.h" 32 #include "components/metrics/ui/screen_info_metrics_provider.h"
33 #include "components/metrics/url_constants.h" 33 #include "components/metrics/url_constants.h"
34 #include "components/prefs/pref_registry_simple.h" 34 #include "components/prefs/pref_registry_simple.h"
35 #include "components/prefs/pref_service.h" 35 #include "components/prefs/pref_service.h"
36 #include "content/public/common/content_switches.h" 36 #include "content/public/common/content_switches.h"
37 #include "content/public/browser/browser_thread.h"
37 38
38 #if defined(OS_LINUX) 39 #if defined(OS_LINUX)
39 #include "chromecast/browser/metrics/external_metrics.h" 40 #include "chromecast/browser/metrics/external_metrics.h"
40 #endif // defined(OS_LINUX) 41 #endif // defined(OS_LINUX)
41 42
42 #if defined(OS_ANDROID) 43 #if defined(OS_ANDROID)
43 #include "chromecast/base/android/dumpstate_writer.h" 44 #include "chromecast/base/android/dumpstate_writer.h"
44 #endif 45 #endif
45 46
46 namespace chromecast { 47 namespace chromecast {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 return std::unique_ptr<::metrics::MetricsLogUploader>( 254 return std::unique_ptr<::metrics::MetricsLogUploader>(
254 new ::metrics::NetMetricsLogUploader(request_context_, uma_server_url, 255 new ::metrics::NetMetricsLogUploader(request_context_, uma_server_url,
255 ::metrics::kDefaultMetricsMimeType, 256 ::metrics::kDefaultMetricsMimeType,
256 on_upload_complete)); 257 on_upload_complete));
257 } 258 }
258 259
259 base::TimeDelta CastMetricsServiceClient::GetStandardUploadInterval() { 260 base::TimeDelta CastMetricsServiceClient::GetStandardUploadInterval() {
260 return base::TimeDelta::FromMinutes(kStandardUploadIntervalMinutes); 261 return base::TimeDelta::FromMinutes(kStandardUploadIntervalMinutes);
261 } 262 }
262 263
264 scoped_refptr<base::SingleThreadTaskRunner>
265 CastMetricsServiceClient::GetMainThreadTaskRunner() {
266 return content::BrowserThread::GetMessageLoopProxyForThread(
267 content::BrowserThread::UI);
268 }
269
270
Ilya Sherman 2016/04/09 07:06:11 nit: Spurious newline.
beaudoin 2016/04/12 18:47:22 Done.
263 void CastMetricsServiceClient::EnableMetricsService(bool enabled) { 271 void CastMetricsServiceClient::EnableMetricsService(bool enabled) {
264 if (!task_runner_->BelongsToCurrentThread()) { 272 if (!task_runner_->BelongsToCurrentThread()) {
265 task_runner_->PostTask( 273 task_runner_->PostTask(
266 FROM_HERE, base::Bind(&CastMetricsServiceClient::EnableMetricsService, 274 FROM_HERE, base::Bind(&CastMetricsServiceClient::EnableMetricsService,
267 base::Unretained(this), enabled)); 275 base::Unretained(this), enabled));
268 return; 276 return;
269 } 277 }
270 278
271 if (enabled) { 279 if (enabled) {
272 metrics_service_->Start(); 280 metrics_service_->Start();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 #endif // defined(OS_LINUX) 417 #endif // defined(OS_LINUX)
410 metrics_service_->Stop(); 418 metrics_service_->Stop();
411 } 419 }
412 420
413 bool CastMetricsServiceClient::IsReportingEnabled() { 421 bool CastMetricsServiceClient::IsReportingEnabled() {
414 return pref_service_->GetBoolean(prefs::kOptInStats); 422 return pref_service_->GetBoolean(prefs::kOptInStats);
415 } 423 }
416 424
417 } // namespace metrics 425 } // namespace metrics
418 } // namespace chromecast 426 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698