Index: chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
index cef8b2c40a8e3e5d3b3264f140fb671ea2e63052..06894a481c3d33cff4af311905f1c117a9fa7a35 100644 |
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
@@ -240,13 +240,13 @@ void ReportPrintSettingsStats(const base::DictionaryValue& settings) { |
} |
// Callback that stores a PDF file on disk. |
-void PrintToPdfCallback(printing::Metafile* metafile, |
+void PrintToPdfCallback(const scoped_refptr<base::RefCountedBytes>& data, |
const base::FilePath& path, |
const base::Closure& pdf_file_saved_closure) { |
DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
- metafile->SaveTo(path); |
- // |metafile| must be deleted on the UI thread. |
- BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, metafile); |
+ printing::PdfMetafileSkia metafile; |
+ metafile.InitFromData(static_cast<const void*>(data->front()), data->size()); |
+ metafile.SaveTo(path); |
if (!pdf_file_saved_closure.is_null()) |
pdf_file_saved_closure.Run(); |
} |
@@ -1315,14 +1315,12 @@ void PrintPreviewHandler::PostPrintToPdfTask() { |
NOTREACHED() << "Preview data was checked before file dialog."; |
return; |
} |
- scoped_ptr<printing::PdfMetafileSkia> metafile(new printing::PdfMetafileSkia); |
- metafile->InitFromData(static_cast<const void*>(data->front()), data->size()); |
- BrowserThread::PostTask( |
- BrowserThread::FILE, FROM_HERE, |
- base::Bind(&PrintToPdfCallback, |
- metafile.release(), |
- print_to_pdf_path_, |
- pdf_file_saved_closure_)); |
+ BrowserThread::PostTask(BrowserThread::FILE, |
+ FROM_HERE, |
+ base::Bind(&PrintToPdfCallback, |
+ data, |
+ print_to_pdf_path_, |
+ pdf_file_saved_closure_)); |
print_to_pdf_path_ = base::FilePath(); |
ClosePreviewDialog(); |
} |