| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 NET_URL_REQUEST_URL_FETCHER_H_ | 5 #ifndef NET_URL_REQUEST_URL_FETCHER_H_ |
| 6 #define NET_URL_REQUEST_URL_FETCHER_H_ | 6 #define NET_URL_REQUEST_URL_FETCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class HttpRequestHeaders; | 30 class HttpRequestHeaders; |
| 31 class HttpResponseHeaders; | 31 class HttpResponseHeaders; |
| 32 class URLFetcherDelegate; | 32 class URLFetcherDelegate; |
| 33 class URLFetcherResponseWriter; | 33 class URLFetcherResponseWriter; |
| 34 class URLRequestContextGetter; | 34 class URLRequestContextGetter; |
| 35 class URLRequestStatus; | 35 class URLRequestStatus; |
| 36 typedef std::vector<std::string> ResponseCookies; | 36 typedef std::vector<std::string> ResponseCookies; |
| 37 | 37 |
| 38 // To use this class, create an instance with the desired URL and a pointer to | 38 // To use this class, create an instance with the desired URL and a pointer to |
| 39 // the object to be notified when the URL has been loaded: | 39 // the object to be notified when the URL has been loaded: |
| 40 // scoped_ptr<URLFetcher> fetcher(URLFetcher::Create("http://www.google.com", | 40 // scoped_ptr<URLFetcher> fetcher = |
| 41 // URLFetcher::Create("http://www.google.com", |
| 41 // URLFetcher::GET, | 42 // URLFetcher::GET, |
| 42 // this)); | 43 // this); |
| 43 // | 44 // |
| 44 // You must also set a request context getter: | 45 // You must also set a request context getter: |
| 45 // | 46 // |
| 46 // fetcher->SetRequestContext(&my_request_context_getter); | 47 // fetcher->SetRequestContext(&my_request_context_getter); |
| 47 // | 48 // |
| 48 // Then, optionally set properties on this object, like the request context or | 49 // Then, optionally set properties on this object, like the request context or |
| 49 // extra headers: | 50 // extra headers: |
| 50 // fetcher->set_extra_request_headers("X-Foo: bar"); | 51 // fetcher->set_extra_request_headers("X-Foo: bar"); |
| 51 // | 52 // |
| 52 // Finally, start the request: | 53 // Finally, start the request: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Used by SetUploadStreamFactory. The callback should assign a fresh upload | 96 // Used by SetUploadStreamFactory. The callback should assign a fresh upload |
| 96 // data stream every time it's called. | 97 // data stream every time it's called. |
| 97 typedef base::Callback<scoped_ptr<UploadDataStream>()> | 98 typedef base::Callback<scoped_ptr<UploadDataStream>()> |
| 98 CreateUploadStreamCallback; | 99 CreateUploadStreamCallback; |
| 99 | 100 |
| 100 virtual ~URLFetcher(); | 101 virtual ~URLFetcher(); |
| 101 | 102 |
| 102 // |url| is the URL to send the request to. | 103 // |url| is the URL to send the request to. |
| 103 // |request_type| is the type of request to make. | 104 // |request_type| is the type of request to make. |
| 104 // |d| the object that will receive the callback on fetch completion. | 105 // |d| the object that will receive the callback on fetch completion. |
| 105 // Caller is responsible for destroying the returned URLFetcher. | 106 static scoped_ptr<URLFetcher> Create(const GURL& url, |
| 106 static URLFetcher* Create(const GURL& url, | 107 URLFetcher::RequestType request_type, |
| 107 URLFetcher::RequestType request_type, | 108 URLFetcherDelegate* d); |
| 108 URLFetcherDelegate* d); | |
| 109 | 109 |
| 110 // Like above, but if there's a URLFetcherFactory registered with the | 110 // Like above, but if there's a URLFetcherFactory registered with the |
| 111 // implementation it will be used. |id| may be used during testing to identify | 111 // implementation it will be used. |id| may be used during testing to identify |
| 112 // who is creating the URLFetcher. | 112 // who is creating the URLFetcher. |
| 113 // Caller is responsible for destroying the returned URLFetcher. | 113 static scoped_ptr<URLFetcher> Create(int id, |
| 114 static URLFetcher* Create(int id, | 114 const GURL& url, |
| 115 const GURL& url, | 115 URLFetcher::RequestType request_type, |
| 116 URLFetcher::RequestType request_type, | 116 URLFetcherDelegate* d); |
| 117 URLFetcherDelegate* d); | |
| 118 | 117 |
| 119 // Cancels all existing URLFetchers. Will notify the URLFetcherDelegates. | 118 // Cancels all existing URLFetchers. Will notify the URLFetcherDelegates. |
| 120 // Note that any new URLFetchers created while this is running will not be | 119 // Note that any new URLFetchers created while this is running will not be |
| 121 // cancelled. Typically, one would call this in the CleanUp() method of an IO | 120 // cancelled. Typically, one would call this in the CleanUp() method of an IO |
| 122 // thread, so that no new URLRequests would be able to start on the IO thread | 121 // thread, so that no new URLRequests would be able to start on the IO thread |
| 123 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO | 122 // anyway. This doesn't prevent new URLFetchers from trying to post to the IO |
| 124 // thread though, even though the task won't ever run. | 123 // thread though, even though the task won't ever run. |
| 125 static void CancelAll(); | 124 static void CancelAll(); |
| 126 | 125 |
| 127 // Normally, URLFetcher will abort loads that request SSL client certificate | 126 // Normally, URLFetcher will abort loads that request SSL client certificate |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // be removed once the URLFetcher is destroyed. User should not take | 315 // be removed once the URLFetcher is destroyed. User should not take |
| 317 // ownership more than once, or call this method after taking ownership. | 316 // ownership more than once, or call this method after taking ownership. |
| 318 virtual bool GetResponseAsFilePath( | 317 virtual bool GetResponseAsFilePath( |
| 319 bool take_ownership, | 318 bool take_ownership, |
| 320 base::FilePath* out_response_path) const = 0; | 319 base::FilePath* out_response_path) const = 0; |
| 321 }; | 320 }; |
| 322 | 321 |
| 323 } // namespace net | 322 } // namespace net |
| 324 | 323 |
| 325 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 324 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
| OLD | NEW |