| OLD | NEW |
| 1 // Copyright 2013 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/local_discovery/pwg_raster_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" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "chrome/common/chrome_utility_messages.h" | 13 #include "chrome/common/chrome_utility_messages.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/child_process_data.h" | 15 #include "content/public/browser/child_process_data.h" |
| 16 #include "content/public/browser/utility_process_host.h" | 16 #include "content/public/browser/utility_process_host.h" |
| 17 #include "content/public/browser/utility_process_host_client.h" | 17 #include "content/public/browser/utility_process_host_client.h" |
| 18 | 18 |
| 19 namespace local_discovery { | 19 namespace printing { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 | 24 |
| 25 class FileHandlers { | 25 class FileHandlers { |
| 26 public: | 26 public: |
| 27 FileHandlers() {} | 27 FileHandlers() {} |
| 28 | 28 |
| 29 ~FileHandlers() { | 29 ~FileHandlers() { |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void Init(base::RefCountedMemory* data); | 33 void Init(base::RefCountedMemory* data); |
| 34 bool IsValid(); | 34 bool IsValid(); |
| 35 | 35 |
| 36 base::FilePath GetPwgPath() const { | 36 base::FilePath GetEmfPath() const { |
| 37 return temp_dir_.path().AppendASCII("output.pwg"); | 37 return temp_dir_.path().AppendASCII("output.emf"); |
| 38 } | 38 } |
| 39 | 39 |
| 40 base::FilePath GetPdfPath() const { | 40 base::FilePath GetPdfPath() const { |
| 41 return temp_dir_.path().AppendASCII("input.pdf"); | 41 return temp_dir_.path().AppendASCII("input.pdf"); |
| 42 } | 42 } |
| 43 | 43 |
| 44 IPC::PlatformFileForTransit GetPdfForProcess(base::ProcessHandle process) { | 44 IPC::PlatformFileForTransit GetPdfForProcess(base::ProcessHandle process) { |
| 45 DCHECK(pdf_file_.IsValid()); | 45 DCHECK(pdf_file_.IsValid()); |
| 46 IPC::PlatformFileForTransit transit = | 46 IPC::PlatformFileForTransit transit = |
| 47 IPC::TakeFileHandleForProcess(pdf_file_.Pass(), process); | 47 IPC::TakeFileHandleForProcess(pdf_file_.Pass(), process); |
| 48 return transit; | 48 return transit; |
| 49 } | 49 } |
| 50 | 50 |
| 51 IPC::PlatformFileForTransit GetPwgForProcess(base::ProcessHandle process) { | 51 const base::FilePath& GetBasePath() const { |
| 52 DCHECK(pwg_file_.IsValid()); | 52 return temp_dir_.path(); |
| 53 IPC::PlatformFileForTransit transit = | |
| 54 IPC::TakeFileHandleForProcess(pwg_file_.Pass(), process); | |
| 55 return transit; | |
| 56 } | 53 } |
| 57 | 54 |
| 58 private: | 55 private: |
| 59 base::ScopedTempDir temp_dir_; | 56 base::ScopedTempDir temp_dir_; |
| 60 base::File pdf_file_; | 57 base::File pdf_file_; |
| 61 base::File pwg_file_; | |
| 62 }; | 58 }; |
| 63 | 59 |
| 64 void FileHandlers::Init(base::RefCountedMemory* data) { | 60 void FileHandlers::Init(base::RefCountedMemory* data) { |
| 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 66 | 62 |
| 67 if (!temp_dir_.CreateUniqueTempDir()) { | 63 if (!temp_dir_.CreateUniqueTempDir()) { |
| 68 return; | 64 return; |
| 69 } | 65 } |
| 70 | 66 |
| 71 if (static_cast<int>(data->size()) != | 67 if (static_cast<int>(data->size()) != |
| 72 base::WriteFile(GetPdfPath(), data->front_as<char>(), data->size())) { | 68 base::WriteFile(GetPdfPath(), data->front_as<char>(), data->size())) { |
| 73 return; | 69 return; |
| 74 } | 70 } |
| 75 | 71 |
| 76 // Reopen in read only mode. | 72 // Reopen in read only mode. |
| 77 pdf_file_.Initialize(GetPdfPath(), | 73 pdf_file_.Initialize(GetPdfPath(), |
| 78 base::File::FLAG_OPEN | base::File::FLAG_READ); | 74 base::File::FLAG_OPEN | base::File::FLAG_READ); |
| 79 pwg_file_.Initialize( | |
| 80 GetPwgPath(), | |
| 81 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_APPEND); | |
| 82 } | 75 } |
| 83 | 76 |
| 84 bool FileHandlers::IsValid() { | 77 bool FileHandlers::IsValid() { |
| 85 return pdf_file_.IsValid() && pwg_file_.IsValid(); | 78 return pdf_file_.IsValid(); |
| 86 } | 79 } |
| 87 | 80 |
| 88 // Converts PDF into PWG raster. | 81 // Converts PDF into EMF. |
| 89 // Class uses 3 threads: UI, IO and FILE. | 82 // Class uses 3 threads: UI, IO and FILE. |
| 90 // Internal workflow is following: | 83 // Internal workflow is following: |
| 91 // 1. Create instance on the UI thread. (files_, settings_,) | 84 // 1. Create instance on the UI thread. (files_, settings_,) |
| 92 // 2. Create file on the FILE thread. | 85 // 2. Create file on the FILE thread. |
| 93 // 3. Start utility process and start conversion on the IO thread. | 86 // 3. Start utility process and start conversion on the IO thread. |
| 94 // 4. Run result callback on the UI thread. | 87 // 4. Run result callback on the UI thread. |
| 95 // 5. Instance is destroyed from any thread that has the last reference. | 88 // 5. Instance is destroyed from any thread that has the last reference. |
| 96 // 6. FileHandlers destroyed on the FILE thread. | 89 // 6. FileHandlers destroyed on the FILE thread. |
| 97 // This step posts |FileHandlers| to be destroyed on the FILE thread. | 90 // This step posts |FileHandlers| to be destroyed on the FILE thread. |
| 98 // All these steps work sequentially, so no data should be accessed | 91 // All these steps work sequentially, so no data should be accessed |
| 99 // simultaneously by several threads. | 92 // simultaneously by several threads. |
| 100 class PwgUtilityProcessHostClient : public content::UtilityProcessHostClient { | 93 class PdfToEmfUtilityProcessHostClient |
| 94 : public content::UtilityProcessHostClient { |
| 101 public: | 95 public: |
| 102 explicit PwgUtilityProcessHostClient( | 96 explicit PdfToEmfUtilityProcessHostClient( |
| 103 const printing::PdfRenderSettings& settings, | 97 const printing::PdfRenderSettings& settings); |
| 104 const printing::PwgRasterSettings& bitmap_settings); | |
| 105 | 98 |
| 106 void Convert(base::RefCountedMemory* data, | 99 void Convert(base::RefCountedMemory* data, |
| 107 const PWGRasterConverter::ResultCallback& callback); | 100 const PdfToEmfConverter::ResultCallback& callback); |
| 108 | 101 |
| 109 // UtilityProcessHostClient implementation. | 102 // UtilityProcessHostClient implementation. |
| 110 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 103 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
| 111 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 104 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 112 | 105 |
| 113 private: | 106 private: |
| 114 virtual ~PwgUtilityProcessHostClient(); | 107 virtual ~PdfToEmfUtilityProcessHostClient(); |
| 115 | 108 |
| 116 // Message handlers. | 109 // Message handlers. |
| 117 void OnProcessStarted(); | 110 void OnProcessStarted(); |
| 118 void OnSucceeded(); | 111 void OnSucceeded(int highest_rendered_page_number, double scale_factor); |
| 119 void OnFailed(); | 112 void OnFailed(); |
| 120 | 113 |
| 121 void RunCallback(bool success); | 114 void RunCallback(int highest_rendered_page_number, double scale_factor); |
| 122 | 115 |
| 123 void StartProcessOnIOThread(); | 116 void StartProcessOnIOThread(); |
| 124 | 117 |
| 125 void RunCallbackOnUIThread(bool success); | 118 void RunCallbackOnUIThread(int highest_rendered_page_number, |
| 119 double scale_factor); |
| 126 void OnFilesReadyOnUIThread(); | 120 void OnFilesReadyOnUIThread(); |
| 127 | 121 |
| 128 scoped_ptr<FileHandlers> files_; | 122 scoped_ptr<FileHandlers> files_; |
| 129 printing::PdfRenderSettings settings_; | 123 printing::PdfRenderSettings settings_; |
| 130 printing::PwgRasterSettings bitmap_settings_; | 124 PdfToEmfConverter::ResultCallback callback_; |
| 131 PWGRasterConverter::ResultCallback callback_; | |
| 132 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; | 125 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
| 133 | 126 |
| 134 DISALLOW_COPY_AND_ASSIGN(PwgUtilityProcessHostClient); | 127 DISALLOW_COPY_AND_ASSIGN(PdfToEmfUtilityProcessHostClient); |
| 135 }; | 128 }; |
| 136 | 129 |
| 137 PwgUtilityProcessHostClient::PwgUtilityProcessHostClient( | 130 PdfToEmfUtilityProcessHostClient::PdfToEmfUtilityProcessHostClient( |
| 138 const printing::PdfRenderSettings& settings, | 131 const printing::PdfRenderSettings& settings) |
| 139 const printing::PwgRasterSettings& bitmap_settings) | 132 : settings_(settings) {} |
| 140 : settings_(settings), bitmap_settings_(bitmap_settings) {} | 133 |
| 141 | 134 PdfToEmfUtilityProcessHostClient::~PdfToEmfUtilityProcessHostClient() { |
| 142 PwgUtilityProcessHostClient::~PwgUtilityProcessHostClient() { | |
| 143 // Delete temp directory. | 135 // Delete temp directory. |
| 144 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, files_.release()); | 136 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, files_.release()); |
| 145 } | 137 } |
| 146 | 138 |
| 147 void PwgUtilityProcessHostClient::Convert( | 139 void PdfToEmfUtilityProcessHostClient::Convert( |
| 148 base::RefCountedMemory* data, | 140 base::RefCountedMemory* data, |
| 149 const PWGRasterConverter::ResultCallback& callback) { | 141 const PdfToEmfConverter::ResultCallback& callback) { |
| 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 151 callback_ = callback; | 143 callback_ = callback; |
| 152 CHECK(!files_); | 144 CHECK(!files_); |
| 153 files_.reset(new FileHandlers()); | 145 files_.reset(new FileHandlers()); |
| 154 BrowserThread::PostTaskAndReply( | 146 BrowserThread::PostTaskAndReply( |
| 155 BrowserThread::FILE, FROM_HERE, | 147 BrowserThread::FILE, |
| 156 base::Bind(&FileHandlers::Init, base::Unretained(files_.get()), | 148 FROM_HERE, |
| 149 base::Bind(&FileHandlers::Init, |
| 150 base::Unretained(files_.get()), |
| 157 make_scoped_refptr(data)), | 151 make_scoped_refptr(data)), |
| 158 base::Bind(&PwgUtilityProcessHostClient::OnFilesReadyOnUIThread, this)); | 152 base::Bind(&PdfToEmfUtilityProcessHostClient::OnFilesReadyOnUIThread, |
| 159 } | 153 this)); |
| 160 | 154 } |
| 161 void PwgUtilityProcessHostClient::OnProcessCrashed(int exit_code) { | 155 |
| 156 void PdfToEmfUtilityProcessHostClient::OnProcessCrashed(int exit_code) { |
| 162 OnFailed(); | 157 OnFailed(); |
| 163 } | 158 } |
| 164 | 159 |
| 165 bool PwgUtilityProcessHostClient::OnMessageReceived( | 160 bool PdfToEmfUtilityProcessHostClient::OnMessageReceived( |
| 166 const IPC::Message& message) { | 161 const IPC::Message& message) { |
| 167 bool handled = true; | 162 bool handled = true; |
| 168 IPC_BEGIN_MESSAGE_MAP(PwgUtilityProcessHostClient, message) | 163 IPC_BEGIN_MESSAGE_MAP(PdfToEmfUtilityProcessHostClient, message) |
| 169 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, OnProcessStarted) | 164 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, OnProcessStarted) |
| 170 IPC_MESSAGE_HANDLER( | 165 IPC_MESSAGE_HANDLER( |
| 171 ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded, OnSucceeded) | 166 ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Succeeded, OnSucceeded) |
| 172 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed, | 167 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed, |
| 173 OnFailed) | 168 OnFailed) |
| 174 IPC_MESSAGE_UNHANDLED(handled = false) | 169 IPC_MESSAGE_UNHANDLED(handled = false) |
| 175 IPC_END_MESSAGE_MAP() | 170 IPC_END_MESSAGE_MAP() |
| 176 return handled; | 171 return handled; |
| 177 } | 172 } |
| 178 | 173 |
| 179 void PwgUtilityProcessHostClient::OnProcessStarted() { | 174 void PdfToEmfUtilityProcessHostClient::OnProcessStarted() { |
| 180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 181 if (!utility_process_host_) { | 176 if (!utility_process_host_) { |
| 182 RunCallbackOnUIThread(false); | 177 RunCallbackOnUIThread(-1, 0.0); |
| 183 return; | 178 return; |
| 184 } | 179 } |
| 185 | 180 |
| 186 base::ProcessHandle process = utility_process_host_->GetData().handle; | 181 base::ProcessHandle process = utility_process_host_->GetData().handle; |
| 187 utility_process_host_->Send(new ChromeUtilityMsg_RenderPDFPagesToPWGRaster( | 182 utility_process_host_->Send( |
| 188 files_->GetPdfForProcess(process), | 183 new ChromeUtilityMsg_RenderPDFToMetafile( |
| 189 settings_, | 184 files_->GetPdfForProcess(process), |
| 190 bitmap_settings_, | 185 files_->GetEmfPath(), |
| 191 files_->GetPwgForProcess(process))); | 186 settings_)); |
| 192 utility_process_host_.reset(); | 187 utility_process_host_.reset(); |
| 193 } | 188 } |
| 194 | 189 |
| 195 void PwgUtilityProcessHostClient::OnSucceeded() { | 190 void PdfToEmfUtilityProcessHostClient::OnSucceeded( |
| 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 191 int highest_rendered_page_number, |
| 197 RunCallback(true); | 192 double scale_factor) { |
| 198 } | 193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 199 | 194 RunCallback(highest_rendered_page_number, scale_factor); |
| 200 void PwgUtilityProcessHostClient::OnFailed() { | 195 } |
| 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 196 |
| 202 RunCallback(false); | 197 void PdfToEmfUtilityProcessHostClient::OnFailed() { |
| 203 } | 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 204 | 199 RunCallback(-1, 0.0); |
| 205 void PwgUtilityProcessHostClient::OnFilesReadyOnUIThread() { | 200 } |
| 201 |
| 202 void PdfToEmfUtilityProcessHostClient::OnFilesReadyOnUIThread() { |
| 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 207 if (!files_->IsValid()) { | 204 if (!files_->IsValid()) { |
| 208 RunCallbackOnUIThread(false); | 205 RunCallbackOnUIThread(-1, 0.0); |
| 209 return; | 206 return; |
| 210 } | 207 } |
| 211 BrowserThread::PostTask( | 208 BrowserThread::PostTask( |
| 212 BrowserThread::IO, FROM_HERE, | 209 BrowserThread::IO, |
| 213 base::Bind(&PwgUtilityProcessHostClient::StartProcessOnIOThread, this)); | 210 FROM_HERE, |
| 214 } | 211 base::Bind(&PdfToEmfUtilityProcessHostClient::StartProcessOnIOThread, |
| 215 | 212 this)); |
| 216 void PwgUtilityProcessHostClient::StartProcessOnIOThread() { | 213 } |
| 214 |
| 215 void PdfToEmfUtilityProcessHostClient::StartProcessOnIOThread() { |
| 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 218 utility_process_host_ = | 217 utility_process_host_ = |
| 219 content::UtilityProcessHost::Create( | 218 content::UtilityProcessHost::Create( |
| 220 this, | 219 this, |
| 221 base::MessageLoop::current()->message_loop_proxy())->AsWeakPtr(); | 220 base::MessageLoop::current()->message_loop_proxy())->AsWeakPtr(); |
| 221 // NOTE: This process _must_ be sandboxed, otherwise the pdf dll will load |
| 222 // gdiplus.dll, change how rendering happens, and not be able to correctly |
| 223 // generate when sent to a metafile DC. |
| 224 utility_process_host_->SetExposedDir(files_->GetBasePath()); |
| 222 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); | 225 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); |
| 223 } | 226 } |
| 224 | 227 |
| 225 void PwgUtilityProcessHostClient::RunCallback(bool success) { | 228 void PdfToEmfUtilityProcessHostClient::RunCallback( |
| 229 int highest_rendered_page_number, |
| 230 double scale_factor) { |
| 226 BrowserThread::PostTask( | 231 BrowserThread::PostTask( |
| 227 BrowserThread::UI, FROM_HERE, | 232 BrowserThread::UI, |
| 228 base::Bind(&PwgUtilityProcessHostClient::RunCallbackOnUIThread, this, | 233 FROM_HERE, |
| 229 success)); | 234 base::Bind(&PdfToEmfUtilityProcessHostClient::RunCallbackOnUIThread, |
| 230 } | 235 this, |
| 231 | 236 highest_rendered_page_number, |
| 232 void PwgUtilityProcessHostClient::RunCallbackOnUIThread(bool success) { | 237 scale_factor)); |
| 238 } |
| 239 |
| 240 void PdfToEmfUtilityProcessHostClient::RunCallbackOnUIThread( |
| 241 int highest_rendered_page_number, |
| 242 double scale_factor) { |
| 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 244 std::vector<base::FilePath> page_filenames; |
| 245 for (int i = 0; i <= highest_rendered_page_number; ++i) { |
| 246 page_filenames.push_back(files_->GetEmfPath().InsertBeforeExtensionASCII( |
| 247 base::StringPrintf(".%d", i))); |
| 248 } |
| 234 if (!callback_.is_null()) { | 249 if (!callback_.is_null()) { |
| 235 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 250 BrowserThread::PostTask( |
| 236 base::Bind(callback_, success, | 251 BrowserThread::UI, |
| 237 files_->GetPwgPath())); | 252 FROM_HERE, |
| 253 base::Bind(callback_, scale_factor, page_filenames)); |
| 238 callback_.Reset(); | 254 callback_.Reset(); |
| 239 } | 255 } |
| 240 } | 256 } |
| 241 | 257 |
| 242 class PWGRasterConverterImpl : public PWGRasterConverter { | 258 class PdfToEmfConverterImpl : public PdfToEmfConverter { |
| 243 public: | 259 public: |
| 244 PWGRasterConverterImpl(); | 260 PdfToEmfConverterImpl(); |
| 245 | 261 |
| 246 virtual ~PWGRasterConverterImpl(); | 262 virtual ~PdfToEmfConverterImpl(); |
| 247 | 263 |
| 248 virtual void Start(base::RefCountedMemory* data, | 264 virtual void Start(base::RefCountedMemory* data, |
| 249 const printing::PdfRenderSettings& conversion_settings, | 265 const printing::PdfRenderSettings& conversion_settings, |
| 250 const printing::PwgRasterSettings& bitmap_settings, | |
| 251 const ResultCallback& callback) OVERRIDE; | 266 const ResultCallback& callback) OVERRIDE; |
| 252 | 267 |
| 253 private: | 268 private: |
| 254 scoped_refptr<PwgUtilityProcessHostClient> utility_client_; | 269 scoped_refptr<PdfToEmfUtilityProcessHostClient> utility_client_; |
| 255 base::CancelableCallback<ResultCallback::RunType> callback_; | 270 base::CancelableCallback<ResultCallback::RunType> callback_; |
| 256 | 271 |
| 257 DISALLOW_COPY_AND_ASSIGN(PWGRasterConverterImpl); | 272 DISALLOW_COPY_AND_ASSIGN(PdfToEmfConverterImpl); |
| 258 }; | 273 }; |
| 259 | 274 |
| 260 PWGRasterConverterImpl::PWGRasterConverterImpl() { | 275 PdfToEmfConverterImpl::PdfToEmfConverterImpl() { |
| 261 } | 276 } |
| 262 | 277 |
| 263 PWGRasterConverterImpl::~PWGRasterConverterImpl() { | 278 PdfToEmfConverterImpl::~PdfToEmfConverterImpl() { |
| 264 } | 279 } |
| 265 | 280 |
| 266 void PWGRasterConverterImpl::Start( | 281 void PdfToEmfConverterImpl::Start( |
| 267 base::RefCountedMemory* data, | 282 base::RefCountedMemory* data, |
| 268 const printing::PdfRenderSettings& conversion_settings, | 283 const printing::PdfRenderSettings& conversion_settings, |
| 269 const printing::PwgRasterSettings& bitmap_settings, | |
| 270 const ResultCallback& callback) { | 284 const ResultCallback& callback) { |
| 271 // Rebind cancelable callback to avoid calling callback if | 285 // Rebind cancelable callback to avoid calling callback if |
| 272 // PWGRasterConverterImpl is destroyed. | 286 // PdfToEmfConverterImpl is destroyed. |
| 273 callback_.Reset(callback); | 287 callback_.Reset(callback); |
| 274 utility_client_ = | 288 utility_client_ = new PdfToEmfUtilityProcessHostClient(conversion_settings); |
| 275 new PwgUtilityProcessHostClient(conversion_settings, bitmap_settings); | |
| 276 utility_client_->Convert(data, callback_.callback()); | 289 utility_client_->Convert(data, callback_.callback()); |
| 277 } | 290 } |
| 278 | 291 |
| 279 } // namespace | 292 } // namespace |
| 280 | 293 |
| 281 // static | 294 // static |
| 282 scoped_ptr<PWGRasterConverter> PWGRasterConverter::CreateDefault() { | 295 scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() { |
| 283 return scoped_ptr<PWGRasterConverter>(new PWGRasterConverterImpl()); | 296 return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl()); |
| 284 } | 297 } |
| 285 | 298 |
| 286 } // namespace local_discovery | 299 } // namespace printing |
| OLD | NEW |