OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_ | 5 #ifndef WEBKIT_GLUE_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ |
6 #define WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_ | 6 #define WEBKIT_GLUE_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ |
7 | |
8 #include <vector> | |
7 | 9 |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "webkit/glue/resource_fetcher.h" | 12 #include "webkit/glue/resource_fetcher.h" |
11 #include "webkit/glue/webkit_glue_export.h" | 13 #include "webkit/glue/webkit_glue_export.h" |
12 | 14 |
13 class SkBitmap; | 15 class SkBitmap; |
14 | 16 |
15 namespace webkit_glue { | 17 namespace webkit_glue { |
16 | 18 |
17 // ImageResourceFetcher handles downloading an image for a webview. Once | 19 // A resource fetcher that returns all (differently-sized) frames in |
18 // downloading is done the supplied callback is notified. ImageResourceFetcher | 20 // an image. Useful for favicons. |
19 // is used to download the favicon and images for web apps. | 21 class MultiResolutionImageResourceFetcher{ |
Nico
2012/08/03 22:37:15
This is fairly similar to ImageResourceFetcher, bu
| |
20 class ImageResourceFetcher { | |
21 public: | 22 public: |
22 typedef base::Callback<void(ImageResourceFetcher*, const SkBitmap&)> Callback; | 23 typedef base::Callback<void(MultiResolutionImageResourceFetcher*, |
24 const std::vector<SkBitmap>&)> Callback; | |
23 | 25 |
24 WEBKIT_GLUE_EXPORT ImageResourceFetcher( | 26 WEBKIT_GLUE_EXPORT MultiResolutionImageResourceFetcher( |
25 const GURL& image_url, | 27 const GURL& image_url, |
26 WebKit::WebFrame* frame, | 28 WebKit::WebFrame* frame, |
27 int id, | 29 int id, |
28 int image_size, | |
29 WebKit::WebURLRequest::TargetType target_type, | 30 WebKit::WebURLRequest::TargetType target_type, |
30 const Callback& callback); | 31 const Callback& callback); |
31 | 32 |
32 WEBKIT_GLUE_EXPORT virtual ~ImageResourceFetcher(); | 33 WEBKIT_GLUE_EXPORT virtual ~MultiResolutionImageResourceFetcher(); |
33 | 34 |
34 // URL of the image we're downloading. | 35 // URL of the image we're downloading. |
35 const GURL& image_url() const { return image_url_; } | 36 const GURL& image_url() const { return image_url_; } |
36 | 37 |
37 // Unique identifier for the request. | 38 // Unique identifier for the request. |
38 int id() const { return id_; } | 39 int id() const { return id_; } |
39 | 40 |
40 private: | 41 private: |
41 // ResourceFetcher::Callback. Decodes the image and invokes callback_. | 42 // ResourceFetcher::Callback. Decodes the image and invokes callback_. |
42 void OnURLFetchComplete(const WebKit::WebURLResponse& response, | 43 void OnURLFetchComplete(const WebKit::WebURLResponse& response, |
43 const std::string& data); | 44 const std::string& data); |
44 | 45 |
45 Callback callback_; | 46 Callback callback_; |
46 | 47 |
47 // Unique identifier for the request. | 48 // Unique identifier for the request. |
48 const int id_; | 49 const int id_; |
49 | 50 |
50 // URL of the image. | 51 // URL of the image. |
51 const GURL image_url_; | 52 const GURL image_url_; |
52 | 53 |
53 // The size of the image. This is only a hint that is used if the image | |
54 // contains multiple sizes. A value of 0 results in using the first frame | |
55 // of the image. | |
56 const int image_size_; | |
57 | |
58 // Does the actual download. | 54 // Does the actual download. |
59 scoped_ptr<ResourceFetcher> fetcher_; | 55 scoped_ptr<ResourceFetcher> fetcher_; |
60 | 56 |
61 DISALLOW_COPY_AND_ASSIGN(ImageResourceFetcher); | 57 DISALLOW_COPY_AND_ASSIGN(MultiResolutionImageResourceFetcher); |
62 }; | 58 }; |
63 | 59 |
64 } // namespace webkit_glue | 60 } // namespace webkit_glue |
65 | 61 |
66 #endif // WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_ | 62 #endif // WEBKIT_GLUE_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ |
OLD | NEW |