| 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 ImageCodec image_codec) |
| 19 : delegate_(delegate), | 19 : delegate_(delegate), |
| 20 image_data_(image_data.begin(), image_data.end()), | 20 image_data_(image_data.begin(), image_data.end()), |
| 21 image_codec_(image_codec), | 21 image_codec_(image_codec), |
| 22 task_runner_(NULL), | 22 task_runner_(NULL), |
| 23 shrink_to_fit_(false) { | 23 shrink_to_fit_(false) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 ImageDecoder::ImageDecoder(Delegate* delegate, |
| 27 const std::vector<char>& image_data, |
| 28 ImageCodec image_codec) |
| 29 : delegate_(delegate), |
| 30 image_data_(image_data.begin(), image_data.end()), |
| 31 image_codec_(image_codec), |
| 32 task_runner_(NULL), |
| 33 shrink_to_fit_(false) { |
| 34 } |
| 35 |
| 26 ImageDecoder::~ImageDecoder() {} | 36 ImageDecoder::~ImageDecoder() {} |
| 27 | 37 |
| 28 void ImageDecoder::Start(scoped_refptr<base::SequencedTaskRunner> task_runner) { | 38 void ImageDecoder::Start(scoped_refptr<base::SequencedTaskRunner> task_runner) { |
| 29 task_runner_ = task_runner; | 39 task_runner_ = task_runner; |
| 30 BrowserThread::PostTask( | 40 BrowserThread::PostTask( |
| 31 BrowserThread::IO, FROM_HERE, | 41 BrowserThread::IO, FROM_HERE, |
| 32 base::Bind(&ImageDecoder::DecodeImageInSandbox, this, image_data_)); | 42 base::Bind(&ImageDecoder::DecodeImageInSandbox, this, image_data_)); |
| 33 } | 43 } |
| 34 | 44 |
| 35 bool ImageDecoder::OnMessageReceived(const IPC::Message& message) { | 45 bool ImageDecoder::OnMessageReceived(const IPC::Message& message) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 62 UtilityProcessHost* utility_process_host; | 72 UtilityProcessHost* utility_process_host; |
| 63 utility_process_host = UtilityProcessHost::Create(this, task_runner_.get()); | 73 utility_process_host = UtilityProcessHost::Create(this, task_runner_.get()); |
| 64 if (image_codec_ == ROBUST_JPEG_CODEC) { | 74 if (image_codec_ == ROBUST_JPEG_CODEC) { |
| 65 utility_process_host->Send( | 75 utility_process_host->Send( |
| 66 new ChromeUtilityMsg_RobustJPEGDecodeImage(image_data)); | 76 new ChromeUtilityMsg_RobustJPEGDecodeImage(image_data)); |
| 67 } else { | 77 } else { |
| 68 utility_process_host->Send( | 78 utility_process_host->Send( |
| 69 new ChromeUtilityMsg_DecodeImage(image_data, shrink_to_fit_)); | 79 new ChromeUtilityMsg_DecodeImage(image_data, shrink_to_fit_)); |
| 70 } | 80 } |
| 71 } | 81 } |
| OLD | NEW |