| 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/md5.h" | 11 #include "base/md5.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/common/cloud_print/cloud_print_constants.h" | 16 #include "chrome/common/cloud_print/cloud_print_constants.h" |
| 17 #include "chrome/common/cloud_print/cloud_print_helpers.h" | 17 #include "chrome/common/cloud_print/cloud_print_helpers.h" |
| 18 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" | 18 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" |
| 19 #include "chrome/service/cloud_print/job_status_updater.h" | 19 #include "chrome/service/cloud_print/job_status_updater.h" |
| 20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 21 #include "net/base/mime_util.h" | 21 #include "net/base/mime_util.h" |
| 22 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
| 23 #include "net/http/http_status_code.h" | 23 #include "net/http/http_status_code.h" |
| 24 #include "printing/backend/print_backend.h" | 24 #include "printing/printing_utils.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 namespace cloud_print { | 28 namespace cloud_print { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 base::subtle::Atomic32 g_total_jobs_started = 0; | 32 base::subtle::Atomic32 g_total_jobs_started = 0; |
| 33 base::subtle::Atomic32 g_total_jobs_done = 0; | 33 base::subtle::Atomic32 g_total_jobs_done = 0; |
| 34 | 34 |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 // |job_spooler_| and |print_system_|. | 760 // |job_spooler_| and |print_system_|. |
| 761 void PrinterJobHandler::DoPrint(const JobDetails& job_details, | 761 void PrinterJobHandler::DoPrint(const JobDetails& job_details, |
| 762 const std::string& printer_name) { | 762 const std::string& printer_name) { |
| 763 job_spooler_ = print_system_->CreateJobSpooler(); | 763 job_spooler_ = print_system_->CreateJobSpooler(); |
| 764 UMA_HISTOGRAM_LONG_TIMES("CloudPrint.PrepareTime", | 764 UMA_HISTOGRAM_LONG_TIMES("CloudPrint.PrepareTime", |
| 765 base::Time::Now() - job_start_time_); | 765 base::Time::Now() - job_start_time_); |
| 766 DCHECK(job_spooler_.get()); | 766 DCHECK(job_spooler_.get()); |
| 767 if (!job_spooler_.get()) | 767 if (!job_spooler_.get()) |
| 768 return; | 768 return; |
| 769 string16 document_name = | 769 string16 document_name = |
| 770 printing::PrintBackend::SimplifyDocumentTitle( | 770 printing::SimplifyDocumentTitle(UTF8ToUTF16(job_details.job_title_)); |
| 771 UTF8ToUTF16(job_details.job_title_)); | |
| 772 if (document_name.empty()) { | 771 if (document_name.empty()) { |
| 773 document_name = printing::PrintBackend::SimplifyDocumentTitle( | 772 document_name = printing::SimplifyDocumentTitle( |
| 774 l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE)); | 773 l10n_util::GetStringUTF16(IDS_DEFAULT_PRINT_DOCUMENT_TITLE)); |
| 775 } | 774 } |
| 776 UMA_HISTOGRAM_ENUMERATION("CloudPrint.JobHandlerEvent", | 775 UMA_HISTOGRAM_ENUMERATION("CloudPrint.JobHandlerEvent", |
| 777 JOB_HANDLER_START_SPOOLING, JOB_HANDLER_MAX); | 776 JOB_HANDLER_START_SPOOLING, JOB_HANDLER_MAX); |
| 778 spooling_start_time_ = base::Time::Now(); | 777 spooling_start_time_ = base::Time::Now(); |
| 779 if (!job_spooler_->Spool(job_details.print_ticket_, | 778 if (!job_spooler_->Spool(job_details.print_ticket_, |
| 780 job_details.print_data_file_path_, | 779 job_details.print_data_file_path_, |
| 781 job_details.print_data_mime_type_, | 780 job_details.print_data_mime_type_, |
| 782 printer_name, | 781 printer_name, |
| 783 UTF16ToUTF8(document_name), | 782 UTF16ToUTF8(document_name), |
| 784 job_details.tags_, | 783 job_details.tags_, |
| 785 this)) { | 784 this)) { |
| 786 OnJobSpoolFailed(); | 785 OnJobSpoolFailed(); |
| 787 } | 786 } |
| 788 } | 787 } |
| 789 | 788 |
| 790 } // namespace cloud_print | 789 } // namespace cloud_print |
| OLD | NEW |