| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/local_discovery/pwg_raster_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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void OnSucceeded(); | 120 void OnSucceeded(); |
| 121 void OnFailed(); | 121 void OnFailed(); |
| 122 | 122 |
| 123 void RunCallback(bool success); | 123 void RunCallback(bool success); |
| 124 | 124 |
| 125 void StartProcessOnIOThread(); | 125 void StartProcessOnIOThread(); |
| 126 | 126 |
| 127 void RunCallbackOnUIThread(bool success); | 127 void RunCallbackOnUIThread(bool success); |
| 128 void OnFilesReadyOnUIThread(); | 128 void OnFilesReadyOnUIThread(); |
| 129 | 129 |
| 130 scoped_ptr<FileHandlers> files_; | 130 scoped_ptr<FileHandlers, BrowserThread::DeleteOnFileThread> files_; |
| 131 printing::PdfRenderSettings settings_; | 131 printing::PdfRenderSettings settings_; |
| 132 printing::PwgRasterSettings bitmap_settings_; | 132 printing::PwgRasterSettings bitmap_settings_; |
| 133 PWGRasterConverter::ResultCallback callback_; | 133 PWGRasterConverter::ResultCallback callback_; |
| 134 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; | 134 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
| 135 | 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(PwgUtilityProcessHostClient); | 136 DISALLOW_COPY_AND_ASSIGN(PwgUtilityProcessHostClient); |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 PwgUtilityProcessHostClient::PwgUtilityProcessHostClient( | 139 PwgUtilityProcessHostClient::PwgUtilityProcessHostClient( |
| 140 const printing::PdfRenderSettings& settings, | 140 const printing::PdfRenderSettings& settings, |
| 141 const printing::PwgRasterSettings& bitmap_settings) | 141 const printing::PwgRasterSettings& bitmap_settings) |
| 142 : settings_(settings), bitmap_settings_(bitmap_settings) {} | 142 : settings_(settings), bitmap_settings_(bitmap_settings) {} |
| 143 | 143 |
| 144 PwgUtilityProcessHostClient::~PwgUtilityProcessHostClient() { | 144 PwgUtilityProcessHostClient::~PwgUtilityProcessHostClient() { |
| 145 // Delete temp directory. | |
| 146 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, files_.release()); | |
| 147 } | 145 } |
| 148 | 146 |
| 149 void PwgUtilityProcessHostClient::Convert( | 147 void PwgUtilityProcessHostClient::Convert( |
| 150 base::RefCountedMemory* data, | 148 base::RefCountedMemory* data, |
| 151 const PWGRasterConverter::ResultCallback& callback) { | 149 const PWGRasterConverter::ResultCallback& callback) { |
| 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 153 callback_ = callback; | 151 callback_ = callback; |
| 154 CHECK(!files_); | 152 CHECK(!files_); |
| 155 files_.reset(new FileHandlers()); | 153 files_.reset(new FileHandlers()); |
| 156 BrowserThread::PostTaskAndReply( | 154 BrowserThread::PostTaskAndReply( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 277 } |
| 280 | 278 |
| 281 } // namespace | 279 } // namespace |
| 282 | 280 |
| 283 // static | 281 // static |
| 284 scoped_ptr<PWGRasterConverter> PWGRasterConverter::CreateDefault() { | 282 scoped_ptr<PWGRasterConverter> PWGRasterConverter::CreateDefault() { |
| 285 return scoped_ptr<PWGRasterConverter>(new PWGRasterConverterImpl()); | 283 return scoped_ptr<PWGRasterConverter>(new PWGRasterConverterImpl()); |
| 286 } | 284 } |
| 287 | 285 |
| 288 } // namespace local_discovery | 286 } // namespace local_discovery |
| OLD | NEW |