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

Side by Side Diff: components/image_fetcher/image_fetcher_impl.h

Issue 2715153006: Set desired_image_size when decoding images for NTP Tile icons. (Closed)
Patch Set: ax Created 3 years, 9 months 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 #ifndef COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_ 5 #ifndef COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_
6 #define COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_ 6 #define COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "components/image_fetcher/image_data_fetcher.h" 16 #include "components/image_fetcher/image_data_fetcher.h"
17 #include "components/image_fetcher/image_decoder.h" 17 #include "components/image_fetcher/image_decoder.h"
18 #include "components/image_fetcher/image_fetcher.h" 18 #include "components/image_fetcher/image_fetcher.h"
19 #include "ui/gfx/geometry/size.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace gfx { 22 namespace gfx {
22 class Image; 23 class Image;
23 } 24 }
24 25
25 namespace net { 26 namespace net {
26 class URLRequestContextGetter; 27 class URLRequestContextGetter;
27 } 28 }
28 29
29 namespace image_fetcher { 30 namespace image_fetcher {
30 31
31 // TODO(markusheintz): Once the iOS implementation of the ImageFetcher is 32 // TODO(markusheintz): Once the iOS implementation of the ImageFetcher is
32 // removed merge the two classes ImageFetcher and ImageFetcherImpl. 33 // removed merge the two classes ImageFetcher and ImageFetcherImpl.
33 class ImageFetcherImpl : public image_fetcher::ImageFetcher { 34 class ImageFetcherImpl : public image_fetcher::ImageFetcher {
34 public: 35 public:
35 ImageFetcherImpl( 36 ImageFetcherImpl(
36 std::unique_ptr<ImageDecoder> image_decoder, 37 std::unique_ptr<ImageDecoder> image_decoder,
37 net::URLRequestContextGetter* url_request_context); 38 net::URLRequestContextGetter* url_request_context);
38 ~ImageFetcherImpl() override; 39 ~ImageFetcherImpl() override;
39 40
40 // Sets the |delegate| of the ImageFetcherImpl. The |delegate| has to be alive 41 // Sets the |delegate| of the ImageFetcherImpl. The |delegate| has to be alive
41 // during the lifetime of the ImageFetcherImpl object. It is the caller's 42 // during the lifetime of the ImageFetcherImpl object. It is the caller's
42 // responsibility to ensure this. 43 // responsibility to ensure this.
43 void SetImageFetcherDelegate(ImageFetcherDelegate* delegate) override; 44 void SetImageFetcherDelegate(ImageFetcherDelegate* delegate) override;
44 45
45 // Sets a service name against which to track data usage. 46 // Sets a service name against which to track data usage.
46 void SetDataUseServiceName(DataUseServiceName data_use_service_name) override; 47 void SetDataUseServiceName(DataUseServiceName data_use_service_name) override;
47 48
49 // Sets the desired size for images with multiple frames (like .ico files).
50 void SetDesiredImageFrameSize(const gfx::Size& size) override;
51
48 void StartOrQueueNetworkRequest( 52 void StartOrQueueNetworkRequest(
49 const std::string& id, 53 const std::string& id,
50 const GURL& image_url, 54 const GURL& image_url,
51 base::Callback<void(const std::string&, const gfx::Image&)> callback) 55 base::Callback<void(const std::string&, const gfx::Image&)> callback)
52 override; 56 override;
53 57
54 private: 58 private:
55 using CallbackVector = 59 using CallbackVector =
56 std::vector<base::Callback<void(const std::string&, const gfx::Image&)>>; 60 std::vector<base::Callback<void(const std::string&, const gfx::Image&)>>;
57 61
(...skipping 17 matching lines...) Expand all
75 using ImageRequestMap = std::map<const GURL, ImageRequest>; 79 using ImageRequestMap = std::map<const GURL, ImageRequest>;
76 80
77 // Processes image URL fetched events. This is the continuation method used 81 // Processes image URL fetched events. This is the continuation method used
78 // for creating callbacks that are passed to the ImageDataFetcher. 82 // for creating callbacks that are passed to the ImageDataFetcher.
79 void OnImageURLFetched(const GURL& image_url, const std::string& image_data); 83 void OnImageURLFetched(const GURL& image_url, const std::string& image_data);
80 84
81 // Processes image decoded events. This is the continuation method used for 85 // Processes image decoded events. This is the continuation method used for
82 // creating callbacks that are passed to the ImageDecoder. 86 // creating callbacks that are passed to the ImageDecoder.
83 void OnImageDecoded(const GURL& image_url, const gfx::Image& image); 87 void OnImageDecoded(const GURL& image_url, const gfx::Image& image);
84 88
89 ImageFetcherDelegate* delegate_;
85 90
86 ImageFetcherDelegate* delegate_; 91 gfx::Size desired_image_frame_size_;
87 92
88 scoped_refptr<net::URLRequestContextGetter> url_request_context_; 93 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
89 94
90 std::unique_ptr<ImageDecoder> image_decoder_; 95 std::unique_ptr<ImageDecoder> image_decoder_;
91 96
92 std::unique_ptr<ImageDataFetcher> image_data_fetcher_; 97 std::unique_ptr<ImageDataFetcher> image_data_fetcher_;
93 98
94 // Map from each image URL to the request information (associated website 99 // Map from each image URL to the request information (associated website
95 // url, fetcher, pending callbacks). 100 // url, fetcher, pending callbacks).
96 ImageRequestMap pending_net_requests_; 101 ImageRequestMap pending_net_requests_;
97 102
98 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl); 103 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl);
99 }; 104 };
100 105
101 } // namespace image_fetcher 106 } // namespace image_fetcher
102 107
103 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_ 108 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698