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

Side by Side Diff: chrome/browser/gaia_userinfo/image_decoder.cc

Issue 8511064: GAIA Profile info prototype (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/gaia_userinfo/image_decoder.h"
6
7 #include "base/bind.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/common/chrome_utility_messages.h"
10 #include "content/public/browser/browser_thread.h"
11
12 using content::BrowserThread;
13
14 ImageDecoder::ImageDecoder(Delegate* delegate,
15 const std::string& image_data)
16 : delegate_(delegate),
17 image_data_(image_data.begin(), image_data.end()),
18 target_thread_id_(BrowserThread::UI) {
19 }
20
21 ImageDecoder::~ImageDecoder() {}
22
23 void ImageDecoder::Start() {
24 if (!BrowserThread::GetCurrentThreadIdentifier(&target_thread_id_)) {
25 NOTREACHED();
26 return;
27 }
28 BrowserThread::PostTask(
29 BrowserThread::IO, FROM_HERE,
30 base::Bind(&ImageDecoder::DecodeImageInSandbox, this, image_data_));
31 }
32
33 bool ImageDecoder::OnMessageReceived(const IPC::Message& message) {
34 bool handled = true;
35 IPC_BEGIN_MESSAGE_MAP(ImageDecoder, message)
36 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Succeeded,
37 OnDecodeImageSucceeded)
38 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Failed,
39 OnDecodeImageFailed)
40 IPC_MESSAGE_UNHANDLED(handled = false)
41 IPC_END_MESSAGE_MAP_EX()
42 return handled;
43 }
44
45 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) {
46 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_));
47 if (delegate_)
48 delegate_->OnImageDecoded(this, decoded_image);
49 }
50
51 void ImageDecoder::OnDecodeImageFailed() {
52 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_));
53 if (delegate_)
54 delegate_->OnDecodeImageFailed(this);
55 }
56
57 void ImageDecoder::DecodeImageInSandbox(
58 const std::vector<unsigned char>& image_data) {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
60 UtilityProcessHost* utility_process_host =
61 new UtilityProcessHost(this,
62 target_thread_id_);
63 utility_process_host->Send(new ChromeUtilityMsg_DecodeImage(image_data));
64 }
OLDNEW
« no previous file with comments | « chrome/browser/gaia_userinfo/image_decoder.h ('k') | chrome/browser/gaia_userinfo/profile_image_downloader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698