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

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

Issue 2074153002: Pass the ImageDecoder to the ImageFetcher at creation time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move image_fetcher_impl.* to components/image_fetcher Created 4 years, 5 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 CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ 5 #ifndef COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_
6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ 6 #define COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "components/image_fetcher/image_data_fetcher.h" 15 #include "components/image_fetcher/image_data_fetcher.h"
16 #include "components/image_fetcher/image_decoder.h" 16 #include "components/image_fetcher/image_decoder.h"
17 #include "components/image_fetcher/image_fetcher.h" 17 #include "components/image_fetcher/image_fetcher.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 class Image; 21 class Image;
22 } 22 }
23 23
24 namespace net { 24 namespace net {
25 class URLRequestContextGetter; 25 class URLRequestContextGetter;
26 } 26 }
27 27
28 // TODO(markusheintz): Move the ImageFetcherImpl to components/image_fetcher 28 namespace image_fetcher {
29 namespace suggestions { 29
30 // TODO(markusheintz): Once the iOS implementation of the ImageFetcher is
31 // removed merge the two classes ImageFetcher and ImageFetcherImpl.
30 32
31 // image_fetcher::ImageFetcher implementation. 33 // image_fetcher::ImageFetcher implementation.
Marc Treib 2016/06/29 13:57:33 nit: This comment is a bit redundant now :)
markusheintz_ 2016/06/29 14:36:45 Comment removed
32 class ImageFetcherImpl : public image_fetcher::ImageFetcher { 34 class ImageFetcherImpl : public image_fetcher::ImageFetcher {
33 public: 35 public:
34 explicit ImageFetcherImpl(net::URLRequestContextGetter* url_request_context); 36 ImageFetcherImpl(
37 image_fetcher::ImageDecoder* image_decoder,
Bernhard Bauer 2016/06/29 13:55:58 Pass |image_decoder| as a unique_ptr? For ease of
Marc Treib 2016/06/29 13:57:33 This should be a unique_ptr, since the ImageFetche
markusheintz_ 2016/06/29 14:36:45 Done.
markusheintz_ 2016/06/29 14:36:45 Done.
38 net::URLRequestContextGetter* url_request_context);
35 ~ImageFetcherImpl() override; 39 ~ImageFetcherImpl() override;
36 40
37 void SetImageFetcherDelegate( 41 void SetImageFetcherDelegate(
38 image_fetcher::ImageFetcherDelegate* delegate) override; 42 image_fetcher::ImageFetcherDelegate* delegate) override;
Bernhard Bauer 2016/06/29 13:55:58 Could you add a comment that the |delegate| has to
markusheintz_ 2016/06/29 14:36:45 Done.
39 43
40 void StartOrQueueNetworkRequest( 44 void StartOrQueueNetworkRequest(
41 const std::string& id, 45 const std::string& id,
42 const GURL& image_url, 46 const GURL& image_url,
43 base::Callback<void(const std::string&, const gfx::Image&)> callback) 47 base::Callback<void(const std::string&, const gfx::Image&)> callback)
44 override; 48 override;
45 49
46 private: 50 private:
47 using CallbackVector = 51 using CallbackVector =
48 std::vector<base::Callback<void(const std::string&, const gfx::Image&)>>; 52 std::vector<base::Callback<void(const std::string&, const gfx::Image&)>>;
(...skipping 21 matching lines...) Expand all
70 // for creating callbacks that are passed to the ImageDataFetcher. 74 // for creating callbacks that are passed to the ImageDataFetcher.
71 void OnImageURLFetched(const GURL& image_url, const std::string& image_data); 75 void OnImageURLFetched(const GURL& image_url, const std::string& image_data);
72 76
73 // Processes image decoded events. This is the continuation method used for 77 // Processes image decoded events. This is the continuation method used for
74 // creating callbacks that are passed to the ImageDecoder. 78 // creating callbacks that are passed to the ImageDecoder.
75 void OnImageDecoded(const GURL& image_url, const gfx::Image& image); 79 void OnImageDecoded(const GURL& image_url, const gfx::Image& image);
76 80
77 81
78 image_fetcher::ImageFetcherDelegate* delegate_; 82 image_fetcher::ImageFetcherDelegate* delegate_;
79 83
80 net::URLRequestContextGetter* url_request_context_; 84 net::URLRequestContextGetter* url_request_context_;
Bernhard Bauer 2016/06/29 13:55:58 Should this keep a scoped_refptr?
markusheintz_ 2016/06/29 14:36:46 Done.
81 85
82 std::unique_ptr<image_fetcher::ImageDecoder> image_decoder_; 86 std::unique_ptr<image_fetcher::ImageDecoder> image_decoder_;
83 87
84 std::unique_ptr<image_fetcher::ImageDataFetcher> image_data_fetcher_; 88 std::unique_ptr<image_fetcher::ImageDataFetcher> image_data_fetcher_;
85 89
86 // Map from each image URL to the request information (associated website 90 // Map from each image URL to the request information (associated website
87 // url, fetcher, pending callbacks). 91 // url, fetcher, pending callbacks).
88 ImageRequestMap pending_net_requests_; 92 ImageRequestMap pending_net_requests_;
89 93
90 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl); 94 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl);
91 }; 95 };
92 96
93 } // namespace suggestions 97 } // namespace image_fetcher
94 98
95 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ 99 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698