| 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 #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 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 enum ImageCodec { | 36 enum ImageCodec { |
| 37 DEFAULT_CODEC = 0, // Uses WebKit image decoding (via WebImage). | 37 DEFAULT_CODEC = 0, // Uses WebKit image decoding (via WebImage). |
| 38 ROBUST_JPEG_CODEC, // Restrict decoding to robust jpeg codec. | 38 ROBUST_JPEG_CODEC, // Restrict decoding to robust jpeg codec. |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 ImageDecoder(Delegate* delegate, | 41 ImageDecoder(Delegate* delegate, |
| 42 const std::string& image_data, | 42 const std::string& image_data, |
| 43 ImageCodec image_codec); | 43 ImageCodec image_codec); |
| 44 | 44 |
| 45 // Starts image decoding. | 45 // Starts image decoding on well-known threads. |
| 46 void Start(); | 46 void Start(); |
| 47 | 47 |
| 48 // Starts image decoding on a sequence worker thread with a sequence token |
| 49 // associated with |sequence_token_name|. |
| 50 void Start(std::string sequence_token_name); |
| 51 |
| 48 const std::vector<unsigned char>& get_image_data() const { | 52 const std::vector<unsigned char>& get_image_data() const { |
| 49 return image_data_; | 53 return image_data_; |
| 50 } | 54 } |
| 51 | 55 |
| 52 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 56 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
| 53 | 57 |
| 54 private: | 58 private: |
| 55 // It's a reference counted object, so destructor is private. | 59 // It's a reference counted object, so destructor is private. |
| 56 virtual ~ImageDecoder(); | 60 virtual ~ImageDecoder(); |
| 57 | 61 |
| 58 // Overidden from UtilityProcessHostClient: | 62 // Overidden from UtilityProcessHostClient: |
| 59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 60 | 64 |
| 65 // True if on valid thread or named worker thread associated with |
| 66 // |sequence_token_name_|. |
| 67 bool CalledOnValidThreadOrWorkerThread(); |
| 68 |
| 61 // IPC message handlers. | 69 // IPC message handlers. |
| 62 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); | 70 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); |
| 63 void OnDecodeImageFailed(); | 71 void OnDecodeImageFailed(); |
| 64 | 72 |
| 65 // Launches sandboxed process that will decode the image. | 73 // Launches sandboxed process that will decode the image. |
| 66 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); | 74 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); |
| 67 | 75 |
| 68 Delegate* delegate_; | 76 Delegate* delegate_; |
| 69 std::vector<unsigned char> image_data_; | 77 std::vector<unsigned char> image_data_; |
| 70 const ImageCodec image_codec_; | 78 const ImageCodec image_codec_; |
| 71 content::BrowserThread::ID target_thread_id_; | 79 content::BrowserThread::ID target_thread_id_; |
| 80 std::string sequence_token_name_; |
| 72 | 81 |
| 73 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); | 82 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); |
| 74 }; | 83 }; |
| 75 | 84 |
| 76 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ | 85 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ |
| OLD | NEW |