| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 109 current_page_++, | 109 current_page_++, |
| 110 IPC::GetFileHandleForProcess( | 110 IPC::GetPlatformFileForTransit( |
| 111 emf_files_.back().GetPlatformFile(), host_->handle(), false))); | 111 emf_files_.back().GetPlatformFile(), false))); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Returns true if all pages processed and client should not expect more | 115 // Returns true if all pages processed and client should not expect more |
| 116 // results. | 116 // results. |
| 117 bool OnPageProcessed() { | 117 bool OnPageProcessed() { |
| 118 --pages_in_progress_; | 118 --pages_in_progress_; |
| 119 GetMorePages(); | 119 GetMorePages(); |
| 120 if (pages_in_progress_ || current_page_ < page_count_) | 120 if (pages_in_progress_ || current_page_ < page_count_) |
| 121 return false; | 121 return false; |
| (...skipping 308 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 |