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 CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 6 #define CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 14 matching lines...) Expand all Loading... | |
25 class HostPortPair; | 25 class HostPortPair; |
26 class HttpRequestHeaders; | 26 class HttpRequestHeaders; |
27 class HttpResponseHeaders; | 27 class HttpResponseHeaders; |
28 class URLRequestContextGetter; | 28 class URLRequestContextGetter; |
29 class URLRequestStatus; | 29 class URLRequestStatus; |
30 typedef std::vector<std::string> ResponseCookies; | 30 typedef std::vector<std::string> ResponseCookies; |
31 } | 31 } |
32 | 32 |
33 namespace content { | 33 namespace content { |
34 | 34 |
35 class ContentURLRequestUserData; | |
35 class URLFetcherDelegate; | 36 class URLFetcherDelegate; |
36 | 37 |
37 // 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 |
38 // the object to be notified when the URL has been loaded: | 39 // the object to be notified when the URL has been loaded: |
39 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com", | 40 // URLFetcher* fetcher = URLFetcher::Create("http://www.google.com", |
40 // URLFetcher::GET, this); | 41 // URLFetcher::GET, this); |
41 // | 42 // |
42 // Then, optionally set properties on this object, like the request context or | 43 // Then, optionally set properties on this object, like the request context or |
43 // extra headers: | 44 // extra headers: |
44 // fetcher->set_extra_request_headers("X-Foo: bar"); | 45 // fetcher->set_extra_request_headers("X-Foo: bar"); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 // This appends the header to the current extra request headers. | 150 // This appends the header to the current extra request headers. |
150 virtual void AddExtraRequestHeader(const std::string& header_line) = 0; | 151 virtual void AddExtraRequestHeader(const std::string& header_line) = 0; |
151 | 152 |
152 virtual void GetExtraRequestHeaders(net::HttpRequestHeaders* headers) = 0; | 153 virtual void GetExtraRequestHeaders(net::HttpRequestHeaders* headers) = 0; |
153 | 154 |
154 // Set the net::URLRequestContext on the request. Must be called before the | 155 // Set the net::URLRequestContext on the request. Must be called before the |
155 // request is started. | 156 // request is started. |
156 virtual void SetRequestContext( | 157 virtual void SetRequestContext( |
157 net::URLRequestContextGetter* request_context_getter) = 0; | 158 net::URLRequestContextGetter* request_context_getter) = 0; |
158 | 159 |
160 // Stash the |user_data| object into the request. The request will take | |
161 // ownership of |user_data|. Must be called before the request is started. | |
162 virtual void SetContentURLRequestUserData( | |
163 content::ContentURLRequestUserData* user_data) = 0; | |
jam
2012/03/01 19:30:42
nit: content:: not needed
why do you have two way
jochen (gone - plz use gerrit)
2012/03/01 19:39:11
I'll do that.
However, I'll still need to expose
| |
164 | |
159 // If |retry| is false, 5xx responses will be propagated to the observer, | 165 // If |retry| is false, 5xx responses will be propagated to the observer, |
160 // if it is true URLFetcher will automatically re-execute the request, | 166 // if it is true URLFetcher will automatically re-execute the request, |
161 // after backoff_delay() elapses. URLFetcher has it set to true by default. | 167 // after backoff_delay() elapses. URLFetcher has it set to true by default. |
162 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; | 168 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; |
163 | 169 |
164 virtual void SetMaxRetries(int max_retries) = 0; | 170 virtual void SetMaxRetries(int max_retries) = 0; |
165 virtual int GetMaxRetries() const = 0; | 171 virtual int GetMaxRetries() const = 0; |
166 | 172 |
167 // Returns the back-off delay before the request will be retried, | 173 // Returns the back-off delay before the request will be retried, |
168 // when a 5xx response was received. | 174 // when a 5xx response was received. |
(...skipping 16 matching lines...) Expand all Loading... | |
185 | 191 |
186 // Returns true if the request was delivered through a proxy. Must only | 192 // Returns true if the request was delivered through a proxy. Must only |
187 // be called after the OnURLFetchComplete callback has run and the request | 193 // be called after the OnURLFetchComplete callback has run and the request |
188 // has not failed. | 194 // has not failed. |
189 virtual bool WasFetchedViaProxy() const = 0; | 195 virtual bool WasFetchedViaProxy() const = 0; |
190 | 196 |
191 // Start the request. After this is called, you may not change any other | 197 // Start the request. After this is called, you may not change any other |
192 // settings. | 198 // settings. |
193 virtual void Start() = 0; | 199 virtual void Start() = 0; |
194 | 200 |
195 // Restarts the URLFetcher with a new URLRequestContextGetter. | 201 // Restarts the URLFetcher with a new URLRequestContextGetter and |
196 virtual void StartWithRequestContextGetter( | 202 // ContentURLRequestUserData. |
197 net::URLRequestContextGetter* request_context_getter) = 0; | 203 virtual void StartWithRequestContextGetterAndUserData( |
jam
2012/03/01 19:30:42
nit: it seems redundant to put the parameter names
jochen (gone - plz use gerrit)
2012/03/01 19:39:11
I think we could just get rid of this function ent
| |
204 net::URLRequestContextGetter* request_context_getter, | |
205 content::ContentURLRequestUserData* user_data) = 0; | |
jam
2012/03/01 19:30:42
nit: content:: is not necessary
| |
198 | 206 |
199 // Return the URL that we were asked to fetch. | 207 // Return the URL that we were asked to fetch. |
200 virtual const GURL& GetOriginalURL() const = 0; | 208 virtual const GURL& GetOriginalURL() const = 0; |
201 | 209 |
202 // Return the URL that this fetcher is processing. | 210 // Return the URL that this fetcher is processing. |
203 virtual const GURL& GetURL() const = 0; | 211 virtual const GURL& GetURL() const = 0; |
204 | 212 |
205 // The status of the URL fetch. | 213 // The status of the URL fetch. |
206 virtual const net::URLRequestStatus& GetStatus() const = 0; | 214 virtual const net::URLRequestStatus& GetStatus() const = 0; |
207 | 215 |
(...skipping 22 matching lines...) Expand all Loading... | |
230 // true, caller takes responsibility for the temp file, and it will not | 238 // true, caller takes responsibility for the temp file, and it will not |
231 // be removed once the URLFetcher is destroyed. User should not take | 239 // be removed once the URLFetcher is destroyed. User should not take |
232 // ownership more than once, or call this method after taking ownership. | 240 // ownership more than once, or call this method after taking ownership. |
233 virtual bool GetResponseAsFilePath(bool take_ownership, | 241 virtual bool GetResponseAsFilePath(bool take_ownership, |
234 FilePath* out_response_path) const = 0; | 242 FilePath* out_response_path) const = 0; |
235 }; | 243 }; |
236 | 244 |
237 } // namespace content | 245 } // namespace content |
238 | 246 |
239 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ | 247 #endif // CONTENT_PUBLIC_COMMON_URL_FETCHER_H_ |
OLD | NEW |