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

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

Issue 608093002: Chromecast: adds callback for CastService to control metrics state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cast-network-delegate
Patch Set: rebase Created 6 years, 2 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
« no previous file with comments | « chromecast/metrics/cast_metrics_service_client.h ('k') | chromecast/service/cast_service.h » ('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 #include "chromecast/metrics/cast_metrics_service_client.h" 5 #include "chromecast/metrics/cast_metrics_service_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "chromecast/common/chromecast_config.h" 9 #include "chromecast/common/chromecast_config.h"
10 #include "chromecast/common/chromecast_switches.h" 10 #include "chromecast/common/chromecast_switches.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 DCHECK(!uma_server_url.empty()); 98 DCHECK(!uma_server_url.empty());
99 return scoped_ptr< ::metrics::MetricsLogUploader>( 99 return scoped_ptr< ::metrics::MetricsLogUploader>(
100 new ::metrics::NetMetricsLogUploader( 100 new ::metrics::NetMetricsLogUploader(
101 request_context_, 101 request_context_,
102 uma_server_url, 102 uma_server_url,
103 mime_type, 103 mime_type,
104 on_upload_complete)); 104 on_upload_complete));
105 } 105 }
106 106
107 void CastMetricsServiceClient::EnableMetricsService(bool enabled) { 107 void CastMetricsServiceClient::EnableMetricsService(bool enabled) {
108 if (!metrics_service_loop_->BelongsToCurrentThread()) {
109 metrics_service_loop_->PostTask(
110 FROM_HERE,
111 base::Bind(&CastMetricsServiceClient::EnableMetricsService,
112 base::Unretained(this),
113 enabled));
114 return;
115 }
116
108 if (enabled) { 117 if (enabled) {
109 metrics_service_->Start(); 118 metrics_service_->Start();
110 } else { 119 } else {
111 metrics_service_->Stop(); 120 metrics_service_->Stop();
112 } 121 }
113 } 122 }
114 123
115 CastMetricsServiceClient::CastMetricsServiceClient( 124 CastMetricsServiceClient::CastMetricsServiceClient(
116 base::TaskRunner* io_task_runner, 125 base::TaskRunner* io_task_runner,
117 PrefService* pref_service, 126 PrefService* pref_service,
118 net::URLRequestContextGetter* request_context) 127 net::URLRequestContextGetter* request_context)
119 : metrics_state_manager_(::metrics::MetricsStateManager::Create( 128 : metrics_state_manager_(::metrics::MetricsStateManager::Create(
120 pref_service, 129 pref_service,
121 base::Bind(&CastMetricsServiceClient::IsReportingEnabled, 130 base::Bind(&CastMetricsServiceClient::IsReportingEnabled,
122 base::Unretained(this)), 131 base::Unretained(this)),
123 base::Bind(&StoreClientInfo), 132 base::Bind(&StoreClientInfo),
124 base::Bind(&LoadClientInfo))), 133 base::Bind(&LoadClientInfo))),
125 metrics_service_(new ::metrics::MetricsService( 134 metrics_service_(new ::metrics::MetricsService(
126 metrics_state_manager_.get(), 135 metrics_state_manager_.get(),
127 this, 136 this,
128 pref_service)), 137 pref_service)),
138 metrics_service_loop_(base::MessageLoopProxy::current()),
129 request_context_(request_context) { 139 request_context_(request_context) {
130 // Always create a client id as it may also be used by crash reporting, 140 // Always create a client id as it may also be used by crash reporting,
131 // (indirectly) included in feedback, and can be queried during setup. 141 // (indirectly) included in feedback, and can be queried during setup.
132 // For UMA and crash reporting, associated opt-in settings will control 142 // For UMA and crash reporting, associated opt-in settings will control
133 // sending reports as directed by the user. 143 // sending reports as directed by the user.
134 // For Setup (which also communicates the user's opt-in preferences), 144 // For Setup (which also communicates the user's opt-in preferences),
135 // report the client-id and expect that setup will handle the current opt-in 145 // report the client-id and expect that setup will handle the current opt-in
136 // value. 146 // value.
137 metrics_state_manager_->ForceClientIdCreation(); 147 metrics_state_manager_->ForceClientIdCreation();
138 148
(...skipping 16 matching lines...) Expand all
155 165
156 CastMetricsServiceClient::~CastMetricsServiceClient() { 166 CastMetricsServiceClient::~CastMetricsServiceClient() {
157 } 167 }
158 168
159 bool CastMetricsServiceClient::IsReportingEnabled() { 169 bool CastMetricsServiceClient::IsReportingEnabled() {
160 return PlatformIsReportingEnabled(); 170 return PlatformIsReportingEnabled();
161 } 171 }
162 172
163 } // namespace metrics 173 } // namespace metrics
164 } // namespace chromecast 174 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/metrics/cast_metrics_service_client.h ('k') | chromecast/service/cast_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698