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 COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_FETCHER_H_ | 5 #ifndef COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_FETCHER_H_ |
6 #define COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_FETCHER_H_ | 6 #define COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/optional.h" |
12 #include "components/data_use_measurement/core/data_use_user_data.h" | 13 #include "components/data_use_measurement/core/data_use_user_data.h" |
13 #include "components/image_fetcher/core/image_fetcher_delegate.h" | 14 #include "components/image_fetcher/core/image_fetcher_delegate.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 class Image; | 18 class Image; |
18 class Size; | 19 class Size; |
19 } | 20 } |
20 | 21 |
21 namespace image_fetcher { | 22 namespace image_fetcher { |
(...skipping 15 matching lines...) Expand all Loading... |
37 const RequestMetadata& metadata)>; | 38 const RequestMetadata& metadata)>; |
38 | 39 |
39 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; | 40 using DataUseServiceName = data_use_measurement::DataUseUserData::ServiceName; |
40 | 41 |
41 virtual void SetImageFetcherDelegate(ImageFetcherDelegate* delegate) = 0; | 42 virtual void SetImageFetcherDelegate(ImageFetcherDelegate* delegate) = 0; |
42 | 43 |
43 // Sets a service name against which to track data usage. | 44 // Sets a service name against which to track data usage. |
44 virtual void SetDataUseServiceName( | 45 virtual void SetDataUseServiceName( |
45 DataUseServiceName data_use_service_name) = 0; | 46 DataUseServiceName data_use_service_name) = 0; |
46 | 47 |
| 48 // Sets an upper limit for image downloads that is by default disabled. |
| 49 // Setting |max_download_bytes| to a negative value will disable the limit. |
| 50 // Already running downloads are immediately affected. |
| 51 virtual void SetImageDownloadLimit( |
| 52 base::Optional<int64_t> max_download_bytes) = 0; |
| 53 |
47 // Sets the desired size for images with multiple frames (like .ico files). | 54 // 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 | 55 // 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 | 56 // 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 | 57 // 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 | 58 // |size| is also supported and will result in chosing the smallest available |
52 // size. | 59 // size. |
53 virtual void SetDesiredImageFrameSize(const gfx::Size& size) = 0; | 60 virtual void SetDesiredImageFrameSize(const gfx::Size& size) = 0; |
54 | 61 |
55 // An empty gfx::Image will be returned to the callback in case the image | 62 // An empty gfx::Image will be returned to the callback in case the image |
56 // could not be fetched. | 63 // could not be fetched. |
57 virtual void StartOrQueueNetworkRequest( | 64 virtual void StartOrQueueNetworkRequest( |
58 const std::string& id, | 65 const std::string& id, |
59 const GURL& image_url, | 66 const GURL& image_url, |
60 const ImageFetcherCallback& callback) = 0; | 67 const ImageFetcherCallback& callback) = 0; |
61 | 68 |
62 virtual ImageDecoder* GetImageDecoder() = 0; | 69 virtual ImageDecoder* GetImageDecoder() = 0; |
63 | 70 |
64 private: | 71 private: |
65 DISALLOW_COPY_AND_ASSIGN(ImageFetcher); | 72 DISALLOW_COPY_AND_ASSIGN(ImageFetcher); |
66 }; | 73 }; |
67 | 74 |
68 } // namespace image_fetcher | 75 } // namespace image_fetcher |
69 | 76 |
70 #endif // COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_FETCHER_H_ | 77 #endif // COMPONENTS_IMAGE_FETCHER_CORE_IMAGE_FETCHER_H_ |
OLD | NEW |