| 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 #include "services/image_decoder/public/interfaces/image_decoder.mojom.h" |
| 15 | 16 |
| 16 class SkBitmap; | 17 class SkBitmap; |
| 17 | 18 |
| 18 // Decodes an image in a sandboxed process. | 19 // Decodes an image in a sandboxed process. |
| 19 class ImageDecoder : public content::UtilityProcessHostClient { | 20 class ImageDecoder : public content::UtilityProcessHostClient { |
| 20 public: | 21 public: |
| 21 class Delegate { | 22 class Delegate { |
| 22 public: | 23 public: |
| 23 // Called when image is decoded. | 24 // Called when image is decoded. |
| 24 // |decoder| is used to identify the image in case of decoding several | 25 // |decoder| is used to identify the image in case of decoding several |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Overidden from UtilityProcessHostClient: | 66 // Overidden from UtilityProcessHostClient: |
| 66 bool OnMessageReceived(const IPC::Message& message) override; | 67 bool OnMessageReceived(const IPC::Message& message) override; |
| 67 | 68 |
| 68 // IPC message handlers. | 69 // IPC message handlers. |
| 69 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); | 70 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); |
| 70 void OnDecodeImageFailed(); | 71 void OnDecodeImageFailed(); |
| 71 | 72 |
| 72 // Launches sandboxed process that will decode the image. | 73 // Launches sandboxed process that will decode the image. |
| 73 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); | 74 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); |
| 74 | 75 |
| 76 // Mojo RPC callback. |
| 77 void OnDecodeImageDone(bool success, services::image_decoder::ImagePtr image); |
| 78 |
| 75 Delegate* delegate_; | 79 Delegate* delegate_; |
| 76 std::vector<unsigned char> image_data_; | 80 std::vector<unsigned char> image_data_; |
| 77 const ImageCodec image_codec_; | 81 const ImageCodec image_codec_; |
| 78 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 82 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 79 bool shrink_to_fit_; // if needed for IPC msg size limit | 83 bool shrink_to_fit_; // if needed for IPC msg size limit |
| 84 services::image_decoder::ImageDecoderPtr decoder_; |
| 80 | 85 |
| 81 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); | 86 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); |
| 82 }; | 87 }; |
| 83 | 88 |
| 84 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ | 89 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ |
| OLD | NEW |