Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3657)

Unified Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 8872008: Print preview: Delete metafiles on the right thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/print_preview_handler.cc
===================================================================
--- chrome/browser/ui/webui/print_preview_handler.cc (revision 113100)
+++ chrome/browser/ui/webui/print_preview_handler.cc (working copy)
@@ -57,6 +57,7 @@
#endif
using content::BrowserThread;
+using printing::Metafile;
namespace {
@@ -173,13 +174,16 @@
}
}
-} // namespace
-
// Callback that stores a PDF file on disk.
-void PrintToPdfCallback(printing::Metafile* metafile, const FilePath& path) {
+void PrintToPdfCallback(Metafile* metafile, const FilePath& path) {
metafile->SaveTo(path);
+ // |metafile| must be deleted on the UI thread.
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&DeletePointer<Metafile>, metafile));
}
+} // namespace
+
// static
FilePath* PrintPreviewHandler::last_saved_path_ = NULL;
std::string* PrintPreviewHandler::last_used_printer_cloud_print_data_ = NULL;
@@ -814,8 +818,9 @@
DCHECK(data.get());
printing::PreviewMetafile* metafile = new printing::PreviewMetafile;
metafile->InitFromData(static_cast<const void*>(data->front()), data->size());
+ // PrintToPdfCallback takes ownership of |metafile|.
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&PrintToPdfCallback, base::Owned(metafile),
+ base::Bind(&PrintToPdfCallback, metafile,
*print_to_pdf_path_));
print_to_pdf_path_.reset();
ActivateInitiatorTabAndClosePreviewTab();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698