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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 IPC_BEGIN_MESSAGE_MAP(ImageDecoder, message) | 47 IPC_BEGIN_MESSAGE_MAP(ImageDecoder, message) |
48 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Succeeded, | 48 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Succeeded, |
49 OnDecodeImageSucceeded) | 49 OnDecodeImageSucceeded) |
50 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Failed, | 50 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Failed, |
51 OnDecodeImageFailed) | 51 OnDecodeImageFailed) |
52 IPC_MESSAGE_UNHANDLED(handled = false) | 52 IPC_MESSAGE_UNHANDLED(handled = false) |
53 IPC_END_MESSAGE_MAP() | 53 IPC_END_MESSAGE_MAP() |
54 return handled; | 54 return handled; |
55 } | 55 } |
56 | 56 |
57 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) { | 57 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image, |
| 58 int id) { |
58 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 59 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
59 if (delegate_) | 60 if (delegate_) |
60 delegate_->OnImageDecoded(this, decoded_image); | 61 delegate_->OnImageDecoded(this, decoded_image); |
61 } | 62 } |
62 | 63 |
63 void ImageDecoder::OnDecodeImageFailed() { | 64 void ImageDecoder::OnDecodeImageFailed(int id) { |
64 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 65 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
65 if (delegate_) | 66 if (delegate_) |
66 delegate_->OnDecodeImageFailed(this); | 67 delegate_->OnDecodeImageFailed(this); |
67 } | 68 } |
68 | 69 |
69 void ImageDecoder::DecodeImageInSandbox( | 70 void ImageDecoder::DecodeImageInSandbox( |
70 const std::vector<unsigned char>& image_data) { | 71 const std::vector<unsigned char>& image_data) { |
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
72 UtilityProcessHost* utility_process_host; | 73 UtilityProcessHost* utility_process_host; |
73 utility_process_host = UtilityProcessHost::Create(this, task_runner_.get()); | 74 utility_process_host = UtilityProcessHost::Create(this, task_runner_.get()); |
74 if (image_codec_ == ROBUST_JPEG_CODEC) { | 75 if (image_codec_ == ROBUST_JPEG_CODEC) { |
75 utility_process_host->Send( | 76 utility_process_host->Send( |
76 new ChromeUtilityMsg_RobustJPEGDecodeImage(image_data)); | 77 new ChromeUtilityMsg_RobustJPEGDecodeImage( |
| 78 image_data, chromeutility::DUMMY_IMAGE_DELEGATE_ID)); |
77 } else { | 79 } else { |
78 utility_process_host->Send( | 80 utility_process_host->Send( |
79 new ChromeUtilityMsg_DecodeImage(image_data, shrink_to_fit_)); | 81 new ChromeUtilityMsg_DecodeImage( |
| 82 image_data, shrink_to_fit_, |
| 83 chromeutility::DUMMY_IMAGE_DELEGATE_ID)); |
80 } | 84 } |
81 } | 85 } |
OLD | NEW |