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

Side by Side Diff: components/image_fetcher/image_fetcher.h

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

Powered by Google App Engine
This is Rietveld 408576698