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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Starts asynchronous image decoding. Once finished, the callback will be | 46 // Starts asynchronous image decoding. Once finished, the callback will be |
47 // posted back to |task_runner|. | 47 // posted back to |task_runner|. |
48 void Start(scoped_refptr<base::SequencedTaskRunner> task_runner); | 48 void Start(scoped_refptr<base::SequencedTaskRunner> task_runner); |
49 | 49 |
50 const std::vector<unsigned char>& get_image_data() const { | 50 const std::vector<unsigned char>& get_image_data() const { |
51 return image_data_; | 51 return image_data_; |
52 } | 52 } |
53 | 53 |
54 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 54 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
55 void set_shrink_to_fit(bool shrink_to_fit) { shrink_to_fit_ = shrink_to_fit; } | |
56 | 55 |
57 private: | 56 private: |
58 // It's a reference counted object, so destructor is private. | 57 // It's a reference counted object, so destructor is private. |
59 virtual ~ImageDecoder(); | 58 virtual ~ImageDecoder(); |
60 | 59 |
61 // Overidden from UtilityProcessHostClient: | 60 // Overidden from UtilityProcessHostClient: |
62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
63 | 62 |
64 // IPC message handlers. | 63 // IPC message handlers. |
65 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); | 64 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); |
66 void OnDecodeImageFailed(); | 65 void OnDecodeImageFailed(); |
67 | 66 |
68 // Launches sandboxed process that will decode the image. | 67 // Launches sandboxed process that will decode the image. |
69 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); | 68 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); |
70 | 69 |
71 Delegate* delegate_; | 70 Delegate* delegate_; |
72 std::vector<unsigned char> image_data_; | 71 std::vector<unsigned char> image_data_; |
73 const ImageCodec image_codec_; | 72 const ImageCodec image_codec_; |
74 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 73 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
75 bool shrink_to_fit_; // if needed for IPC msg size limit | |
76 | 74 |
77 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); | 75 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); |
78 }; | 76 }; |
79 | 77 |
80 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ | 78 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ |
OLD | NEW |