| 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/printer_job_handler.h" | 5 #include "chrome/service/cloud_print/printer_job_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 // access any members other than |job_handler_task_runner_|, | 785 // access any members other than |job_handler_task_runner_|, |
| 786 // |job_spooler_| and |print_system_|. | 786 // |job_spooler_| and |print_system_|. |
| 787 void PrinterJobHandler::DoPrint(const JobDetails& job_details, | 787 void PrinterJobHandler::DoPrint(const JobDetails& job_details, |
| 788 const std::string& printer_name) { | 788 const std::string& printer_name) { |
| 789 job_spooler_ = print_system_->CreateJobSpooler(); | 789 job_spooler_ = print_system_->CreateJobSpooler(); |
| 790 UMA_HISTOGRAM_LONG_TIMES("CloudPrint.PrepareTime", | 790 UMA_HISTOGRAM_LONG_TIMES("CloudPrint.PrepareTime", |
| 791 base::Time::Now() - job_start_time_); | 791 base::Time::Now() - job_start_time_); |
| 792 DCHECK(job_spooler_.get()); | 792 DCHECK(job_spooler_.get()); |
| 793 if (!job_spooler_.get()) | 793 if (!job_spooler_.get()) |
| 794 return; | 794 return; |
| 795 base::string16 document_name = printing::SimplifyDocumentTitle( | 795 |
| 796 base::UTF8ToUTF16(job_details.job_title_)); | 796 base::string16 document_name = |
| 797 if (document_name.empty()) { | 797 job_details.job_title_.empty() |
| 798 document_name = printing::SimplifyDocumentTitle( | 798 ? l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE) |
| 799 l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE)); | 799 : base::UTF8ToUTF16(job_details.job_title_); |
| 800 } | 800 |
| 801 document_name = printing::FormatDocumentTitleWithOwner( |
| 802 base::UTF8ToUTF16(job_details.job_owner_), document_name); |
| 803 |
| 801 UMA_HISTOGRAM_ENUMERATION("CloudPrint.JobHandlerEvent", | 804 UMA_HISTOGRAM_ENUMERATION("CloudPrint.JobHandlerEvent", |
| 802 JOB_HANDLER_START_SPOOLING, JOB_HANDLER_MAX); | 805 JOB_HANDLER_START_SPOOLING, JOB_HANDLER_MAX); |
| 803 spooling_start_time_ = base::Time::Now(); | 806 spooling_start_time_ = base::Time::Now(); |
| 804 if (!job_spooler_->Spool(job_details.print_ticket_, | 807 if (!job_spooler_->Spool(job_details.print_ticket_, |
| 805 job_details.print_ticket_mime_type_, | 808 job_details.print_ticket_mime_type_, |
| 806 job_details.print_data_file_path_, | 809 job_details.print_data_file_path_, |
| 807 job_details.print_data_mime_type_, | 810 job_details.print_data_mime_type_, |
| 808 printer_name, | 811 printer_name, |
| 809 base::UTF16ToUTF8(document_name), | 812 base::UTF16ToUTF8(document_name), |
| 810 job_details.tags_, | 813 job_details.tags_, |
| 811 this)) { | 814 this)) { |
| 812 OnJobSpoolFailed(); | 815 OnJobSpoolFailed(); |
| 813 } | 816 } |
| 814 } | 817 } |
| 815 | 818 |
| 816 } // namespace cloud_print | 819 } // namespace cloud_print |
| OLD | NEW |