OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/service/cloud_print/cloud_print_proxy_backend.h" | 5 #include "chrome/service/cloud_print/cloud_print_proxy_backend.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... | |
26 #include "chrome/service/cloud_print/cloud_print_token_store.h" | 26 #include "chrome/service/cloud_print/cloud_print_token_store.h" |
27 #include "chrome/service/cloud_print/connector_settings.h" | 27 #include "chrome/service/cloud_print/connector_settings.h" |
28 #include "chrome/service/net/service_url_request_context_getter.h" | 28 #include "chrome/service/net/service_url_request_context_getter.h" |
29 #include "chrome/service/service_process.h" | 29 #include "chrome/service/service_process.h" |
30 #include "components/cloud_devices/common/cloud_devices_switches.h" | 30 #include "components/cloud_devices/common/cloud_devices_switches.h" |
31 #include "google_apis/gaia/gaia_oauth_client.h" | 31 #include "google_apis/gaia/gaia_oauth_client.h" |
32 #include "google_apis/gaia/gaia_urls.h" | 32 #include "google_apis/gaia/gaia_urls.h" |
33 #include "jingle/notifier/base/notifier_options.h" | 33 #include "jingle/notifier/base/notifier_options.h" |
34 #include "jingle/notifier/listener/push_client.h" | 34 #include "jingle/notifier/listener/push_client.h" |
35 #include "jingle/notifier/listener/push_client_observer.h" | 35 #include "jingle/notifier/listener/push_client_observer.h" |
36 #include "net/traffic_annotation/network_traffic_annotation.h" | |
36 #include "url/gurl.h" | 37 #include "url/gurl.h" |
37 | 38 |
38 namespace cloud_print { | 39 namespace cloud_print { |
39 | 40 |
40 // The real guts of CloudPrintProxyBackend, to keep the public client API clean. | 41 // The real guts of CloudPrintProxyBackend, to keep the public client API clean. |
41 class CloudPrintProxyBackend::Core | 42 class CloudPrintProxyBackend::Core |
42 : public base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>, | 43 : public base::RefCountedThreadSafe<CloudPrintProxyBackend::Core>, |
43 public CloudPrintAuth::Client, | 44 public CloudPrintAuth::Client, |
44 public CloudPrintConnector::Client, | 45 public CloudPrintConnector::Client, |
45 public notifier::PushClientObserver { | 46 public notifier::PushClientObserver { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 | 257 |
257 bool CloudPrintProxyBackend::Core::CurrentlyOnFrontendThread() const { | 258 bool CloudPrintProxyBackend::Core::CurrentlyOnFrontendThread() const { |
258 return backend_->frontend_task_runner_->BelongsToCurrentThread(); | 259 return backend_->frontend_task_runner_->BelongsToCurrentThread(); |
259 } | 260 } |
260 | 261 |
261 bool CloudPrintProxyBackend::Core::CurrentlyOnCoreThread() const { | 262 bool CloudPrintProxyBackend::Core::CurrentlyOnCoreThread() const { |
262 return backend_->core_thread_.task_runner()->BelongsToCurrentThread(); | 263 return backend_->core_thread_.task_runner()->BelongsToCurrentThread(); |
263 } | 264 } |
264 | 265 |
265 void CloudPrintProxyBackend::Core::CreateAuthAndConnector() { | 266 void CloudPrintProxyBackend::Core::CreateAuthAndConnector() { |
267 net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation = | |
268 net::DefinePartialNetworkTrafficAnnotation("cloud_print_backend", | |
269 "cloud_print", R"( | |
270 semantics { | |
271 description: | |
272 "Creates and authenticates connection with Cloud Print." | |
273 trigger: | |
274 "Cloud Print service intialization." | |
msramek
2017/06/08 21:23:32
nit: Fits on one line.
Ramin Halavati
2017/06/09 04:55:46
Done.
| |
275 data: "OAuth2 token." | |
276 })"); | |
266 if (!auth_.get()) { | 277 if (!auth_.get()) { |
267 auth_ = new CloudPrintAuth(this, settings_.server_url(), oauth_client_info_, | 278 auth_ = |
268 settings_.proxy_id()); | 279 new CloudPrintAuth(this, settings_.server_url(), oauth_client_info_, |
280 settings_.proxy_id(), partial_traffic_annotation); | |
269 } | 281 } |
270 | 282 |
271 if (!connector_.get()) { | 283 if (!connector_.get()) { |
272 connector_ = new CloudPrintConnector(this, settings_); | 284 connector_ = |
285 new CloudPrintConnector(this, settings_, partial_traffic_annotation); | |
273 } | 286 } |
274 } | 287 } |
275 | 288 |
276 void CloudPrintProxyBackend::Core::DestroyAuthAndConnector() { | 289 void CloudPrintProxyBackend::Core::DestroyAuthAndConnector() { |
277 auth_ = NULL; | 290 auth_ = NULL; |
278 connector_ = NULL; | 291 connector_ = NULL; |
279 } | 292 } |
280 | 293 |
281 void CloudPrintProxyBackend::Core::DoInitializeWithToken( | 294 void CloudPrintProxyBackend::Core::DoInitializeWithToken( |
282 const std::string& cloud_print_token) { | 295 const std::string& cloud_print_token) { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 HandlePrinterNotification(notification.data); | 591 HandlePrinterNotification(notification.data); |
579 } | 592 } |
580 | 593 |
581 void CloudPrintProxyBackend::Core::OnPingResponse() { | 594 void CloudPrintProxyBackend::Core::OnPingResponse() { |
582 UMA_HISTOGRAM_COUNTS_100("CloudPrint.XmppPingTry", pending_xmpp_pings_); | 595 UMA_HISTOGRAM_COUNTS_100("CloudPrint.XmppPingTry", pending_xmpp_pings_); |
583 pending_xmpp_pings_ = 0; | 596 pending_xmpp_pings_ = 0; |
584 VLOG(1) << "CP_CONNECTOR: Ping response received."; | 597 VLOG(1) << "CP_CONNECTOR: Ping response received."; |
585 } | 598 } |
586 | 599 |
587 } // namespace cloud_print | 600 } // namespace cloud_print |
OLD | NEW |