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

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 treib@, bauerb@ 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 <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<image_fetcher::ImageDecoder> image_decoder,
37 net::URLRequestContextGetter* url_request_context);
35 ~ImageFetcherImpl() override; 38 ~ImageFetcherImpl() override;
36 39
40 // 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 // responsibility to ensure this.
37 void SetImageFetcherDelegate( 43 void SetImageFetcherDelegate(
38 image_fetcher::ImageFetcherDelegate* delegate) override; 44 image_fetcher::ImageFetcherDelegate* delegate) override;
39 45
40 void StartOrQueueNetworkRequest( 46 void StartOrQueueNetworkRequest(
41 const std::string& id, 47 const std::string& id,
42 const GURL& image_url, 48 const GURL& image_url,
43 base::Callback<void(const std::string&, const gfx::Image&)> callback) 49 base::Callback<void(const std::string&, const gfx::Image&)> callback)
44 override; 50 override;
45 51
46 private: 52 private:
(...skipping 23 matching lines...) Expand all
70 // for creating callbacks that are passed to the ImageDataFetcher. 76 // for creating callbacks that are passed to the ImageDataFetcher.
71 void OnImageURLFetched(const GURL& image_url, const std::string& image_data); 77 void OnImageURLFetched(const GURL& image_url, const std::string& image_data);
72 78
73 // Processes image decoded events. This is the continuation method used for 79 // Processes image decoded events. This is the continuation method used for
74 // creating callbacks that are passed to the ImageDecoder. 80 // creating callbacks that are passed to the ImageDecoder.
75 void OnImageDecoded(const GURL& image_url, const gfx::Image& image); 81 void OnImageDecoded(const GURL& image_url, const gfx::Image& image);
76 82
77 83
78 image_fetcher::ImageFetcherDelegate* delegate_; 84 image_fetcher::ImageFetcherDelegate* delegate_;
79 85
80 net::URLRequestContextGetter* url_request_context_; 86 scoped_refptr<net::URLRequestContextGetter> url_request_context_;
81 87
82 std::unique_ptr<image_fetcher::ImageDecoder> image_decoder_; 88 std::unique_ptr<image_fetcher::ImageDecoder> image_decoder_;
83 89
84 std::unique_ptr<image_fetcher::ImageDataFetcher> image_data_fetcher_; 90 std::unique_ptr<image_fetcher::ImageDataFetcher> image_data_fetcher_;
85 91
86 // Map from each image URL to the request information (associated website 92 // Map from each image URL to the request information (associated website
87 // url, fetcher, pending callbacks). 93 // url, fetcher, pending callbacks).
88 ImageRequestMap pending_net_requests_; 94 ImageRequestMap pending_net_requests_;
89 95
90 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl); 96 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl);
91 }; 97 };
92 98
93 } // namespace suggestions 99 } // namespace image_fetcher
94 100
95 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ 101 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698