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::TargetType target_type
,
40 const Callback
& callback
);
42 virtual ~MultiResolutionImageResourceFetcher();
44 // URL of the image we're downloading.
45 const GURL
& image_url() const { return image_url_
; }
47 // Unique identifier for the request.
48 int id() const { return id_
; }
50 // HTTP status code upon fetch completion.
51 int http_status_code() const { return http_status_code_
; }
54 // ResourceFetcher::Callback. Decodes the image and invokes callback_.
55 void OnURLFetchComplete(const blink::WebURLResponse
& response
,
56 const std::string
& data
);
60 // Unique identifier for the request.
63 // HTTP status code upon fetch completion.
64 int http_status_code_
;
67 const GURL image_url_
;
69 // Does the actual download.
70 scoped_ptr
<ResourceFetcher
> fetcher_
;
72 DISALLOW_COPY_AND_ASSIGN(MultiResolutionImageResourceFetcher
);
75 } // namespace content
77 #endif // CONTENT_RENDERER_FETCHERS_MULTI_RESOLUTION_IMAGE_RESOURCE_FETCHER_H_