| 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 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 14 #include "content/public/browser/utility_process_host_client.h" | 14 #include "content/public/browser/utility_process_host_client.h" |
| 15 | 15 |
| 16 class SkBitmap; | 16 class SkBitmap; |
| 17 | 17 |
| 18 // Decodes an image in a sandboxed process. | 18 // Decodes an image in a sandboxed process. This class is deprecated and will be |
| 19 // removed once crbug.com/<TODO(twellington): fill this in once deprecation is |
| 20 // approved and bug is created> is resolved. Use ImageBatchDecoder instead. |
| 19 class ImageDecoder : public content::UtilityProcessHostClient { | 21 class ImageDecoder : public content::UtilityProcessHostClient { |
| 20 public: | 22 public: |
| 21 class Delegate { | 23 class Delegate { |
| 22 public: | 24 public: |
| 23 // Called when image is decoded. | 25 // Called when image is decoded. |
| 24 // |decoder| is used to identify the image in case of decoding several | 26 // |decoder| is used to identify the image in case of decoding several |
| 25 // images simultaneously. | 27 // images simultaneously. |
| 26 virtual void OnImageDecoded(const ImageDecoder* decoder, | 28 virtual void OnImageDecoded(const ImageDecoder* decoder, |
| 27 const SkBitmap& decoded_image) = 0; | 29 const SkBitmap& decoded_image) = 0; |
| 28 | 30 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 59 void set_shrink_to_fit(bool shrink_to_fit) { shrink_to_fit_ = shrink_to_fit; } | 61 void set_shrink_to_fit(bool shrink_to_fit) { shrink_to_fit_ = shrink_to_fit; } |
| 60 | 62 |
| 61 private: | 63 private: |
| 62 // It's a reference counted object, so destructor is private. | 64 // It's a reference counted object, so destructor is private. |
| 63 ~ImageDecoder() override; | 65 ~ImageDecoder() override; |
| 64 | 66 |
| 65 // Overidden from UtilityProcessHostClient: | 67 // Overidden from UtilityProcessHostClient: |
| 66 bool OnMessageReceived(const IPC::Message& message) override; | 68 bool OnMessageReceived(const IPC::Message& message) override; |
| 67 | 69 |
| 68 // IPC message handlers. | 70 // IPC message handlers. |
| 69 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); | 71 void OnDecodeImageSucceeded(const SkBitmap& decoded_image, int id); |
| 70 void OnDecodeImageFailed(); | 72 void OnDecodeImageFailed(int id); |
| 71 | 73 |
| 72 // Launches sandboxed process that will decode the image. | 74 // Launches sandboxed process that will decode the image. |
| 73 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); | 75 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); |
| 74 | 76 |
| 75 Delegate* delegate_; | 77 Delegate* delegate_; |
| 76 std::vector<unsigned char> image_data_; | 78 std::vector<unsigned char> image_data_; |
| 77 const ImageCodec image_codec_; | 79 const ImageCodec image_codec_; |
| 78 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 80 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 79 bool shrink_to_fit_; // if needed for IPC msg size limit | 81 bool shrink_to_fit_; // if needed for IPC msg size limit |
| 80 | 82 |
| 81 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); | 83 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ | 86 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ |
| OLD | NEW |