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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_
6 #define CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "third_party/WebKit/public/platform/WebURLRequest.h"
26 class ResourceFetcher
;
28 // A resource fetcher that returns all (differently-sized) frames in
29 // an image. Useful for favicons.
30 class MultiResolutionImageResourceFetcher
{
32 typedef base::Callback
<void(MultiResolutionImageResourceFetcher
*,
33 const std::vector
<SkBitmap
>&)> Callback
;
35 MultiResolutionImageResourceFetcher(
36 const GURL
& image_url
,
37 blink::WebFrame
* frame
,
39 blink::WebURLRequest::RequestContext request_context
,
40 blink::WebURLRequest::CachePolicy cache_policy
,
41 const Callback
& callback
);
43 virtual ~MultiResolutionImageResourceFetcher();
45 // URL of the image we're downloading.
46 const GURL
& image_url() const { return image_url_
; }
48 // Unique identifier for the request.
49 int id() const { return id_
; }
51 // HTTP status code upon fetch completion.
52 int http_status_code() const { return http_status_code_
; }
55 // ResourceFetcher::Callback. Decodes the image and invokes callback_.
56 void OnURLFetchComplete(const blink::WebURLResponse
& response
,
57 const std::string
& data
);
61 // Unique identifier for the request.
64 // HTTP status code upon fetch completion.
65 int http_status_code_
;
68 const GURL image_url_
;
70 // Does the actual download.
71 scoped_ptr
<ResourceFetcher
> fetcher_
;
73 DISALLOW_COPY_AND_ASSIGN(MultiResolutionImageResourceFetcher
);
76 } // namespace content
78 #endif // CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_