Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / content / renderer / fetchers / image_resource_fetcher.h
blob2edcf3296fc96448c7d191310ebdbadb99e55d30
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_FETCHERS_IMAGE_RESOURCE_FETCHER_H_
6 #define CONTENT_RENDERER_FETCHERS_IMAGE_RESOURCE_FETCHER_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "third_party/WebKit/public/platform/WebURLRequest.h"
12 #include "url/gurl.h"
14 class SkBitmap;
16 namespace blink {
17 class WebFrame;
18 class WebURLResponse;
21 namespace content {
23 class ResourceFetcher;
25 // ImageResourceFetcher handles downloading an image for a webview. Once
26 // downloading is done the supplied callback is notified. ImageResourceFetcher
27 // is used to download the favicon and images for web apps.
28 class ImageResourceFetcher {
29 public:
30 typedef base::Callback<void(ImageResourceFetcher*, const SkBitmap&)> Callback;
32 ImageResourceFetcher(
33 const GURL& image_url,
34 blink::WebFrame* frame,
35 int id,
36 int image_size,
37 blink::WebURLRequest::TargetType target_type,
38 const Callback& callback);
40 virtual ~ImageResourceFetcher();
42 // URL of the image we're downloading.
43 const GURL& image_url() const { return image_url_; }
45 // Unique identifier for the request.
46 int id() const { return id_; }
48 private:
49 // ResourceFetcher::Callback. Decodes the image and invokes callback_.
50 void OnURLFetchComplete(const blink::WebURLResponse& response,
51 const std::string& data);
53 Callback callback_;
55 // Unique identifier for the request.
56 const int id_;
58 // URL of the image.
59 const GURL image_url_;
61 // The size of the image. This is only a hint that is used if the image
62 // contains multiple sizes. A value of 0 results in using the first frame
63 // of the image.
64 const int image_size_;
66 // Does the actual download.
67 scoped_ptr<ResourceFetcher> fetcher_;
69 DISALLOW_COPY_AND_ASSIGN(ImageResourceFetcher);
72 } // namespace content
74 #endif // CONTENT_RENDERER_FETCHERS_IMAGE_RESOURCE_FETCHER_H_