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

Side by Side Diff: chrome/service/cloud_print/cloud_print_proxy_backend.cc

Issue 4233004: Make CUPS cloud print proxy to support multiple print servers.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/service/cloud_print/print_system.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 319 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
320 VLOG(1) << "CP_PROXY: Starting proxy, id: " << proxy_id; 320 VLOG(1) << "CP_PROXY: Starting proxy, id: " << proxy_id;
321 321
322 print_system_ = 322 print_system_ =
323 cloud_print::PrintSystem::CreateInstance(print_system_settings_.get()); 323 cloud_print::PrintSystem::CreateInstance(print_system_settings_.get());
324 if (!print_system_.get()) { 324 if (!print_system_.get()) {
325 NOTREACHED(); 325 NOTREACHED();
326 return; // No print system available, fail initalization. 326 return; // No print system available, fail initalization.
327 } 327 }
328 328
329 print_system_->Init();
330
329 // TODO(sanjeevr): Validate the tokens. 331 // TODO(sanjeevr): Validate the tokens.
330 auth_token_ = cloud_print_token; 332 auth_token_ = cloud_print_token;
331 333
332 const notifier::NotifierOptions kNotifierOptions; 334 const notifier::NotifierOptions kNotifierOptions;
333 const bool kInvalidateXmppAuthToken = false; 335 const bool kInvalidateXmppAuthToken = false;
334 const bool kAllowInsecureXmppConnection = false; 336 const bool kAllowInsecureXmppConnection = false;
335 talk_mediator_.reset(new notifier::TalkMediatorImpl( 337 talk_mediator_.reset(new notifier::TalkMediatorImpl(
336 new notifier::PushNotificationsThread(kNotifierOptions, 338 new notifier::PushNotificationsThread(kNotifierOptions,
337 kCloudPrintPushNotificationsSource), 339 kCloudPrintPushNotificationsSource),
338 kInvalidateXmppAuthToken, 340 kInvalidateXmppAuthToken,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 kMaxRetries, 379 kMaxRetries,
378 kInitialTimeout, 380 kInitialTimeout,
379 kMultiplier, 381 kMultiplier,
380 kConstantFactor, 382 kConstantFactor,
381 kMaximumTimeout); 383 kMaximumTimeout);
382 } 384 }
383 385
384 void CloudPrintProxyBackend::Core::StartRegistration() { 386 void CloudPrintProxyBackend::Core::StartRegistration() {
385 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 387 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
386 printer_list_.clear(); 388 printer_list_.clear();
387 print_system_->GetPrintBackend()->EnumeratePrinters(&printer_list_); 389 print_system_->EnumeratePrinters(&printer_list_);
388 // Now we need to ask the server about printers that were registered on the 390 // Now we need to ask the server about printers that were registered on the
389 // server so that we can trim this list. 391 // server so that we can trim this list.
390 GetRegisteredPrinters(); 392 GetRegisteredPrinters();
391 } 393 }
392 394
393 void CloudPrintProxyBackend::Core::EndRegistration() { 395 void CloudPrintProxyBackend::Core::EndRegistration() {
394 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 396 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
395 request_ = NULL; 397 request_ = NULL;
396 if (new_printers_available_) { 398 if (new_printers_available_) {
397 new_printers_available_ = false; 399 new_printers_available_ = false;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // For the next printer to be uploaded, create a multi-part post request to 448 // For the next printer to be uploaded, create a multi-part post request to
447 // upload the printer capabilities and the printer defaults. 449 // upload the printer capabilities and the printer defaults.
448 if (next_upload_index_ < printer_list_.size()) { 450 if (next_upload_index_ < printer_list_.size()) {
449 const printing::PrinterBasicInfo& info = 451 const printing::PrinterBasicInfo& info =
450 printer_list_.at(next_upload_index_); 452 printer_list_.at(next_upload_index_);
451 bool have_printer_info = true; 453 bool have_printer_info = true;
452 // If we are retrying a previous upload, we don't need to fetch the caps 454 // If we are retrying a previous upload, we don't need to fetch the caps
453 // and defaults again. 455 // and defaults again.
454 if (info.printer_name != last_uploaded_printer_name_) { 456 if (info.printer_name != last_uploaded_printer_name_) {
455 have_printer_info = 457 have_printer_info =
456 print_system_->GetPrintBackend()->GetPrinterCapsAndDefaults( 458 print_system_->GetPrinterCapsAndDefaults(
457 info.printer_name.c_str(), &last_uploaded_printer_info_); 459 info.printer_name.c_str(), &last_uploaded_printer_info_);
458 } 460 }
459 if (have_printer_info) { 461 if (have_printer_info) {
460 last_uploaded_printer_name_ = info.printer_name; 462 last_uploaded_printer_name_ = info.printer_name;
461 std::string mime_boundary; 463 std::string mime_boundary;
462 CloudPrintHelpers::CreateMimeBoundaryForUpload(&mime_boundary); 464 CloudPrintHelpers::CreateMimeBoundaryForUpload(&mime_boundary);
463 std::string post_data; 465 std::string post_data;
464 CloudPrintHelpers::AddMultipartValueForUpload(kProxyIdValue, proxy_id_, 466 CloudPrintHelpers::AddMultipartValueForUpload(kProxyIdValue, proxy_id_,
465 mime_boundary, 467 mime_boundary,
466 std::string(), &post_data); 468 std::string(), &post_data);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 VLOG(1) << "CP_PROXY: Printer job handle shutdown, id " << printer_id; 762 VLOG(1) << "CP_PROXY: Printer job handle shutdown, id " << printer_id;
761 job_handler_map_.erase(printer_id); 763 job_handler_map_.erase(printer_id);
762 } 764 }
763 765
764 void CloudPrintProxyBackend::Core::OnAuthError() { 766 void CloudPrintProxyBackend::Core::OnAuthError() {
765 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 767 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
766 VLOG(1) << "CP_PROXY: Auth Error"; 768 VLOG(1) << "CP_PROXY: Auth Error";
767 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 769 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
768 &Core::NotifyAuthenticationFailed)); 770 &Core::NotifyAuthenticationFailed));
769 } 771 }
OLDNEW
« no previous file with comments | « no previous file | chrome/service/cloud_print/print_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698