Commit de97f62a authored by thestig@chromium.org's avatar thestig@chromium.org

Print preview: Delete metafiles on the right thread.

BUG=106665
TEST=see bug.

Review URL: http://codereview.chromium.org/8872008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113570 0039d316-1c4b-4281-b951-d872f2087c98
parent 51451833
......@@ -57,6 +57,7 @@
#endif
using content::BrowserThread;
using printing::Metafile;
namespace {
......@@ -173,13 +174,16 @@ void ReportPrintSettingsStats(const DictionaryValue& settings) {
}
}
} // 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 @@ void PrintPreviewHandler::PostPrintToPdfTask() {
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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment