| 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 <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 17 #include "chrome/service/cloud_print/cloud_print_auth.h" | 18 #include "chrome/service/cloud_print/cloud_print_auth.h" |
| 18 #include "chrome/service/cloud_print/cloud_print_connector.h" | 19 #include "chrome/service/cloud_print/cloud_print_connector.h" |
| 19 #include "chrome/service/cloud_print/cloud_print_consts.h" | 20 #include "chrome/service/cloud_print/cloud_print_consts.h" |
| 20 #include "chrome/service/cloud_print/cloud_print_helpers.h" | 21 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
| 21 #include "chrome/service/cloud_print/cloud_print_token_store.h" | 22 #include "chrome/service/cloud_print/cloud_print_token_store.h" |
| 22 #include "chrome/service/cloud_print/connector_settings.h" | 23 #include "chrome/service/cloud_print/connector_settings.h" |
| 23 #include "chrome/service/gaia/service_gaia_authenticator.h" | 24 #include "chrome/service/gaia/service_gaia_authenticator.h" |
| 24 #include "chrome/service/net/service_url_request_context.h" | 25 #include "chrome/service/net/service_url_request_context.h" |
| 25 #include "chrome/service/service_process.h" | 26 #include "chrome/service/service_process.h" |
| 26 #include "google_apis/gaia/gaia_oauth_client.h" | 27 #include "google_apis/gaia/gaia_oauth_client.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 368 |
| 368 pending_xmpp_pings_ = 0; | 369 pending_xmpp_pings_ = 0; |
| 369 notifier::NotifierOptions notifier_options; | 370 notifier::NotifierOptions notifier_options; |
| 370 notifier_options.request_context_getter = | 371 notifier_options.request_context_getter = |
| 371 g_service_process->GetServiceURLRequestContextGetter(); | 372 g_service_process->GetServiceURLRequestContextGetter(); |
| 372 notifier_options.auth_mechanism = "X-OAUTH2"; | 373 notifier_options.auth_mechanism = "X-OAUTH2"; |
| 373 notifier_options.try_ssltcp_first = true; | 374 notifier_options.try_ssltcp_first = true; |
| 374 push_client_ = notifier::PushClient::CreateDefault(notifier_options); | 375 push_client_ = notifier::PushClient::CreateDefault(notifier_options); |
| 375 push_client_->AddObserver(this); | 376 push_client_->AddObserver(this); |
| 376 notifier::Subscription subscription; | 377 notifier::Subscription subscription; |
| 377 subscription.channel = kCloudPrintPushNotificationsSource; | 378 subscription.channel = cloud_print::kCloudPrintPushNotificationsSource; |
| 378 subscription.from = kCloudPrintPushNotificationsSource; | 379 subscription.from = cloud_print::kCloudPrintPushNotificationsSource; |
| 379 push_client_->UpdateSubscriptions( | 380 push_client_->UpdateSubscriptions( |
| 380 notifier::SubscriptionList(1, subscription)); | 381 notifier::SubscriptionList(1, subscription)); |
| 381 push_client_->UpdateCredentials(robot_email, access_token); | 382 push_client_->UpdateCredentials(robot_email, access_token); |
| 382 } | 383 } |
| 383 | 384 |
| 384 void CloudPrintProxyBackend::Core::DoShutdown() { | 385 void CloudPrintProxyBackend::Core::DoShutdown() { |
| 385 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); | 386 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); |
| 386 VLOG(1) << "CP_CONNECTOR: Shutdown connector, id: " << settings_.proxy_id(); | 387 VLOG(1) << "CP_CONNECTOR: Shutdown connector, id: " << settings_.proxy_id(); |
| 387 | 388 |
| 388 if (connector_->IsRunning()) | 389 if (connector_->IsRunning()) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 | 560 |
| 560 | 561 |
| 561 void CloudPrintProxyBackend::Core::OnIncomingNotification( | 562 void CloudPrintProxyBackend::Core::OnIncomingNotification( |
| 562 const notifier::Notification& notification) { | 563 const notifier::Notification& notification) { |
| 563 // Since we got some notification from the server, | 564 // Since we got some notification from the server, |
| 564 // reset pending ping counter to 0. | 565 // reset pending ping counter to 0. |
| 565 pending_xmpp_pings_ = 0; | 566 pending_xmpp_pings_ = 0; |
| 566 | 567 |
| 567 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); | 568 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); |
| 568 VLOG(1) << "CP_CONNECTOR: Incoming notification."; | 569 VLOG(1) << "CP_CONNECTOR: Incoming notification."; |
| 569 if (0 == base::strcasecmp(kCloudPrintPushNotificationsSource, | 570 if (0 == base::strcasecmp(cloud_print::kCloudPrintPushNotificationsSource, |
| 570 notification.channel.c_str())) | 571 notification.channel.c_str())) |
| 571 HandlePrinterNotification(notification.data); | 572 HandlePrinterNotification(notification.data); |
| 572 } | 573 } |
| 573 | 574 |
| 574 void CloudPrintProxyBackend::Core::OnPingResponse() { | 575 void CloudPrintProxyBackend::Core::OnPingResponse() { |
| 575 pending_xmpp_pings_ = 0; | 576 pending_xmpp_pings_ = 0; |
| 576 VLOG(1) << "CP_CONNECTOR: Ping response received."; | 577 VLOG(1) << "CP_CONNECTOR: Ping response received."; |
| 577 } | 578 } |
| 578 | 579 |
| OLD | NEW |