| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 OnDecodeImageFailed) | 41 OnDecodeImageFailed) |
| 42 IPC_MESSAGE_UNHANDLED(handled = false) | 42 IPC_MESSAGE_UNHANDLED(handled = false) |
| 43 IPC_END_MESSAGE_MAP() | 43 IPC_END_MESSAGE_MAP() |
| 44 return handled; | 44 return handled; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) { | 47 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) { |
| 48 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_)); | 48 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_)); |
| 49 if (delegate_) | 49 if (delegate_) |
| 50 delegate_->OnImageDecoded(this, decoded_image); | 50 delegate_->OnImageDecoded(this, decoded_image); |
| 51 Release(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 void ImageDecoder::OnDecodeImageFailed() { | 54 void ImageDecoder::OnDecodeImageFailed() { |
| 54 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_)); | 55 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_)); |
| 55 if (delegate_) | 56 if (delegate_) |
| 56 delegate_->OnDecodeImageFailed(this); | 57 delegate_->OnDecodeImageFailed(this); |
| 58 Release(); |
| 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 utility_process_host->Send(new ChromeUtilityMsg_DecodeImage(image_data)); |
| 66 } | 68 } |
| OLD | NEW |