| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/printing/pwg_raster_converter.h" | 5 #include "chrome/browser/printing/pwg_raster_converter.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 bool IsValid(); | 50 bool IsValid(); |
| 51 | 51 |
| 52 base::FilePath GetPwgPath() const { | 52 base::FilePath GetPwgPath() const { |
| 53 return temp_dir_.path().AppendASCII("output.pwg"); | 53 return temp_dir_.path().AppendASCII("output.pwg"); |
| 54 } | 54 } |
| 55 | 55 |
| 56 base::FilePath GetPdfPath() const { | 56 base::FilePath GetPdfPath() const { |
| 57 return temp_dir_.path().AppendASCII("input.pdf"); | 57 return temp_dir_.path().AppendASCII("input.pdf"); |
| 58 } | 58 } |
| 59 | 59 |
| 60 IPC::PlatformFileForTransit GetPdfForProcess(base::ProcessHandle process) { | 60 IPC::PlatformFileForTransit GetPdfForProcess() { |
| 61 DCHECK(pdf_file_.IsValid()); | 61 DCHECK(pdf_file_.IsValid()); |
| 62 IPC::PlatformFileForTransit transit = | 62 IPC::PlatformFileForTransit transit = |
| 63 IPC::TakeFileHandleForProcess(std::move(pdf_file_), process); | 63 IPC::TakePlatformFileForTransit(std::move(pdf_file_)); |
| 64 return transit; | 64 return transit; |
| 65 } | 65 } |
| 66 | 66 |
| 67 IPC::PlatformFileForTransit GetPwgForProcess(base::ProcessHandle process) { | 67 IPC::PlatformFileForTransit GetPwgForProcess() { |
| 68 DCHECK(pwg_file_.IsValid()); | 68 DCHECK(pwg_file_.IsValid()); |
| 69 IPC::PlatformFileForTransit transit = | 69 IPC::PlatformFileForTransit transit = |
| 70 IPC::TakeFileHandleForProcess(std::move(pwg_file_), process); | 70 IPC::TakePlatformFileForTransit(std::move(pwg_file_)); |
| 71 return transit; | 71 return transit; |
| 72 } | 72 } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 base::ScopedTempDir temp_dir_; | 75 base::ScopedTempDir temp_dir_; |
| 76 base::File pdf_file_; | 76 base::File pdf_file_; |
| 77 base::File pwg_file_; | 77 base::File pwg_file_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 void FileHandlers::Init(base::RefCountedMemory* data) { | 80 void FileHandlers::Init(base::RefCountedMemory* data) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 return handled; | 189 return handled; |
| 190 } | 190 } |
| 191 | 191 |
| 192 void PwgUtilityProcessHostClient::OnProcessStarted() { | 192 void PwgUtilityProcessHostClient::OnProcessStarted() { |
| 193 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 193 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 194 if (!utility_process_host_) { | 194 if (!utility_process_host_) { |
| 195 RunCallbackOnUIThread(false); | 195 RunCallbackOnUIThread(false); |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 base::ProcessHandle process = utility_process_host_->GetData().handle; | |
| 200 utility_process_host_->Send(new ChromeUtilityMsg_RenderPDFPagesToPWGRaster( | 199 utility_process_host_->Send(new ChromeUtilityMsg_RenderPDFPagesToPWGRaster( |
| 201 files_->GetPdfForProcess(process), | 200 files_->GetPdfForProcess(), settings_, bitmap_settings_, |
| 202 settings_, | 201 files_->GetPwgForProcess())); |
| 203 bitmap_settings_, | |
| 204 files_->GetPwgForProcess(process))); | |
| 205 utility_process_host_.reset(); | 202 utility_process_host_.reset(); |
| 206 } | 203 } |
| 207 | 204 |
| 208 void PwgUtilityProcessHostClient::OnSucceeded() { | 205 void PwgUtilityProcessHostClient::OnSucceeded() { |
| 209 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 206 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 210 RunCallback(true); | 207 RunCallback(true); |
| 211 } | 208 } |
| 212 | 209 |
| 213 void PwgUtilityProcessHostClient::OnFailed() { | 210 void PwgUtilityProcessHostClient::OnFailed() { |
| 214 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 211 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 354 } |
| 358 } | 355 } |
| 359 | 356 |
| 360 result.rotate_all_pages = raster_capability.value().rotate_all_pages; | 357 result.rotate_all_pages = raster_capability.value().rotate_all_pages; |
| 361 | 358 |
| 362 result.reverse_page_order = raster_capability.value().reverse_order_streaming; | 359 result.reverse_page_order = raster_capability.value().reverse_order_streaming; |
| 363 return result; | 360 return result; |
| 364 } | 361 } |
| 365 | 362 |
| 366 } // namespace printing | 363 } // namespace printing |
| OLD | NEW |