| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 const notifier::NotifierOptions kNotifierOptions; | 374 const notifier::NotifierOptions kNotifierOptions; |
| 375 talk_mediator_.reset(new notifier::TalkMediatorImpl( | 375 talk_mediator_.reset(new notifier::TalkMediatorImpl( |
| 376 new notifier::MediatorThreadImpl(kNotifierOptions), | 376 new notifier::MediatorThreadImpl(kNotifierOptions), |
| 377 kNotifierOptions)); | 377 kNotifierOptions)); |
| 378 notifier::Subscription subscription; | 378 notifier::Subscription subscription; |
| 379 subscription.channel = kCloudPrintPushNotificationsSource; | 379 subscription.channel = kCloudPrintPushNotificationsSource; |
| 380 subscription.channel.append("/proxy/"); | 380 subscription.channel.append("/proxy/"); |
| 381 subscription.channel.append(proxy_id); | 381 subscription.channel.append(proxy_id); |
| 382 subscription.from = kCloudPrintPushNotificationsSource; | 382 subscription.from = kCloudPrintPushNotificationsSource; |
| 383 push_notifications_channel_ = subscription.channel; | 383 push_notifications_channel_ = subscription.channel; |
| 384 talk_mediator_->AddSubscription(subscription); | |
| 385 talk_mediator_->SetDelegate(this); | 384 talk_mediator_->SetDelegate(this); |
| 385 // SetAuthToken should be called before AddSubscription. |
| 386 talk_mediator_->SetAuthToken(email, cloud_print_xmpp_token, | 386 talk_mediator_->SetAuthToken(email, cloud_print_xmpp_token, |
| 387 kSyncGaiaServiceId); | 387 kSyncGaiaServiceId); |
| 388 talk_mediator_->AddSubscription(subscription); |
| 388 talk_mediator_->Login(); | 389 talk_mediator_->Login(); |
| 389 | 390 |
| 390 print_server_watcher_ = print_system_->CreatePrintServerWatcher(); | 391 print_server_watcher_ = print_system_->CreatePrintServerWatcher(); |
| 391 print_server_watcher_->StartWatching(this); | 392 print_server_watcher_->StartWatching(this); |
| 392 | 393 |
| 393 proxy_id_ = proxy_id; | 394 proxy_id_ = proxy_id; |
| 394 | 395 |
| 395 StartRegistration(); | 396 StartRegistration(); |
| 396 } else { | 397 } else { |
| 397 // We could not initialize the print system. We need to notify the server. | 398 // We could not initialize the print system. We need to notify the server. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 print_server_watcher_->StopWatching(); | 443 print_server_watcher_->StopWatching(); |
| 443 | 444 |
| 444 // Need to kill all running jobs. | 445 // Need to kill all running jobs. |
| 445 while (!job_handler_map_.empty()) { | 446 while (!job_handler_map_.empty()) { |
| 446 JobHandlerMap::iterator index = job_handler_map_.begin(); | 447 JobHandlerMap::iterator index = job_handler_map_.begin(); |
| 447 // Shutdown will call our OnPrinterJobHandlerShutdown method which will | 448 // Shutdown will call our OnPrinterJobHandlerShutdown method which will |
| 448 // remove this from the map. | 449 // remove this from the map. |
| 449 index->second->Shutdown(); | 450 index->second->Shutdown(); |
| 450 } | 451 } |
| 451 // Important to delete the TalkMediator on this thread. | 452 // Important to delete the TalkMediator on this thread. |
| 453 talk_mediator_->Logout(); |
| 452 talk_mediator_.reset(); | 454 talk_mediator_.reset(); |
| 453 notifications_enabled_ = false; | 455 notifications_enabled_ = false; |
| 454 notifications_enabled_since_ = base::TimeTicks(); | 456 notifications_enabled_since_ = base::TimeTicks(); |
| 455 request_ = NULL; | 457 request_ = NULL; |
| 456 } | 458 } |
| 457 | 459 |
| 458 void CloudPrintProxyBackend::Core::DoRegisterSelectedPrinters( | 460 void CloudPrintProxyBackend::Core::DoRegisterSelectedPrinters( |
| 459 const printing::PrinterList& printer_list) { | 461 const printing::PrinterList& printer_list) { |
| 460 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); | 462 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); |
| 461 if (!print_system_.get()) | 463 if (!print_system_.get()) |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 &Core::NotifyAuthenticationFailed)); | 936 &Core::NotifyAuthenticationFailed)); |
| 935 } | 937 } |
| 936 | 938 |
| 937 void CloudPrintProxyBackend::Core::OnPrinterNotFound( | 939 void CloudPrintProxyBackend::Core::OnPrinterNotFound( |
| 938 const std::string& printer_name, | 940 const std::string& printer_name, |
| 939 bool* delete_from_server) { | 941 bool* delete_from_server) { |
| 940 // If we have a complete list of local printers, then this needs to be deleted | 942 // If we have a complete list of local printers, then this needs to be deleted |
| 941 // from the server. | 943 // from the server. |
| 942 *delete_from_server = complete_list_available_; | 944 *delete_from_server = complete_list_available_; |
| 943 } | 945 } |
| OLD | NEW |