| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/pdf_to_emf_converter.h" | 5 #include "chrome/browser/printing/pdf_to_emf_converter.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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 BrowserThread::FILE, | 328 BrowserThread::FILE, |
| 329 FROM_HERE, | 329 FROM_HERE, |
| 330 base::Bind(&CreateTempPdfFile, data, &temp_dir_), | 330 base::Bind(&CreateTempPdfFile, data, &temp_dir_), |
| 331 base::Bind(&PdfToEmfUtilityProcessHostClient::OnTempPdfReady, this)); | 331 base::Bind(&PdfToEmfUtilityProcessHostClient::OnTempPdfReady, this)); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void PdfToEmfUtilityProcessHostClient::OnTempPdfReady(ScopedTempFile pdf) { | 334 void PdfToEmfUtilityProcessHostClient::OnTempPdfReady(ScopedTempFile pdf) { |
| 335 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 335 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 336 if (!utility_process_host_ || !pdf) | 336 if (!utility_process_host_ || !pdf) |
| 337 return OnFailed(); | 337 return OnFailed(); |
| 338 base::ProcessHandle process = utility_process_host_->GetData().handle; | |
| 339 // Should reply with OnPageCount(). | 338 // Should reply with OnPageCount(). |
| 340 Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( | 339 Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles( |
| 341 IPC::GetFileHandleForProcess(pdf->GetPlatformFile(), process, false), | 340 IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false), |
| 342 settings_)); | 341 settings_)); |
| 343 } | 342 } |
| 344 | 343 |
| 345 void PdfToEmfUtilityProcessHostClient::OnPageCount(int page_count) { | 344 void PdfToEmfUtilityProcessHostClient::OnPageCount(int page_count) { |
| 346 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 345 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 347 if (start_callback_.is_null()) | 346 if (start_callback_.is_null()) |
| 348 return OnFailed(); | 347 return OnFailed(); |
| 349 BrowserThread::PostTask(BrowserThread::UI, | 348 BrowserThread::PostTask(BrowserThread::UI, |
| 350 FROM_HERE, | 349 FROM_HERE, |
| 351 base::Bind(&PdfToEmfConverterImpl::RunCallback, | 350 base::Bind(&PdfToEmfConverterImpl::RunCallback, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 382 this, | 381 this, |
| 383 &get_page_callbacks_.back())); | 382 &get_page_callbacks_.back())); |
| 384 } | 383 } |
| 385 | 384 |
| 386 void PdfToEmfUtilityProcessHostClient::OnTempEmfReady( | 385 void PdfToEmfUtilityProcessHostClient::OnTempEmfReady( |
| 387 GetPageCallbackData* callback_data, | 386 GetPageCallbackData* callback_data, |
| 388 ScopedTempFile emf) { | 387 ScopedTempFile emf) { |
| 389 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 388 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 390 if (!utility_process_host_ || !emf) | 389 if (!utility_process_host_ || !emf) |
| 391 return OnFailed(); | 390 return OnFailed(); |
| 392 base::ProcessHandle process = utility_process_host_->GetData().handle; | |
| 393 IPC::PlatformFileForTransit transit = | 391 IPC::PlatformFileForTransit transit = |
| 394 IPC::GetFileHandleForProcess(emf->GetPlatformFile(), process, false); | 392 IPC::GetPlatformFileForTransit(emf->GetPlatformFile(), false); |
| 395 callback_data->set_emf(std::move(emf)); | 393 callback_data->set_emf(std::move(emf)); |
| 396 // Should reply with OnPageDone(). | 394 // Should reply with OnPageDone(). |
| 397 Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage( | 395 Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage( |
| 398 callback_data->page_number(), transit)); | 396 callback_data->page_number(), transit)); |
| 399 } | 397 } |
| 400 | 398 |
| 401 void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success, | 399 void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success, |
| 402 float scale_factor) { | 400 float scale_factor) { |
| 403 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 401 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 404 if (get_page_callbacks_.empty()) | 402 if (get_page_callbacks_.empty()) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 503 |
| 506 PdfToEmfConverter::~PdfToEmfConverter() { | 504 PdfToEmfConverter::~PdfToEmfConverter() { |
| 507 } | 505 } |
| 508 | 506 |
| 509 // static | 507 // static |
| 510 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() { | 508 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() { |
| 511 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl()); | 509 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl()); |
| 512 } | 510 } |
| 513 | 511 |
| 514 } // namespace printing | 512 } // namespace printing |
| OLD | NEW |