OLD | NEW |
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 "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/md5.h" | 8 #include "base/md5.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 kPrinterCapsValue, last_uploaded_printer_info_.printer_capabilities, | 434 kPrinterCapsValue, last_uploaded_printer_info_.printer_capabilities, |
435 mime_boundary, last_uploaded_printer_info_.caps_mime_type, | 435 mime_boundary, last_uploaded_printer_info_.caps_mime_type, |
436 &post_data); | 436 &post_data); |
437 CloudPrintHelpers::AddMultipartValueForUpload( | 437 CloudPrintHelpers::AddMultipartValueForUpload( |
438 kPrinterDefaultsValue, last_uploaded_printer_info_.printer_defaults, | 438 kPrinterDefaultsValue, last_uploaded_printer_info_.printer_defaults, |
439 mime_boundary, last_uploaded_printer_info_.defaults_mime_type, | 439 mime_boundary, last_uploaded_printer_info_.defaults_mime_type, |
440 &post_data); | 440 &post_data); |
441 // Send a hash of the printer capabilities to the server. We will use this | 441 // Send a hash of the printer capabilities to the server. We will use this |
442 // later to check if the capabilities have changed | 442 // later to check if the capabilities have changed |
443 CloudPrintHelpers::AddMultipartValueForUpload( | 443 CloudPrintHelpers::AddMultipartValueForUpload( |
444 WideToUTF8(kPrinterCapsHashValue).c_str(), | 444 kPrinterCapsHashValue, |
445 MD5String(last_uploaded_printer_info_.printer_capabilities), | 445 MD5String(last_uploaded_printer_info_.printer_capabilities), |
446 mime_boundary, std::string(), &post_data); | 446 mime_boundary, std::string(), &post_data); |
447 // Terminate the request body | 447 // Terminate the request body |
448 post_data.append("--" + mime_boundary + "--\r\n"); | 448 post_data.append("--" + mime_boundary + "--\r\n"); |
449 std::string mime_type("multipart/form-data; boundary="); | 449 std::string mime_type("multipart/form-data; boundary="); |
450 mime_type += mime_boundary; | 450 mime_type += mime_boundary; |
451 request_.reset( | 451 request_.reset( |
452 new URLFetcher( | 452 new URLFetcher( |
453 CloudPrintHelpers::GetUrlForPrinterRegistration( | 453 CloudPrintHelpers::GetUrlForPrinterRegistration( |
454 cloud_print_server_url_), | 454 cloud_print_server_url_), |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 std::string printer_id; | 550 std::string printer_id; |
551 printer_data->GetString(kIdValue, &printer_id); | 551 printer_data->GetString(kIdValue, &printer_id); |
552 DCHECK(!printer_id.empty()); | 552 DCHECK(!printer_id.empty()); |
553 LOG(INFO) << "CP_PROXY: Init job handler for printer id: " << printer_id; | 553 LOG(INFO) << "CP_PROXY: Init job handler for printer id: " << printer_id; |
554 JobHandlerMap::iterator index = job_handler_map_.find(printer_id); | 554 JobHandlerMap::iterator index = job_handler_map_.find(printer_id); |
555 // We might already have a job handler for this printer | 555 // We might already have a job handler for this printer |
556 if (index == job_handler_map_.end()) { | 556 if (index == job_handler_map_.end()) { |
557 cloud_print::PrinterBasicInfo printer_info; | 557 cloud_print::PrinterBasicInfo printer_info; |
558 printer_data->GetString(kNameValue, &printer_info.printer_name); | 558 printer_data->GetString(kNameValue, &printer_info.printer_name); |
559 DCHECK(!printer_info.printer_name.empty()); | 559 DCHECK(!printer_info.printer_name.empty()); |
560 printer_data->GetString(UTF8ToWide(kPrinterDescValue), | 560 printer_data->GetString(kPrinterDescValue, |
561 &printer_info.printer_description); | 561 &printer_info.printer_description); |
562 printer_data->GetInteger(UTF8ToWide(kPrinterStatusValue), | 562 printer_data->GetInteger(kPrinterStatusValue, |
563 &printer_info.printer_status); | 563 &printer_info.printer_status); |
564 std::string caps_hash; | 564 std::string caps_hash; |
565 printer_data->GetString(kPrinterCapsHashValue, &caps_hash); | 565 printer_data->GetString(kPrinterCapsHashValue, &caps_hash); |
566 scoped_refptr<PrinterJobHandler> job_handler; | 566 scoped_refptr<PrinterJobHandler> job_handler; |
567 job_handler = new PrinterJobHandler(printer_info, printer_id, caps_hash, | 567 job_handler = new PrinterJobHandler(printer_info, printer_id, caps_hash, |
568 auth_token_, cloud_print_server_url_, | 568 auth_token_, cloud_print_server_url_, |
569 print_system_.get(), this); | 569 print_system_.get(), this); |
570 job_handler_map_[printer_id] = job_handler; | 570 job_handler_map_[printer_id] = job_handler; |
571 job_handler->Initialize(); | 571 job_handler->Initialize(); |
572 } | 572 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 StartRegistration(); | 654 StartRegistration(); |
655 } | 655 } |
656 } | 656 } |
657 | 657 |
658 // PrinterJobHandler::Delegate implementation | 658 // PrinterJobHandler::Delegate implementation |
659 void CloudPrintProxyBackend::Core::OnPrinterJobHandlerShutdown( | 659 void CloudPrintProxyBackend::Core::OnPrinterJobHandlerShutdown( |
660 PrinterJobHandler* job_handler, const std::string& printer_id) { | 660 PrinterJobHandler* job_handler, const std::string& printer_id) { |
661 LOG(INFO) << "CP_PROXY: Printer job handle shutdown, id " << printer_id; | 661 LOG(INFO) << "CP_PROXY: Printer job handle shutdown, id " << printer_id; |
662 job_handler_map_.erase(printer_id); | 662 job_handler_map_.erase(printer_id); |
663 } | 663 } |
OLD | NEW |