| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 public: | 88 public: |
| 89 explicit PdfToEmfState(ServiceUtilityProcessHost* host) | 89 explicit PdfToEmfState(ServiceUtilityProcessHost* host) |
| 90 : host_(host), page_count_(0), current_page_(0), pages_in_progress_(0) {} | 90 : host_(host), page_count_(0), current_page_(0), pages_in_progress_(0) {} |
| 91 ~PdfToEmfState() { Stop(); } | 91 ~PdfToEmfState() { Stop(); } |
| 92 | 92 |
| 93 bool Start(base::File pdf_file, | 93 bool Start(base::File pdf_file, |
| 94 const printing::PdfRenderSettings& conversion_settings) { | 94 const printing::PdfRenderSettings& conversion_settings) { |
| 95 if (!temp_dir_.CreateUniqueTempDir()) | 95 if (!temp_dir_.CreateUniqueTempDir()) |
| 96 return false; | 96 return false; |
| 97 return host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( | 97 return host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( |
| 98 IPC::TakeFileHandleForProcess(std::move(pdf_file), host_->handle()), | 98 IPC::TakePlatformFileForTransit(std::move(pdf_file)), |
| 99 conversion_settings)); | 99 conversion_settings)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void GetMorePages() { | 102 void GetMorePages() { |
| 103 const int kMaxNumberOfTempFilesPerDocument = 3; | 103 const int kMaxNumberOfTempFilesPerDocument = 3; |
| 104 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && | 104 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && |
| 105 current_page_ < page_count_) { | 105 current_page_ < page_count_) { |
| 106 ++pages_in_progress_; | 106 ++pages_in_progress_; |
| 107 emf_files_.push(CreateTempFile()); | 107 emf_files_.push(CreateTempFile()); |
| 108 host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage( | 108 host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage( |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 return false; | 430 return false; |
| 431 } | 431 } |
| 432 printing::Emf emf; | 432 printing::Emf emf; |
| 433 if (!emf.InitFromData(data.data(), data.size())) { | 433 if (!emf.InitFromData(data.data(), data.size())) { |
| 434 OnRenderPDFPagesToMetafileDone(false); | 434 OnRenderPDFPagesToMetafileDone(false); |
| 435 return false; | 435 return false; |
| 436 } | 436 } |
| 437 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); | 437 OnRenderPDFPagesToMetafilePageDone(scale_factor, emf); |
| 438 return true; | 438 return true; |
| 439 } | 439 } |
| OLD | NEW |