| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_H_ | |
| 6 #define COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "components/data_use_measurement/core/data_use_user_data.h" | |
| 13 #include "components/image_fetcher/image_fetcher_delegate.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 namespace gfx { | |
| 17 class Image; | |
| 18 class Size; | |
| 19 } | |
| 20 | |
| 21 namespace image_fetcher { | |
| 22 | |
| 23 class ImageDecoder; | |
| 24 | |
| 25 struct RequestMetadata; | |
| 26 | |
| 27 // A class used to fetch server images. It can be called from any thread and the | |
| 28 // callback will be called on the thread which initiated the fetch. | |
| 29 class ImageFetcher { | |
| 30 public: | |
| 31 ImageFetcher() {} | |
| 32 virtual ~ImageFetcher() {} | |
| 33 | |
| 34 using ImageFetcherCallback = | |
| 35 base::Callback<void(const std::string& id, | |
| 36 const gfx::Image& image, | |
| 37 const RequestMetadata& metadata)>; | |
| 38 | |
| 39 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; | |
| 40 | |
| 41 virtual void SetImageFetcherDelegate(ImageFetcherDelegate* delegate) = 0; | |
| 42 | |
| 43 // Sets a service name against which to track data usage. | |
| 44 virtual void SetDataUseServiceName( | |
| 45 DataUseServiceName data_use_service_name) = 0; | |
| 46 | |
| 47 // Sets the desired size for images with multiple frames (like .ico files). | |
| 48 // By default, the image fetcher choses smaller images. Override to choose a | |
| 49 // frame with a size as close as possible to |size| (trying to take one in | |
| 50 // larger size if there's no precise match). Passing gfx::Size() as | |
| 51 // |size| is also supported and will result in chosing the smallest available | |
| 52 // size. | |
| 53 virtual void SetDesiredImageFrameSize(const gfx::Size& size) = 0; | |
| 54 | |
| 55 // An empty gfx::Image will be returned to the callback in case the image | |
| 56 // could not be fetched. | |
| 57 virtual void StartOrQueueNetworkRequest( | |
| 58 const std::string& id, | |
| 59 const GURL& image_url, | |
| 60 const ImageFetcherCallback& callback) = 0; | |
| 61 | |
| 62 virtual ImageDecoder* GetImageDecoder() = 0; | |
| 63 | |
| 64 private: | |
| 65 DISALLOW_COPY_AND_ASSIGN(ImageFetcher); | |
| 66 }; | |
| 67 | |
| 68 } // namespace image_fetcher | |
| 69 | |
| 70 #endif // COMPONENTS_IMAGE_FETCHER_IMAGE_FETCHER_H_ | |
| OLD | NEW |