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

Unified Diff: chrome/browser/printing/pdf_to_emf_converter.cc

Issue 1132393002: Check if temp file was created before OnPageDone called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mon May 11 10:22:01 PDT 2015 Created 5 years, 7 months 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/printing/pdf_to_emf_converter.cc
diff --git a/chrome/browser/printing/pdf_to_emf_converter.cc b/chrome/browser/printing/pdf_to_emf_converter.cc
index fa64e97586600c0698d01b57d35436aa5a648000..676459da0f055e13258b70f3f489028a51098c51 100644
--- a/chrome/browser/printing/pdf_to_emf_converter.cc
+++ b/chrome/browser/printing/pdf_to_emf_converter.cc
@@ -60,7 +60,9 @@ typedef scoped_ptr<base::File, BrowserThread::DeleteOnFileThread>
class LazyEmf : public MetafilePlayer {
public:
LazyEmf(const scoped_refptr<RefCountedTempDir>& temp_dir, ScopedTempFile file)
- : temp_dir_(temp_dir), file_(file.Pass()) {}
+ : temp_dir_(temp_dir), file_(file.Pass()) {
+ CHECK(file_);
+ }
~LazyEmf() override { Close(); }
bool SafePlayback(HDC hdc) const override;
@@ -133,7 +135,7 @@ class PdfToEmfUtilityProcessHostClient
const PdfToEmfConverter::GetPageCallback& callback() const {
return callback_;
}
- ScopedTempFile emf() { return emf_.Pass(); }
+ ScopedTempFile TakeEmf() { return emf_.Pass(); }
void set_emf(ScopedTempFile emf) { emf_ = emf.Pass(); }
private:
@@ -398,10 +400,16 @@ void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success,
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (get_page_callbacks_.empty())
return OnFailed();
- scoped_ptr<MetafilePlayer> emf;
GetPageCallbackData& data = get_page_callbacks_.front();
- if (success)
- emf.reset(new LazyEmf(temp_dir_, data.emf().Pass()));
+ scoped_ptr<MetafilePlayer> emf;
+
+ if (success) {
+ ScopedTempFile temp_emf = data.TakeEmf();
+ if (!temp_emf) // Unexpected message from utility process.
+ return OnFailed();
+ emf.reset(new LazyEmf(temp_dir_, temp_emf.Pass()));
+ }
+
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
base::Bind(&PdfToEmfConverterImpl::RunCallback,
« 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