Chromium Code Reviews| Index: chrome/browser/printing/print_view_manager_base.cc |
| diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc |
| index f10180891110e44923841330f69b777a5804b4c6..6f61e8247e4a937c04d178604212fc9048d729e0 100644 |
| --- a/chrome/browser/printing/print_view_manager_base.cc |
| +++ b/chrome/browser/printing/print_view_manager_base.cc |
| @@ -7,7 +7,9 @@ |
| #include <map> |
| #include "base/bind.h" |
| +#include "base/file_util.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/numerics/safe_conversions.h" |
| #include "base/prefs/pref_service.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/timer/timer.h" |
| @@ -50,12 +52,25 @@ |
| using base::TimeDelta; |
| using content::BrowserThread; |
| +namespace printing { |
| + |
| +namespace { |
| + |
| #if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING) |
| // Limits memory usage by raster to 64 MiB. |
| const int kMaxRasterSizeInPixels = 16*1024*1024; |
| #endif |
| -namespace printing { |
| +#if defined(WIN_PDF_METAFILE_FOR_PRINTING) |
| +void WriteBytesOnFileThread(const base::FilePath& path, |
| + const base::RefCountedMemory* deta) { |
| + base::WriteFile(path, |
| + reinterpret_cast<const char*>(deta->front()), |
| + base::checked_cast<int>(deta->size())); |
| +} |
| +#endif // WIN_PDF_METAFILE_FOR_PRINTING |
| + |
| +} // namespace |
| PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents) |
| : content::WebContentsObserver(web_contents), |
| @@ -220,10 +235,10 @@ void PrintViewManagerBase::OnDidPrintPage( |
| #if !defined(WIN_PDF_METAFILE_FOR_PRINTING) |
| // Update the rendered document. It will send notifications to the listener. |
| document->SetPage(params.page_number, |
| - metafile.release(), |
| - params.actual_shrink, |
| - params.page_size, |
| - params.content_area); |
| + metafile.release(), |
| + params.actual_shrink, |
| + params.page_size, |
| + params.content_area); |
| ShouldQuitFromInnerMessageLoop(); |
| #else |
| @@ -232,6 +247,15 @@ void PrintViewManagerBase::OnDidPrintPage( |
| reinterpret_cast<const unsigned char*>(shared_buf.memory()), |
| params.data_size); |
| + base::FilePath debug_dump_path = |
| + PrintedDocument::CreateDebugDumpPath(document->name(), "pdf"); |
| + if (!debug_dump_path.empty()) { |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, |
| + FROM_HERE, |
| + base::Bind(&WriteBytesOnFileThread, debug_dump_path, bytes)); |
|
Lei Zhang
2014/06/11 20:03:05
You can probably Bind() to &base::WriteFile with I
Vitaly Buka (NO REVIEWS)
2014/06/11 21:32:57
Moved writing into document.
|
| + } |
|
Noam Samuel
2014/06/11 18:35:23
Does this only dump PDFS on Windows? Maybe it make
Vitaly Buka (NO REVIEWS)
2014/06/11 21:32:57
Other platforms dumped pdfs inside of SetPage abov
|
| + |
| if (!pdf_to_emf_converter_) |
| pdf_to_emf_converter_ = PdfToEmfConverter::CreateDefault(); |