Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/chromeos/login/image_decoder.cc

Issue 6995095: Move UtilityProcessHost to content and move the message sending/dispatching to the clients. This... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/login/image_decoder.h" 5 #include "chrome/browser/chromeos/login/image_decoder.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/common/chrome_utility_messages.h"
8 #include "content/browser/browser_thread.h" 9 #include "content/browser/browser_thread.h"
9 10
10 namespace chromeos { 11 namespace chromeos {
11 12
12 ImageDecoder::ImageDecoder(Delegate* delegate, 13 ImageDecoder::ImageDecoder(Delegate* delegate,
13 const std::string& image_data) 14 const std::string& image_data)
14 : delegate_(delegate), 15 : delegate_(delegate),
15 image_data_(image_data.begin(), image_data.end()), 16 image_data_(image_data.begin(), image_data.end()),
16 target_thread_id_(BrowserThread::UI) { 17 target_thread_id_(BrowserThread::UI) {
17 } 18 }
18 19
19 ImageDecoder::~ImageDecoder() {} 20 ImageDecoder::~ImageDecoder() {}
20 21
21 void ImageDecoder::Start() { 22 void ImageDecoder::Start() {
22 if (!BrowserThread::GetCurrentThreadIdentifier(&target_thread_id_)) { 23 if (!BrowserThread::GetCurrentThreadIdentifier(&target_thread_id_)) {
23 NOTREACHED(); 24 NOTREACHED();
24 return; 25 return;
25 } 26 }
26 BrowserThread::PostTask( 27 BrowserThread::PostTask(
27 BrowserThread::IO, FROM_HERE, 28 BrowserThread::IO, FROM_HERE,
28 NewRunnableMethod( 29 NewRunnableMethod(
29 this, &ImageDecoder::DecodeImageInSandbox, 30 this, &ImageDecoder::DecodeImageInSandbox,
30 image_data_)); 31 image_data_));
31 } 32 }
32 33
34 bool ImageDecoder::OnMessageReceived(const IPC::Message& message) {
35 bool handled = true;
36 IPC_BEGIN_MESSAGE_MAP(ImageDecoder, message)
37 IPC_MESSAGE_HANDLER(UtilityHostMsg_DecodeImage_Succeeded,
38 OnDecodeImageSucceeded)
39 IPC_MESSAGE_HANDLER(UtilityHostMsg_DecodeImage_Failed, OnDecodeImageFailed)
40 IPC_MESSAGE_UNHANDLED(handled = false)
41 IPC_END_MESSAGE_MAP_EX()
42 return handled;
43 }
44
33 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) { 45 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) {
34 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_)); 46 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_));
35 if (delegate_) 47 if (delegate_)
36 delegate_->OnImageDecoded(this, decoded_image); 48 delegate_->OnImageDecoded(this, decoded_image);
37 } 49 }
38 50
39 void ImageDecoder::OnDecodeImageFailed() { 51 void ImageDecoder::OnDecodeImageFailed() {
40 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_)); 52 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_));
41 if (delegate_) 53 if (delegate_)
42 delegate_->OnDecodeImageFailed(this); 54 delegate_->OnDecodeImageFailed(this);
43 } 55 }
44 56
45 void ImageDecoder::DecodeImageInSandbox( 57 void ImageDecoder::DecodeImageInSandbox(
46 const std::vector<unsigned char>& image_data) { 58 const std::vector<unsigned char>& image_data) {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
48 UtilityProcessHost* utility_process_host = 60 UtilityProcessHost* utility_process_host =
49 new UtilityProcessHost(this, 61 new UtilityProcessHost(this,
50 target_thread_id_); 62 target_thread_id_);
51 utility_process_host->StartImageDecoding(image_data); 63 utility_process_host->Send(new UtilityMsg_DecodeImage(image_data));
52 } 64 }
53 65
54 } // namespace chromeos 66 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698