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_BITMAP_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_ |
6 #define CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_ | 6 #define CHROME_BROWSER_BITMAP_FETCHER_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/bitmap_fetcher_delegate.h" | 9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h" |
10 #include "chrome/browser/image_decoder.h" | 10 #include "chrome/browser/image_decoder.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 // Asynchrounously fetches an image from the given URL and returns the | 23 // Asynchrounously fetches an image from the given URL and returns the |
24 // decoded Bitmap to the provided BitmapFetcherDelegate. | 24 // decoded Bitmap to the provided BitmapFetcherDelegate. |
25 class BitmapFetcher : public net::URLFetcherDelegate, | 25 class BitmapFetcher : public net::URLFetcherDelegate, |
26 public ImageDecoder::ImageRequest { | 26 public ImageDecoder::ImageRequest { |
27 public: | 27 public: |
28 BitmapFetcher(const GURL& url, BitmapFetcherDelegate* delegate); | 28 BitmapFetcher(const GURL& url, BitmapFetcherDelegate* delegate); |
29 ~BitmapFetcher() override; | 29 ~BitmapFetcher() override; |
30 | 30 |
31 const GURL& url() const { return url_; } | 31 const GURL& url() const { return url_; } |
32 net::URLFetcher* url_fetcher() { return url_fetcher_.get(); } | |
33 | |
34 // Initializes internal fetcher. After this function returns url_fetcher() | |
35 // can be accessed to configure it further(eg. add user data to request). | |
Theresa
2015/05/04 16:57:39
nit, missing space: "further (e.g. add...)"
| |
36 // All configuration must be done before Start() is called. | |
37 // Values for |load_flags| are defined in net/base/load_flags.h. In general, | |
38 // |net::LOAD_NORMAL| is appropriate. | |
39 void Init(net::URLRequestContextGetter* request_context, | |
40 const std::string& referrer, | |
dschuyler
2015/05/05 20:45:50
No big deal, but I noticed that each of the calls
| |
41 net::URLRequest::ReferrerPolicy referrer_policy, | |
42 int load_flags); | |
32 | 43 |
33 // Start fetching the URL with the fetcher. The delegate is notified | 44 // Start fetching the URL with the fetcher. The delegate is notified |
34 // asynchronously when done. Start may be called more than once in some | 45 // asynchronously when done. Start may be called more than once in some |
35 // cases. If so, subsequent starts will be ignored since the operation is | 46 // cases. If so, subsequent starts will be ignored since the operation is |
36 // already in progress. Arguments are used to configure the internal fetcher. | 47 // already in progress. |
37 // Values for |load_flags| are defined in net/base/load_flags.h. In general, | 48 void Start(); |
38 // |net::LOAD_NORMAL| is appropriate. | |
39 void Start(net::URLRequestContextGetter* request_context, | |
40 const std::string& referrer, | |
41 net::URLRequest::ReferrerPolicy referrer_policy, | |
42 int load_flags); | |
43 | 49 |
44 // Methods inherited from URLFetcherDelegate | 50 // Methods inherited from URLFetcherDelegate |
45 | 51 |
46 // This will be called when the URL has been fetched, successfully or not. | 52 // This will be called when the URL has been fetched, successfully or not. |
47 // Use accessor methods on |source| to get the results. | 53 // Use accessor methods on |source| to get the results. |
48 void OnURLFetchComplete(const net::URLFetcher* source) override; | 54 void OnURLFetchComplete(const net::URLFetcher* source) override; |
49 | 55 |
50 // This will be called when some part of the response is read. |current| | 56 // This will be called when some part of the response is read. |current| |
51 // denotes the number of bytes received up to the call, and |total| is the | 57 // denotes the number of bytes received up to the call, and |total| is the |
52 // expected total size of the response (or -1 if not determined). | 58 // expected total size of the response (or -1 if not determined). |
(...skipping 18 matching lines...) Expand all Loading... | |
71 scoped_ptr<net::URLFetcher> url_fetcher_; | 77 scoped_ptr<net::URLFetcher> url_fetcher_; |
72 const GURL url_; | 78 const GURL url_; |
73 BitmapFetcherDelegate* const delegate_; | 79 BitmapFetcherDelegate* const delegate_; |
74 | 80 |
75 DISALLOW_COPY_AND_ASSIGN(BitmapFetcher); | 81 DISALLOW_COPY_AND_ASSIGN(BitmapFetcher); |
76 }; | 82 }; |
77 | 83 |
78 } // namespace chrome | 84 } // namespace chrome |
79 | 85 |
80 #endif // CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_ | 86 #endif // CHROME_BROWSER_BITMAP_FETCHER_BITMAP_FETCHER_H_ |
OLD | NEW |