OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/image_decoder.h" | 5 #include "chrome/browser/image_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/common/chrome_utility_messages.h" | 9 #include "chrome/common/chrome_utility_messages.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/utility_process_host.h" | 11 #include "content/public/browser/utility_process_host.h" |
12 | 12 |
13 using content::BrowserThread; | 13 using content::BrowserThread; |
14 using content::UtilityProcessHost; | 14 using content::UtilityProcessHost; |
15 | 15 |
16 ImageDecoder::ImageDecoder(Delegate* delegate, | 16 ImageDecoder::ImageDecoder(Delegate* delegate, |
17 const std::string& image_data) | 17 const std::string& image_data, |
| 18 ImageCodec image_codec) |
18 : delegate_(delegate), | 19 : delegate_(delegate), |
19 image_data_(image_data.begin(), image_data.end()), | 20 image_data_(image_data.begin(), image_data.end()), |
| 21 image_codec_(image_codec), |
20 target_thread_id_(BrowserThread::UI) { | 22 target_thread_id_(BrowserThread::UI) { |
21 } | 23 } |
22 | 24 |
23 ImageDecoder::~ImageDecoder() {} | 25 ImageDecoder::~ImageDecoder() {} |
24 | 26 |
25 void ImageDecoder::Start() { | 27 void ImageDecoder::Start() { |
26 if (!BrowserThread::GetCurrentThreadIdentifier(&target_thread_id_)) { | 28 if (!BrowserThread::GetCurrentThreadIdentifier(&target_thread_id_)) { |
27 NOTREACHED(); | 29 NOTREACHED(); |
28 return; | 30 return; |
29 } | 31 } |
(...skipping 25 matching lines...) Expand all Loading... |
55 if (delegate_) | 57 if (delegate_) |
56 delegate_->OnDecodeImageFailed(this); | 58 delegate_->OnDecodeImageFailed(this); |
57 } | 59 } |
58 | 60 |
59 void ImageDecoder::DecodeImageInSandbox( | 61 void ImageDecoder::DecodeImageInSandbox( |
60 const std::vector<unsigned char>& image_data) { | 62 const std::vector<unsigned char>& image_data) { |
61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
62 UtilityProcessHost* utility_process_host = UtilityProcessHost::Create( | 64 UtilityProcessHost* utility_process_host = UtilityProcessHost::Create( |
63 this, target_thread_id_); | 65 this, target_thread_id_); |
64 utility_process_host->EnableZygote(); | 66 utility_process_host->EnableZygote(); |
65 utility_process_host->Send(new ChromeUtilityMsg_DecodeImage(image_data)); | 67 if (image_codec_ == ONLY_IJG_LIBJPEG_CODEC) { |
| 68 utility_process_host->Send( |
| 69 new ChromeUtilityMsg_DecodeImageWithIJGlibjpeg(image_data)); |
| 70 } else { |
| 71 utility_process_host->Send(new ChromeUtilityMsg_DecodeImage(image_data)); |
| 72 } |
66 } | 73 } |
OLD | NEW |