Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: ios/chrome/browser/suggestions/image_fetcher_impl.mm

Issue 2504683002: Adds a new constructor for gfx::Image on iOS. (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/suggestions/ios_image_decoder_impl.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/image_fetcher_impl.h" 5 #include "ios/chrome/browser/suggestions/image_fetcher_impl.h"
6 6
7 #include <UIKit/UIKit.h> 7 #include <UIKit/UIKit.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Copy string reference so it's retained. 54 // Copy string reference so it's retained.
55 const std::string fetch_id(id); 55 const std::string fetch_id(id);
56 // If image_fetcher_ is destroyed the request will be cancelled and this block 56 // If image_fetcher_ is destroyed the request will be cancelled and this block
57 // will never be called. A reference to delegate_ can be kept. 57 // will never be called. A reference to delegate_ can be kept.
58 web::ImageFetchedCallback fetcher_callback = 58 web::ImageFetchedCallback fetcher_callback =
59 ^(const GURL& original_url, int response_code, NSData* data) { 59 ^(const GURL& original_url, int response_code, NSData* data) {
60 if (data) { 60 if (data) {
61 // Most likely always returns 1x images. 61 // Most likely always returns 1x images.
62 UIImage* ui_image = [UIImage imageWithData:data scale:1]; 62 UIImage* ui_image = [UIImage imageWithData:data scale:1];
63 if (ui_image) { 63 if (ui_image) {
64 gfx::Image gfx_image(ui_image); 64 gfx::Image gfx_image(ui_image, base::scoped_policy::ASSUME);
65 callback.Run(fetch_id, gfx_image); 65 callback.Run(fetch_id, gfx_image);
66 if (delegate_) { 66 if (delegate_) {
67 delegate_->OnImageFetched(fetch_id, gfx_image); 67 delegate_->OnImageFetched(fetch_id, gfx_image);
68 } 68 }
69 return; 69 return;
70 } 70 }
71 } 71 }
72 gfx::Image empty_image; 72 gfx::Image empty_image;
73 callback.Run(fetch_id, empty_image); 73 callback.Run(fetch_id, empty_image);
74 if (delegate_) { 74 if (delegate_) {
75 delegate_->OnImageFetched(fetch_id, empty_image); 75 delegate_->OnImageFetched(fetch_id, empty_image);
76 } 76 }
77 }; 77 };
78 image_fetcher_->StartDownload(image_url, fetcher_callback); 78 image_fetcher_->StartDownload(image_url, fetcher_callback);
79 } 79 }
80 80
81 } // namespace suggestions 81 } // namespace suggestions
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/suggestions/ios_image_decoder_impl.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698