OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/printing/pdf_to_emf_converter.h" | 5 #include "chrome/browser/printing/pdf_to_emf_converter.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 void RunCallback(const std::vector<printing::PageRange>& page_ranges, | 118 void RunCallback(const std::vector<printing::PageRange>& page_ranges, |
119 double scale_factor); | 119 double scale_factor); |
120 | 120 |
121 void StartProcessOnIOThread(); | 121 void StartProcessOnIOThread(); |
122 | 122 |
123 void RunCallbackOnUIThread( | 123 void RunCallbackOnUIThread( |
124 const std::vector<printing::PageRange>& page_ranges, | 124 const std::vector<printing::PageRange>& page_ranges, |
125 double scale_factor); | 125 double scale_factor); |
126 void OnFilesReadyOnUIThread(); | 126 void OnFilesReadyOnUIThread(); |
127 | 127 |
128 scoped_ptr<FileHandlers> files_; | 128 scoped_ptr<FileHandlers, BrowserThread::DeleteOnFileThread> files_; |
129 printing::PdfRenderSettings settings_; | 129 printing::PdfRenderSettings settings_; |
130 PdfToEmfConverter::ResultCallback callback_; | 130 PdfToEmfConverter::ResultCallback callback_; |
131 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; | 131 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
132 | 132 |
133 DISALLOW_COPY_AND_ASSIGN(PdfToEmfUtilityProcessHostClient); | 133 DISALLOW_COPY_AND_ASSIGN(PdfToEmfUtilityProcessHostClient); |
134 }; | 134 }; |
135 | 135 |
136 PdfToEmfUtilityProcessHostClient::PdfToEmfUtilityProcessHostClient( | 136 PdfToEmfUtilityProcessHostClient::PdfToEmfUtilityProcessHostClient( |
137 const printing::PdfRenderSettings& settings) | 137 const printing::PdfRenderSettings& settings) |
138 : settings_(settings) {} | 138 : settings_(settings) {} |
139 | 139 |
140 PdfToEmfUtilityProcessHostClient::~PdfToEmfUtilityProcessHostClient() { | 140 PdfToEmfUtilityProcessHostClient::~PdfToEmfUtilityProcessHostClient() { |
141 // Delete temp directory. | |
142 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, files_.release()); | |
143 } | 141 } |
144 | 142 |
145 void PdfToEmfUtilityProcessHostClient::Convert( | 143 void PdfToEmfUtilityProcessHostClient::Convert( |
146 base::RefCountedMemory* data, | 144 base::RefCountedMemory* data, |
147 const PdfToEmfConverter::ResultCallback& callback) { | 145 const PdfToEmfConverter::ResultCallback& callback) { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
149 callback_ = callback; | 147 callback_ = callback; |
150 CHECK(!files_); | 148 CHECK(!files_); |
151 files_.reset(new FileHandlers()); | 149 files_.reset(new FileHandlers()); |
152 BrowserThread::PostTaskAndReply( | 150 BrowserThread::PostTaskAndReply( |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 298 } |
301 | 299 |
302 } // namespace | 300 } // namespace |
303 | 301 |
304 // static | 302 // static |
305 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() { | 303 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() { |
306 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl()); | 304 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl()); |
307 } | 305 } |
308 | 306 |
309 } // namespace printing | 307 } // namespace printing |
OLD | NEW |