OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 IOS_CHROME_BROWSER_SUGGESTIONS_IOS_IMAGE_DECODER_IMPL_H_ | 5 #ifndef IOS_CHROME_BROWSER_SUGGESTIONS_IOS_IMAGE_DECODER_IMPL_H_ |
6 #define IOS_CHROME_BROWSER_SUGGESTIONS_IOS_IMAGE_DECODER_IMPL_H_ | 6 #define IOS_CHROME_BROWSER_SUGGESTIONS_IOS_IMAGE_DECODER_IMPL_H_ |
7 | 7 |
8 #include "base/mac/scoped_nsobject.h" | |
8 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/weak_ptr.h" | |
9 #include "components/image_fetcher/image_decoder.h" | 12 #include "components/image_fetcher/image_decoder.h" |
10 | 13 |
14 @class NSData; | |
15 | |
16 namespace base { | |
17 class TaskRunner; | |
18 } | |
19 | |
11 namespace suggestions { | 20 namespace suggestions { |
12 | 21 |
13 class IOSImageDecoderImpl : public image_fetcher::ImageDecoder { | 22 class IOSImageDecoderImpl : public image_fetcher::ImageDecoder { |
14 public: | 23 public: |
15 IOSImageDecoderImpl(); | 24 explicit IOSImageDecoderImpl( |
25 const scoped_refptr<base::TaskRunner>& task_runner); | |
16 ~IOSImageDecoderImpl() override; | 26 ~IOSImageDecoderImpl() override; |
17 | 27 |
18 void DecodeImage( | 28 void DecodeImage( |
19 const std::string& image_data, | 29 const std::string& image_data, |
20 const image_fetcher::ImageDecodedCallback& callback) override; | 30 const image_fetcher::ImageDecodedCallback& callback) override; |
21 | 31 |
22 private: | 32 private: |
33 void CreateUIImageAndRunCallback( | |
34 const image_fetcher::ImageDecodedCallback& callback, | |
35 base::scoped_nsobject<NSData> data); | |
noyau (Ping after 24h)
2016/09/09 10:18:04
This private use scoped_nsobject has the unfortuna
vitaliii
2016/09/09 13:03:41
No, I have not, but that is a great idea (though q
| |
36 | |
37 // The task runner used to decode images if necessary. | |
38 const scoped_refptr<base::TaskRunner> task_runner_; | |
39 | |
40 // The WeakPtrFactory is used to cancel callbacks if ImageFetcher is destroyed | |
41 // during WebP decoding. | |
42 base::WeakPtrFactory<IOSImageDecoderImpl> weak_factory_; | |
43 | |
23 DISALLOW_COPY_AND_ASSIGN(IOSImageDecoderImpl); | 44 DISALLOW_COPY_AND_ASSIGN(IOSImageDecoderImpl); |
24 }; | 45 }; |
25 | 46 |
26 } // namespace suggestions | 47 } // namespace suggestions |
27 | 48 |
28 #endif // IOS_CHROME_BROWSER_SUGGESTIONS_IOS_IMAGE_DECODER_IMPL_H_ | 49 #endif // IOS_CHROME_BROWSER_SUGGESTIONS_IOS_IMAGE_DECODER_IMPL_H_ |
OLD | NEW |