| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ | 5 #ifndef CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ |
| 6 #define CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ | 6 #define CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "content/renderer/fetchers/resource_fetcher.h" | 12 #include "content/renderer/fetchers/resource_fetcher.h" |
| 13 | 13 |
| 14 class SkBitmap; | 14 class SkBitmap; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // A resource fetcher that returns all (differently-sized) frames in | 18 // A resource fetcher that returns all (differently-sized) frames in |
| 19 // an image. Useful for favicons. | 19 // an image. Useful for favicons. |
| 20 class MultiResolutionImageResourceFetcher{ | 20 class MultiResolutionImageResourceFetcher{ |
| 21 public: | 21 public: |
| 22 typedef base::Callback<void(MultiResolutionImageResourceFetcher*, | 22 typedef base::Callback<void(MultiResolutionImageResourceFetcher*, |
| 23 const std::vector<SkBitmap>&)> Callback; | 23 const std::vector<SkBitmap>&)> Callback; |
| 24 | 24 |
| 25 MultiResolutionImageResourceFetcher( | 25 MultiResolutionImageResourceFetcher( |
| 26 const GURL& image_url, | 26 const GURL& image_url, |
| 27 WebKit::WebFrame* frame, | 27 blink::WebFrame* frame, |
| 28 int id, | 28 int id, |
| 29 WebKit::WebURLRequest::TargetType target_type, | 29 blink::WebURLRequest::TargetType target_type, |
| 30 const Callback& callback); | 30 const Callback& callback); |
| 31 | 31 |
| 32 virtual ~MultiResolutionImageResourceFetcher(); | 32 virtual ~MultiResolutionImageResourceFetcher(); |
| 33 | 33 |
| 34 // URL of the image we're downloading. | 34 // URL of the image we're downloading. |
| 35 const GURL& image_url() const { return image_url_; } | 35 const GURL& image_url() const { return image_url_; } |
| 36 | 36 |
| 37 // Unique identifier for the request. | 37 // Unique identifier for the request. |
| 38 int id() const { return id_; } | 38 int id() const { return id_; } |
| 39 | 39 |
| 40 // HTTP status code upon fetch completion. | 40 // HTTP status code upon fetch completion. |
| 41 int http_status_code() const { return http_status_code_; } | 41 int http_status_code() const { return http_status_code_; } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // ResourceFetcher::Callback. Decodes the image and invokes callback_. | 44 // ResourceFetcher::Callback. Decodes the image and invokes callback_. |
| 45 void OnURLFetchComplete(const WebKit::WebURLResponse& response, | 45 void OnURLFetchComplete(const blink::WebURLResponse& response, |
| 46 const std::string& data); | 46 const std::string& data); |
| 47 | 47 |
| 48 Callback callback_; | 48 Callback callback_; |
| 49 | 49 |
| 50 // Unique identifier for the request. | 50 // Unique identifier for the request. |
| 51 const int id_; | 51 const int id_; |
| 52 | 52 |
| 53 // HTTP status code upon fetch completion. | 53 // HTTP status code upon fetch completion. |
| 54 int http_status_code_; | 54 int http_status_code_; |
| 55 | 55 |
| 56 // URL of the image. | 56 // URL of the image. |
| 57 const GURL image_url_; | 57 const GURL image_url_; |
| 58 | 58 |
| 59 // Does the actual download. | 59 // Does the actual download. |
| 60 scoped_ptr<ResourceFetcher> fetcher_; | 60 scoped_ptr<ResourceFetcher> fetcher_; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(MultiResolutionImageResourceFetcher); | 62 DISALLOW_COPY_AND_ASSIGN(MultiResolutionImageResourceFetcher); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace content | 65 } // namespace content |
| 66 | 66 |
| 67 #endif // CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ | 67 #endif // CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_ |
| OLD | NEW |