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

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

Issue 11968044: Fix login visual hitch on chromebook (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add settings observer and using unnamed sequence thread 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
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 #ifndef CHROME_BROWSER_IMAGE_DECODER_H_ 5 #ifndef CHROME_BROWSER_IMAGE_DECODER_H_
6 #define CHROME_BROWSER_IMAGE_DECODER_H_ 6 #define CHROME_BROWSER_IMAGE_DECODER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/threading/sequenced_worker_pool.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/utility_process_host_client.h" 14 #include "content/public/browser/utility_process_host_client.h"
14 15
15 class SkBitmap; 16 class SkBitmap;
16 17
17 // Decodes an image in a sandboxed process. 18 // Decodes an image in a sandboxed process.
18 class ImageDecoder : public content::UtilityProcessHostClient { 19 class ImageDecoder : public content::UtilityProcessHostClient {
19 public: 20 public:
20 class Delegate { 21 class Delegate {
21 public: 22 public:
(...skipping 13 matching lines...) Expand all
35 36
36 enum ImageCodec { 37 enum ImageCodec {
37 DEFAULT_CODEC = 0, // Uses WebKit image decoding (via WebImage). 38 DEFAULT_CODEC = 0, // Uses WebKit image decoding (via WebImage).
38 ROBUST_JPEG_CODEC, // Restrict decoding to robust jpeg codec. 39 ROBUST_JPEG_CODEC, // Restrict decoding to robust jpeg codec.
39 }; 40 };
40 41
41 ImageDecoder(Delegate* delegate, 42 ImageDecoder(Delegate* delegate,
42 const std::string& image_data, 43 const std::string& image_data,
43 ImageCodec image_codec); 44 ImageCodec image_codec);
44 45
45 // Starts image decoding. 46 // Starts image decoding on well-known threads.
46 void Start(); 47 void Start();
47 48
49 // Starts image decoding on a sequence worker thread with a sequence token
50 // |sequence_token|.
51 void Start(const base::SequencedWorkerPool::SequenceToken& sequence_token);
52
48 const std::vector<unsigned char>& get_image_data() const { 53 const std::vector<unsigned char>& get_image_data() const {
49 return image_data_; 54 return image_data_;
50 } 55 }
51 56
52 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 57 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
53 58
54 private: 59 private:
55 // It's a reference counted object, so destructor is private. 60 // It's a reference counted object, so destructor is private.
56 virtual ~ImageDecoder(); 61 virtual ~ImageDecoder();
57 62
58 // Overidden from UtilityProcessHostClient: 63 // Overidden from UtilityProcessHostClient:
59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 64 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
60 65
66 // True if on valid thread or named worker thread associated with
67 // |sequence_token_name_|.
68 bool CalledOnValidThreadOrWorkerThread();
69
61 // IPC message handlers. 70 // IPC message handlers.
62 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); 71 void OnDecodeImageSucceeded(const SkBitmap& decoded_image);
63 void OnDecodeImageFailed(); 72 void OnDecodeImageFailed();
64 73
65 // Launches sandboxed process that will decode the image. 74 // Launches sandboxed process that will decode the image.
66 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); 75 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data);
67 76
68 Delegate* delegate_; 77 Delegate* delegate_;
69 std::vector<unsigned char> image_data_; 78 std::vector<unsigned char> image_data_;
70 const ImageCodec image_codec_; 79 const ImageCodec image_codec_;
71 content::BrowserThread::ID target_thread_id_; 80 content::BrowserThread::ID target_thread_id_;
81 base::SequencedWorkerPool::SequenceToken sequence_token_;
82 bool decode_on_sequence_worker_thread_;
72 83
73 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); 84 DISALLOW_COPY_AND_ASSIGN(ImageDecoder);
74 }; 85 };
75 86
76 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ 87 #endif // CHROME_BROWSER_IMAGE_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698