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_IMAGE_RESOURCE_FETCHER_H_ |
6 #define WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_ | 6 #define WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "webkit/glue/resource_fetcher.h" | 10 #include "webkit/glue/resource_fetcher.h" |
| 11 #include "webkit/glue/webkit_glue_export.h" |
11 | 12 |
12 class SkBitmap; | 13 class SkBitmap; |
13 | 14 |
14 namespace webkit_glue { | 15 namespace webkit_glue { |
15 | 16 |
16 // ImageResourceFetcher handles downloading an image for a webview. Once | 17 // ImageResourceFetcher handles downloading an image for a webview. Once |
17 // downloading is done the supplied callback is notified. ImageResourceFetcher | 18 // downloading is done the supplied callback is notified. ImageResourceFetcher |
18 // is used to download the favicon and images for web apps. | 19 // is used to download the favicon and images for web apps. |
19 class ImageResourceFetcher { | 20 class ImageResourceFetcher { |
20 public: | 21 public: |
21 typedef base::Callback<void(ImageResourceFetcher*, const SkBitmap&)> Callback; | 22 typedef base::Callback<void(ImageResourceFetcher*, const SkBitmap&)> Callback; |
22 | 23 |
23 ImageResourceFetcher(const GURL& image_url, | 24 WEBKIT_GLUE_EXPORT ImageResourceFetcher( |
24 WebKit::WebFrame* frame, | 25 const GURL& image_url, |
25 int id, | 26 WebKit::WebFrame* frame, |
26 int image_size, | 27 int id, |
27 WebKit::WebURLRequest::TargetType target_type, | 28 int image_size, |
28 const Callback& callback); | 29 WebKit::WebURLRequest::TargetType target_type, |
| 30 const Callback& callback); |
29 | 31 |
30 virtual ~ImageResourceFetcher(); | 32 WEBKIT_GLUE_EXPORT virtual ~ImageResourceFetcher(); |
31 | 33 |
32 // URL of the image we're downloading. | 34 // URL of the image we're downloading. |
33 const GURL& image_url() const { return image_url_; } | 35 const GURL& image_url() const { return image_url_; } |
34 | 36 |
35 // Unique identifier for the request. | 37 // Unique identifier for the request. |
36 int id() const { return id_; } | 38 int id() const { return id_; } |
37 | 39 |
38 private: | 40 private: |
39 // ResourceFetcher::Callback. Decodes the image and invokes callback_. | 41 // ResourceFetcher::Callback. Decodes the image and invokes callback_. |
40 void OnURLFetchComplete(const WebKit::WebURLResponse& response, | 42 void OnURLFetchComplete(const WebKit::WebURLResponse& response, |
(...skipping 14 matching lines...) Expand all Loading... |
55 | 57 |
56 // Does the actual download. | 58 // Does the actual download. |
57 scoped_ptr<ResourceFetcher> fetcher_; | 59 scoped_ptr<ResourceFetcher> fetcher_; |
58 | 60 |
59 DISALLOW_COPY_AND_ASSIGN(ImageResourceFetcher); | 61 DISALLOW_COPY_AND_ASSIGN(ImageResourceFetcher); |
60 }; | 62 }; |
61 | 63 |
62 } // namespace webkit_glue | 64 } // namespace webkit_glue |
63 | 65 |
64 #endif // WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_ | 66 #endif // WEBKIT_GLUE_IMAGE_RESOURCE_FETCHER_H_ |
OLD | NEW |