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

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

Issue 11968044: Fix login visual hitch on chromebook (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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
« no previous file with comments | « chrome/browser/image_decoder.h ('k') | chrome/browser/profiles/profile_downloader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "content/public/browser/utility_process_host.h" 11 #include "content/public/browser/utility_process_host.h"
12 12
13 using content::BrowserThread; 13 using content::BrowserThread;
14 using content::UtilityProcessHost; 14 using content::UtilityProcessHost;
15 15
16 ImageDecoder::ImageDecoder(Delegate* delegate, 16 ImageDecoder::ImageDecoder(Delegate* delegate,
17 const std::string& image_data, 17 const std::string& image_data,
18 ImageCodec image_codec) 18 ImageCodec image_codec)
19 : delegate_(delegate), 19 : delegate_(delegate),
20 image_data_(image_data.begin(), image_data.end()), 20 image_data_(image_data.begin(), image_data.end()),
21 image_codec_(image_codec), 21 image_codec_(image_codec),
22 target_thread_id_(BrowserThread::UI) { 22 task_runner_(NULL) {
23 } 23 }
24 24
25 ImageDecoder::~ImageDecoder() {} 25 ImageDecoder::~ImageDecoder() {}
26 26
27 void ImageDecoder::Start() { 27 void ImageDecoder::Start(scoped_refptr<base::SequencedTaskRunner> task_runner) {
28 if (!BrowserThread::GetCurrentThreadIdentifier(&target_thread_id_)) { 28 task_runner_ = task_runner;
29 NOTREACHED();
30 return;
31 }
32 BrowserThread::PostTask( 29 BrowserThread::PostTask(
33 BrowserThread::IO, FROM_HERE, 30 BrowserThread::IO, FROM_HERE,
34 base::Bind(&ImageDecoder::DecodeImageInSandbox, this, image_data_)); 31 base::Bind(&ImageDecoder::DecodeImageInSandbox, this, image_data_));
35 } 32 }
36 33
37 bool ImageDecoder::OnMessageReceived(const IPC::Message& message) { 34 bool ImageDecoder::OnMessageReceived(const IPC::Message& message) {
38 bool handled = true; 35 bool handled = true;
39 IPC_BEGIN_MESSAGE_MAP(ImageDecoder, message) 36 IPC_BEGIN_MESSAGE_MAP(ImageDecoder, message)
40 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Succeeded, 37 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Succeeded,
41 OnDecodeImageSucceeded) 38 OnDecodeImageSucceeded)
42 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Failed, 39 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_DecodeImage_Failed,
43 OnDecodeImageFailed) 40 OnDecodeImageFailed)
44 IPC_MESSAGE_UNHANDLED(handled = false) 41 IPC_MESSAGE_UNHANDLED(handled = false)
45 IPC_END_MESSAGE_MAP() 42 IPC_END_MESSAGE_MAP()
46 return handled; 43 return handled;
47 } 44 }
48 45
49 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) { 46 void ImageDecoder::OnDecodeImageSucceeded(const SkBitmap& decoded_image) {
50 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_)); 47 DCHECK(task_runner_->RunsTasksOnCurrentThread());
51 if (delegate_) 48 if (delegate_)
52 delegate_->OnImageDecoded(this, decoded_image); 49 delegate_->OnImageDecoded(this, decoded_image);
53 } 50 }
54 51
55 void ImageDecoder::OnDecodeImageFailed() { 52 void ImageDecoder::OnDecodeImageFailed() {
56 DCHECK(BrowserThread::CurrentlyOn(target_thread_id_)); 53 DCHECK(task_runner_->RunsTasksOnCurrentThread());
57 if (delegate_) 54 if (delegate_)
58 delegate_->OnDecodeImageFailed(this); 55 delegate_->OnDecodeImageFailed(this);
59 } 56 }
60 57
61 void ImageDecoder::DecodeImageInSandbox( 58 void ImageDecoder::DecodeImageInSandbox(
62 const std::vector<unsigned char>& image_data) { 59 const std::vector<unsigned char>& image_data) {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
64 UtilityProcessHost* utility_process_host = UtilityProcessHost::Create( 61 UtilityProcessHost* utility_process_host;
65 this, BrowserThread::GetMessageLoopProxyForThread(target_thread_id_)); 62 utility_process_host = UtilityProcessHost::Create(this, task_runner_.get());
66 utility_process_host->EnableZygote(); 63 utility_process_host->EnableZygote();
67 if (image_codec_ == ROBUST_JPEG_CODEC) { 64 if (image_codec_ == ROBUST_JPEG_CODEC) {
68 utility_process_host->Send( 65 utility_process_host->Send(
69 new ChromeUtilityMsg_RobustJPEGDecodeImage(image_data)); 66 new ChromeUtilityMsg_RobustJPEGDecodeImage(image_data));
70 } else { 67 } else {
71 utility_process_host->Send(new ChromeUtilityMsg_DecodeImage(image_data)); 68 utility_process_host->Send(new ChromeUtilityMsg_DecodeImage(image_data));
72 } 69 }
73 } 70 }
OLDNEW
« no previous file with comments | « chrome/browser/image_decoder.h ('k') | chrome/browser/profiles/profile_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698