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

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: Feedback 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
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/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "components/image_fetcher/image_fetcher_delegate.h" 10 #include "components/image_fetcher/image_fetcher_delegate.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return; 51 return;
52 } 52 }
53 // Copy string reference so it's retained. 53 // Copy string reference so it's retained.
54 const std::string fetch_id(id); 54 const std::string fetch_id(id);
55 ImageFetchedCallback fetcher_callback = 55 ImageFetchedCallback fetcher_callback =
56 ^(const GURL& original_url, int response_code, NSData* data) { 56 ^(const GURL& original_url, int response_code, NSData* data) {
57 if (data) { 57 if (data) {
58 // Most likely always returns 1x images. 58 // Most likely always returns 1x images.
59 UIImage* ui_image = [UIImage imageWithData:data scale:1]; 59 UIImage* ui_image = [UIImage imageWithData:data scale:1];
60 if (ui_image) { 60 if (ui_image) {
61 gfx::Image gfx_image(ui_image); 61 gfx::Image gfx_image(ui_image, base::scoped_policy::ASSUME);
62 callback.Run(fetch_id, gfx_image); 62 callback.Run(fetch_id, gfx_image);
63 if (delegate_) { 63 if (delegate_) {
64 delegate_->OnImageFetched(fetch_id, gfx_image); 64 delegate_->OnImageFetched(fetch_id, gfx_image);
65 } 65 }
66 return; 66 return;
67 } 67 }
68 } 68 }
69 gfx::Image empty_image; 69 gfx::Image empty_image;
70 callback.Run(fetch_id, empty_image); 70 callback.Run(fetch_id, empty_image);
71 if (delegate_) { 71 if (delegate_) {
72 delegate_->OnImageFetched(fetch_id, empty_image); 72 delegate_->OnImageFetched(fetch_id, empty_image);
73 } 73 }
74 }; 74 };
75 imageFetcher_->StartDownload(image_url, fetcher_callback); 75 imageFetcher_->StartDownload(image_url, fetcher_callback);
76 } 76 }
77 77
78 } // namespace suggestions 78 } // namespace suggestions
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/suggestions/ios_image_decoder_impl.mm » ('j') | ui/gfx/image/image.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698