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_REQUEST_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 // to Read() previously. | 256 // to Read() previously. |
257 // | 257 // |
258 // If an error occurred, request->status() will contain the error, | 258 // If an error occurred, request->status() will contain the error, |
259 // and bytes read will be -1. | 259 // and bytes read will be -1. |
260 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; | 260 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; |
261 | 261 |
262 protected: | 262 protected: |
263 virtual ~Delegate() {} | 263 virtual ~Delegate() {} |
264 }; | 264 }; |
265 | 265 |
266 // TODO(tburkard): we should get rid of this constructor, and have each | 266 // URLRequests should almost always be created by calling |
267 // creator of a URLRequest specifically list the cookie store to be used. | 267 // URLRequestContext::CreateRequest. |
268 // For now, this constructor will use the cookie store in |context|. | 268 // |
269 URLRequest(const GURL& url, | 269 // If no cookie store or network delegate are passed in, will use the ones |
270 RequestPriority priority, | 270 // from the URLRequestContext. |
mmenke
2014/07/24 16:24:41
Not a huge fan of this behavior, but it matches wh
pauljensen
2014/07/31 15:38:17
Acknowledged.
| |
271 Delegate* delegate, | |
272 const URLRequestContext* context); | |
273 | |
274 URLRequest(const GURL& url, | 271 URLRequest(const GURL& url, |
275 RequestPriority priority, | 272 RequestPriority priority, |
276 Delegate* delegate, | 273 Delegate* delegate, |
277 const URLRequestContext* context, | 274 const URLRequestContext* context, |
278 CookieStore* cookie_store); | 275 CookieStore* cookie_store, |
276 NetworkDelegate* network_delegate); | |
279 | 277 |
280 // If destroyed after Start() has been called but while IO is pending, | 278 // If destroyed after Start() has been called but while IO is pending, |
281 // then the request will be effectively canceled and the delegate | 279 // then the request will be effectively canceled and the delegate |
282 // will not have any more of its methods called. | 280 // will not have any more of its methods called. |
283 virtual ~URLRequest(); | 281 virtual ~URLRequest(); |
284 | 282 |
285 // Changes the default cookie policy from allowing all cookies to blocking all | 283 // Changes the default cookie policy from allowing all cookies to blocking all |
286 // cookies. Embedders that want to implement a more flexible policy should | 284 // cookies. Embedders that want to implement a more flexible policy should |
287 // change the default to blocking all cookies, and provide a NetworkDelegate | 285 // change the default to blocking all cookies, and provide a NetworkDelegate |
288 // with the URLRequestContext that maintains the CookieStore. | 286 // with the URLRequestContext that maintains the CookieStore. |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 // Should only be called if the original job has not started a response. | 693 // Should only be called if the original job has not started a response. |
696 void Restart(); | 694 void Restart(); |
697 | 695 |
698 private: | 696 private: |
699 friend class URLRequestJob; | 697 friend class URLRequestJob; |
700 | 698 |
701 // Registers or unregisters a network interception class. | 699 // Registers or unregisters a network interception class. |
702 static void RegisterRequestInterceptor(Interceptor* interceptor); | 700 static void RegisterRequestInterceptor(Interceptor* interceptor); |
703 static void UnregisterRequestInterceptor(Interceptor* interceptor); | 701 static void UnregisterRequestInterceptor(Interceptor* interceptor); |
704 | 702 |
705 // Initializes the URLRequest. Code shared between the two constructors. | |
706 // TODO(tburkard): This can ultimately be folded into a single constructor | |
707 // again. | |
708 void Init(const GURL& url, | |
709 RequestPriority priotity, | |
710 Delegate* delegate, | |
711 const URLRequestContext* context, | |
712 CookieStore* cookie_store); | |
713 | |
714 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest | 703 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest |
715 // handler. If |blocked| is true, the request is blocked and an error page is | 704 // handler. If |blocked| is true, the request is blocked and an error page is |
716 // returned indicating so. This should only be called after Start is called | 705 // returned indicating so. This should only be called after Start is called |
717 // and OnBeforeRequest returns true (signalling that the request should be | 706 // and OnBeforeRequest returns true (signalling that the request should be |
718 // paused). | 707 // paused). |
719 void BeforeRequestComplete(int error); | 708 void BeforeRequestComplete(int error); |
720 | 709 |
721 void StartJob(URLRequestJob* job); | 710 void StartJob(URLRequestJob* job); |
722 | 711 |
723 // Restarting involves replacing the current job with a new one such as what | 712 // Restarting involves replacing the current job with a new one such as what |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 | 870 |
882 // The proxy server used for this request, if any. | 871 // The proxy server used for this request, if any. |
883 HostPortPair proxy_server_; | 872 HostPortPair proxy_server_; |
884 | 873 |
885 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 874 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
886 }; | 875 }; |
887 | 876 |
888 } // namespace net | 877 } // namespace net |
889 | 878 |
890 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 879 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
OLD | NEW |