OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_BITMAP_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_BITMAP_FETCHER_H_ |
6 #define CHROME_BROWSER_BITMAP_FETCHER_H_ | 6 #define CHROME_BROWSER_BITMAP_FETCHER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/bitmap_fetcher_delegate.h" | 9 #include "chrome/browser/bitmap_fetcher_delegate.h" |
10 #include "chrome/browser/image_decoder.h" | 10 #include "chrome/browser/image_decoder.h" |
| 11 #include "content/public/common/referrer.h" |
11 #include "net/url_request/url_fetcher_delegate.h" | 12 #include "net/url_request/url_fetcher_delegate.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
14 | 15 |
| 16 namespace content { |
| 17 class BrowserContext; |
| 18 } // namespace content |
| 19 |
15 namespace net { | 20 namespace net { |
16 class URLFetcher; | 21 class URLFetcher; |
17 class URLRequestContextGetter; | 22 class URLRequestContextGetter; |
18 } // namespace net | 23 } // namespace net |
19 | 24 |
20 namespace chrome { | 25 namespace chrome { |
21 | 26 |
22 // Asynchrounously fetches an image from the given URL and returns the | 27 // Asynchrounously fetches an image from the given URL and returns the |
23 // decoded Bitmap to the provided BitmapFetcherDelegate. | 28 // decoded Bitmap to the provided BitmapFetcherDelegate. |
24 class BitmapFetcher : public net::URLFetcherDelegate, | 29 class BitmapFetcher : public net::URLFetcherDelegate, |
25 public ImageDecoder::Delegate { | 30 public ImageDecoder::Delegate { |
26 public: | 31 public: |
27 BitmapFetcher(const GURL& url, BitmapFetcherDelegate* delegate); | 32 BitmapFetcher(const GURL& url, BitmapFetcherDelegate* delegate); |
28 virtual ~BitmapFetcher(); | 33 virtual ~BitmapFetcher(); |
29 | 34 |
30 const GURL& url() const { return url_; } | 35 const GURL& url() const { return url_; } |
31 | 36 |
32 // Start fetching the URL with the fetcher. The delegate is notified | 37 // Start fetching the URL with the fetcher. The delegate is notified |
33 // asynchronously when done. Start may be called more than once in some | 38 // asynchronously when done. Start may be called more than once in some |
34 // cases. If so, subsequent starts will be ignored since the operation is | 39 // cases. If so, subsequent starts will be ignored since the operation is |
35 // already in progress. | 40 // already in progress. |
36 void Start(net::URLRequestContextGetter* request_context); | 41 void Start(net::URLRequestContextGetter* request_context); |
37 | 42 |
| 43 void Start(net::URLRequestContextGetter* request_context, |
| 44 const content::Referrer& referrer, |
| 45 int load_flags); |
| 46 |
38 // Methods inherited from URLFetcherDelegate | 47 // Methods inherited from URLFetcherDelegate |
39 | 48 |
40 // This will be called when the URL has been fetched, successfully or not. | 49 // This will be called when the URL has been fetched, successfully or not. |
41 // Use accessor methods on |source| to get the results. | 50 // Use accessor methods on |source| to get the results. |
42 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 51 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
43 | 52 |
44 // This will be called when some part of the response is read. |current| | 53 // This will be called when some part of the response is read. |current| |
45 // denotes the number of bytes received up to the call, and |total| is the | 54 // denotes the number of bytes received up to the call, and |total| is the |
46 // expected total size of the response (or -1 if not determined). | 55 // expected total size of the response (or -1 if not determined). |
47 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, | 56 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, |
(...skipping 19 matching lines...) Expand all Loading... |
67 scoped_refptr<ImageDecoder> image_decoder_; | 76 scoped_refptr<ImageDecoder> image_decoder_; |
68 const GURL url_; | 77 const GURL url_; |
69 BitmapFetcherDelegate* const delegate_; | 78 BitmapFetcherDelegate* const delegate_; |
70 | 79 |
71 DISALLOW_COPY_AND_ASSIGN(BitmapFetcher); | 80 DISALLOW_COPY_AND_ASSIGN(BitmapFetcher); |
72 }; | 81 }; |
73 | 82 |
74 } // namespace chrome | 83 } // namespace chrome |
75 | 84 |
76 #endif // CHROME_BROWSER_BITMAP_FETCHER_H_ | 85 #endif // CHROME_BROWSER_BITMAP_FETCHER_H_ |
OLD | NEW |