OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/login/image_decoder.h" |
| 6 |
| 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/chrome_thread.h" |
| 9 |
| 10 namespace chromeos { |
| 11 |
| 12 ImageDecoder::ImageDecoder(Delegate* delegate, |
| 13 const std::vector<unsigned char>& image_data) |
| 14 : delegate_(delegate), |
| 15 image_data_(image_data) { |
| 16 } |
| 17 |
| 18 void ImageDecoder::Start() { |
| 19 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 20 ChromeThread::PostTask( |
| 21 ChromeThread::IO, FROM_HERE, |
| 22 NewRunnableMethod( |
| 23 this, &ImageDecoder::DecodeImageInSandbox, |
| 24 g_browser_process->resource_dispatcher_host(), |
| 25 image_data_)); |
| 26 } |
| 27 |
| 28 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) { |
| 29 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 30 if (delegate_) |
| 31 delegate_->OnImageDecoded(decoded_image); |
| 32 } |
| 33 |
| 34 void ImageDecoder::DecodeImageInSandbox( |
| 35 ResourceDispatcherHost* rdh, |
| 36 const std::vector<unsigned char>& image_data) { |
| 37 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 38 UtilityProcessHost* utility_process_host = |
| 39 new UtilityProcessHost(rdh, |
| 40 this, |
| 41 ChromeThread::UI); |
| 42 utility_process_host->StartImageDecoding(image_data); |
| 43 } |
| 44 |
| 45 } // namespace chromeos |
| 46 |
OLD | NEW |