Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ |
| 6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ | 6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 14 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
| 15 #include "components/image_fetcher/image_fetcher.h" | 15 #include "components/image_fetcher/image_fetcher.h" |
| 16 #include "ui/gfx/image/image_skia.h" | |
| 17 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 18 | 17 |
| 18 namespace gfx { | |
| 19 class Image; | |
| 20 } | |
| 21 | |
| 19 namespace net { | 22 namespace net { |
| 20 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
| 21 } | 24 } |
| 22 | 25 |
| 26 | |
|
Marc Treib
2016/05/13 15:53:59
nit: remove the extra empty line
markusheintz_
2016/05/17 13:08:22
Done.
| |
| 23 namespace suggestions { | 27 namespace suggestions { |
| 24 | 28 |
| 25 // A class used to fetch server images. It can be called from any thread and the | 29 // ImageFetcher implementation. |
|
Marc Treib
2016/05/13 15:53:59
nit: I'd specify "image_fetcher::ImageFetcher"
markusheintz_
2016/05/17 13:08:22
Done.
| |
| 26 // callback will be called on the thread which initiated the fetch. | |
| 27 class ImageFetcherImpl : public image_fetcher::ImageFetcher, | 30 class ImageFetcherImpl : public image_fetcher::ImageFetcher, |
| 28 public chrome::BitmapFetcherDelegate { | 31 public chrome::BitmapFetcherDelegate { |
| 29 public: | 32 public: |
| 30 explicit ImageFetcherImpl(net::URLRequestContextGetter* url_request_context); | 33 explicit ImageFetcherImpl(net::URLRequestContextGetter* url_request_context); |
| 31 ~ImageFetcherImpl() override; | 34 ~ImageFetcherImpl() override; |
| 32 | 35 |
| 33 void SetImageFetcherDelegate( | 36 void SetImageFetcherDelegate( |
| 34 image_fetcher::ImageFetcherDelegate* delegate) override; | 37 image_fetcher::ImageFetcherDelegate* delegate) override; |
| 35 | 38 |
| 36 void StartOrQueueNetworkRequest( | 39 void StartOrQueueNetworkRequest( |
| 37 const GURL& url, | 40 const GURL& url, |
| 38 const GURL& image_url, | 41 const GURL& image_url, |
| 39 base::Callback<void(const GURL&, const SkBitmap*)> callback) override; | 42 base::Callback<void(const GURL&, const gfx::Image&)> callback) override; |
| 40 | 43 |
| 41 private: | 44 private: |
| 42 // Inherited from BitmapFetcherDelegate. | 45 // Inherited from BitmapFetcherDelegate. |
| 43 void OnFetchComplete(const GURL& image_url, const SkBitmap* bitmap) override; | 46 void OnFetchComplete(const GURL& image_url, const SkBitmap* bitmap) override; |
| 44 | 47 |
| 45 typedef std::vector<base::Callback<void(const GURL&, const SkBitmap*)> > | 48 typedef std::vector<base::Callback<void(const GURL&, const gfx::Image&)> > |
| 46 CallbackVector; | 49 CallbackVector; |
| 47 | 50 |
| 48 // State related to an image fetch (associated website url, image_url, | 51 // State related to an image fetch (associated website url, image_url, |
| 49 // fetcher, pending callbacks). | 52 // fetcher, pending callbacks). |
| 50 struct ImageRequest { | 53 struct ImageRequest { |
| 51 ImageRequest(); | 54 ImageRequest(); |
| 52 // Struct takes ownership of |f|. | 55 // Struct takes ownership of |f|. |
| 53 explicit ImageRequest(chrome::BitmapFetcher* f); | 56 explicit ImageRequest(chrome::BitmapFetcher* f); |
| 54 ImageRequest(const ImageRequest& other); | 57 ImageRequest(const ImageRequest& other); |
| 55 ~ImageRequest(); | 58 ~ImageRequest(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 78 image_fetcher::ImageFetcherDelegate* delegate_; | 81 image_fetcher::ImageFetcherDelegate* delegate_; |
| 79 | 82 |
| 80 net::URLRequestContextGetter* url_request_context_; | 83 net::URLRequestContextGetter* url_request_context_; |
| 81 | 84 |
| 82 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl); | 85 DISALLOW_COPY_AND_ASSIGN(ImageFetcherImpl); |
| 83 }; | 86 }; |
| 84 | 87 |
| 85 } // namespace suggestions | 88 } // namespace suggestions |
| 86 | 89 |
| 87 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ | 90 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_IMAGE_FETCHER_IMPL_H_ |
| OLD | NEW |