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

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: Addressed comments round2 treib@ & added missing imports *sigh* 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
« no previous file with comments | « components/image_fetcher/BUILD.gn ('k') | components/image_fetcher/image_fetcher_impl.cc » ('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 #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 <memory>
9 #include <string> 10 #include <string>
10 #include <utility> 11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "components/image_fetcher/image_data_fetcher.h" 16 #include "components/image_fetcher/image_data_fetcher.h"
16 #include "components/image_fetcher/image_decoder.h" 17 #include "components/image_fetcher/image_decoder.h"
17 #include "components/image_fetcher/image_fetcher.h" 18 #include "components/image_fetcher/image_fetcher.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
19 20
20 namespace gfx { 21 namespace gfx {
21 class Image; 22 class Image;
22 } 23 }
23 24
24 namespace net { 25 namespace net {
25 class URLRequestContextGetter; 26 class URLRequestContextGetter;
26 } 27 }
27 28
28 // TODO(markusheintz): Move the ImageFetcherImpl to components/image_fetcher 29 namespace image_fetcher {
29 namespace suggestions {
30 30
31 // image_fetcher::ImageFetcher implementation. 31 // TODO(markusheintz): Once the iOS implementation of the ImageFetcher is
32 // removed merge the two classes ImageFetcher and ImageFetcherImpl.
32 class ImageFetcherImpl : public image_fetcher::ImageFetcher { 33 class ImageFetcherImpl : public image_fetcher::ImageFetcher {
33 public: 34 public:
34 explicit ImageFetcherImpl(net::URLRequestContextGetter* url_request_context); 35 ImageFetcherImpl(
36 std::unique_ptr<ImageDecoder> image_decoder,
37 net::URLRequestContextGetter* url_request_context);
35 ~ImageFetcherImpl() override; 38 ~ImageFetcherImpl() override;
36 39
37 void SetImageFetcherDelegate( 40 // Sets the |delegate| of the ImageFetcherImpl. The |delegate| has to be alive
38 image_fetcher::ImageFetcherDelegate* delegate) override; 41 // during the lifetime of the ImageFetcherImpl object. It is the caller's
42 // responsibility to ensure this.
43 void SetImageFetcherDelegate(ImageFetcherDelegate* delegate) override;
39 44
40 void StartOrQueueNetworkRequest( 45 void StartOrQueueNetworkRequest(
41 const std::string& id, 46 const std::string& id,
42 const GURL& image_url, 47 const GURL& image_url,
43 base::Callback<void(const std::string&, const gfx::Image&)> callback) 48 base::Callback<void(const std::string&, const gfx::Image&)> callback)
44 override; 49 override;
45 50
46 private: 51 private:
47 using CallbackVector = 52 using CallbackVector =
48 std::vector<base::Callback<void(const std::string&, const gfx::Image&)>>; 53 std::vector<base::Callback<void(const std::string&, const gfx::Image&)>>;
(...skipping 19 matching lines...) Expand all
68 73
69 // Processes image URL fetched events. This is the continuation method used 74 // Processes image URL fetched events. This is the continuation method used
70 // for creating callbacks that are passed to the ImageDataFetcher. 75 // for creating callbacks that are passed to the ImageDataFetcher.
71 void OnImageURLFetched(const GURL& image_url, const std::string& image_data); 76 void OnImageURLFetched(const GURL& image_url, const std::string& image_data);
72 77
73 // Processes image decoded events. This is the continuation method used for 78 // Processes image decoded events. This is the continuation method used for
74 // creating callbacks that are passed to the ImageDecoder. 79 // creating callbacks that are passed to the ImageDecoder.
75 void OnImageDecoded(const GURL& image_url, const gfx::Image& image); 80 void OnImageDecoded(const GURL& image_url, const gfx::Image& image);
76 81
77 82
78 image_fetcher::ImageFetcherDelegate* delegate_; 83 ImageFetcherDelegate* delegate_;
79 84
80 net::URLRequestContextGetter* url_request_context_; 85 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
81 86
82 std::unique_ptr<image_fetcher::ImageDecoder> image_decoder_; 87 std::unique_ptr<ImageDecoder> image_decoder_;
83 88
84 std::unique_ptr<image_fetcher::ImageDataFetcher> image_data_fetcher_; 89 std::unique_ptr<ImageDataFetcher> image_data_fetcher_;
85 90
86 // Map from each image URL to the request information (associated website 91 // Map from each image URL to the request information (associated website
87 // url, fetcher, pending callbacks). 92 // url, fetcher, pending callbacks).
88 ImageRequestMap pending_net_requests_; 93 ImageRequestMap pending_net_requests_;
89 94
90 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl); 95 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl);
91 }; 96 };
92 97
93 } // namespace suggestions 98 } // namespace image_fetcher
94 99
95 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ 100 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_
OLDNEW
« no previous file with comments | « components/image_fetcher/BUILD.gn ('k') | components/image_fetcher/image_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698