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/service_utility_process_host.h" | 5 #include "chrome/service/service_utility_process_host.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <queue> | 9 #include <queue> |
10 #include <utility> | 10 #include <utility> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 explicit PdfToEmfState(ServiceUtilityProcessHost* host) | 92 explicit PdfToEmfState(ServiceUtilityProcessHost* host) |
93 : host_(host), page_count_(0), current_page_(0), pages_in_progress_(0) {} | 93 : host_(host), page_count_(0), current_page_(0), pages_in_progress_(0) {} |
94 ~PdfToEmfState() { Stop(); } | 94 ~PdfToEmfState() { Stop(); } |
95 | 95 |
96 bool Start(base::File pdf_file, | 96 bool Start(base::File pdf_file, |
97 const printing::PdfRenderSettings& conversion_settings) { | 97 const printing::PdfRenderSettings& conversion_settings) { |
98 if (!temp_dir_.CreateUniqueTempDir()) | 98 if (!temp_dir_.CreateUniqueTempDir()) |
99 return false; | 99 return false; |
100 return host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( | 100 return host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( |
101 IPC::TakePlatformFileForTransit(std::move(pdf_file)), | 101 IPC::TakePlatformFileForTransit(std::move(pdf_file)), |
102 conversion_settings, false /* print_text_with_gdi */)); | 102 conversion_settings)); |
103 } | 103 } |
104 | 104 |
105 void GetMorePages() { | 105 void GetMorePages() { |
106 const int kMaxNumberOfTempFilesPerDocument = 3; | 106 const int kMaxNumberOfTempFilesPerDocument = 3; |
107 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && | 107 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && |
108 current_page_ < page_count_) { | 108 current_page_ < page_count_) { |
109 ++pages_in_progress_; | 109 ++pages_in_progress_; |
110 emf_files_.push(CreateTempFile()); | 110 emf_files_.push(CreateTempFile()); |
111 host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage( | 111 host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage( |
112 current_page_++, | 112 current_page_++, |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 return false; | 457 return false; |
458 } | 458 } |
459 printing::Emf emf; | 459 printing::Emf emf; |
460 if (!emf.InitFromData(data.data(), data.size())) { | 460 if (!emf.InitFromData(data.data(), data.size())) { |
461 OnRenderPDFPagesToMetafileDone(false); | 461 OnRenderPDFPagesToMetafileDone(false); |
462 return false; | 462 return false; |
463 } | 463 } |
464 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); | 464 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); |
465 return true; | 465 return true; |
466 } | 466 } |
OLD | NEW |