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 #include "ios/chrome/browser/suggestions/ios_image_decoder_impl.h" | 5 #include "ios/chrome/browser/suggestions/ios_image_decoder_impl.h" |
6 | 6 |
7 #include <UIKit/UIKit.h> | 7 #include <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 const image_fetcher::ImageDecodedCallback& callback, | 141 const image_fetcher::ImageDecodedCallback& callback, |
142 const base::scoped_nsobject<NSData>& image_data) { | 142 const base::scoped_nsobject<NSData>& image_data) { |
143 // Decode the image data using UIImage. | 143 // Decode the image data using UIImage. |
144 if (image_data) { | 144 if (image_data) { |
145 // "Most likely" always returns 1x images. | 145 // "Most likely" always returns 1x images. |
146 UIImage* ui_image = [UIImage imageWithData:image_data scale:1]; | 146 UIImage* ui_image = [UIImage imageWithData:image_data scale:1]; |
147 if (ui_image) { | 147 if (ui_image) { |
148 // This constructor does not retain the image, but expects to take the | 148 // This constructor does not retain the image, but expects to take the |
149 // ownership, therefore, |ui_image| is retained here, but not released | 149 // ownership, therefore, |ui_image| is retained here, but not released |
150 // afterwards. | 150 // afterwards. |
151 gfx::Image gfx_image([ui_image retain]); | 151 gfx::Image gfx_image(ui_image, base::scoped_policy::RETAIN); |
152 callback.Run(gfx_image); | 152 callback.Run(gfx_image); |
153 return; | 153 return; |
154 } | 154 } |
155 } | 155 } |
156 gfx::Image empty_image; | 156 gfx::Image empty_image; |
157 callback.Run(empty_image); | 157 callback.Run(empty_image); |
158 } | 158 } |
159 | 159 |
160 std::unique_ptr<image_fetcher::ImageDecoder> CreateIOSImageDecoder( | 160 std::unique_ptr<image_fetcher::ImageDecoder> CreateIOSImageDecoder( |
161 scoped_refptr<base::TaskRunner> task_runner) { | 161 scoped_refptr<base::TaskRunner> task_runner) { |
162 return base::MakeUnique<IOSImageDecoderImpl>(std::move(task_runner)); | 162 return base::MakeUnique<IOSImageDecoderImpl>(std::move(task_runner)); |
163 } | 163 } |
164 | 164 |
165 } // namespace suggestions | 165 } // namespace suggestions |
OLD | NEW |