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 |
11 #include "base/debug/leak_tracker.h" | 11 #include "base/debug/leak_tracker.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
15 #include "base/supports_user_data.h" | 16 #include "base/supports_user_data.h" |
16 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "net/base/auth.h" | 19 #include "net/base/auth.h" |
19 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
20 #include "net/base/load_states.h" | 21 #include "net/base/load_states.h" |
21 #include "net/base/load_timing_info.h" | 22 #include "net/base/load_timing_info.h" |
22 #include "net/base/net_export.h" | 23 #include "net/base/net_export.h" |
23 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 // to Read() previously. | 267 // to Read() previously. |
267 // | 268 // |
268 // If an error occurred, request->status() will contain the error, | 269 // If an error occurred, request->status() will contain the error, |
269 // and bytes read will be -1. | 270 // and bytes read will be -1. |
270 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; | 271 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; |
271 | 272 |
272 protected: | 273 protected: |
273 virtual ~Delegate() {} | 274 virtual ~Delegate() {} |
274 }; | 275 }; |
275 | 276 |
276 // URLRequests should almost always be created by calling | |
277 // URLRequestContext::CreateRequest. | |
278 // | |
279 // If no cookie store or network delegate are passed in, will use the ones | |
280 // from the URLRequestContext. | |
281 URLRequest(const GURL& url, | |
282 RequestPriority priority, | |
283 Delegate* delegate, | |
284 const URLRequestContext* context, | |
285 CookieStore* cookie_store, | |
286 NetworkDelegate* network_delegate); | |
287 | |
288 // If destroyed after Start() has been called but while IO is pending, | 277 // If destroyed after Start() has been called but while IO is pending, |
289 // then the request will be effectively canceled and the delegate | 278 // then the request will be effectively canceled and the delegate |
290 // will not have any more of its methods called. | 279 // will not have any more of its methods called. |
291 virtual ~URLRequest(); | 280 virtual ~URLRequest(); |
292 | 281 |
293 // Changes the default cookie policy from allowing all cookies to blocking all | 282 // Changes the default cookie policy from allowing all cookies to blocking all |
294 // cookies. Embedders that want to implement a more flexible policy should | 283 // cookies. Embedders that want to implement a more flexible policy should |
295 // change the default to blocking all cookies, and provide a NetworkDelegate | 284 // change the default to blocking all cookies, and provide a NetworkDelegate |
296 // with the URLRequestContext that maintains the CookieStore. | 285 // with the URLRequestContext that maintains the CookieStore. |
297 // The cookie policy default has to be set before the first URLRequest is | 286 // The cookie policy default has to be set before the first URLRequest is |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 // Called by URLRequestHttpJob (note, only HTTP(S) jobs will call this) to | 696 // Called by URLRequestHttpJob (note, only HTTP(S) jobs will call this) to |
708 // allow deferral of network initialization. | 697 // allow deferral of network initialization. |
709 void NotifyBeforeNetworkStart(bool* defer); | 698 void NotifyBeforeNetworkStart(bool* defer); |
710 | 699 |
711 // Allow an interceptor's URLRequestJob to restart this request. | 700 // Allow an interceptor's URLRequestJob to restart this request. |
712 // Should only be called if the original job has not started a response. | 701 // Should only be called if the original job has not started a response. |
713 void Restart(); | 702 void Restart(); |
714 | 703 |
715 private: | 704 private: |
716 friend class URLRequestJob; | 705 friend class URLRequestJob; |
706 friend class URLRequestContext; | |
707 | |
708 // URLRequests are always be created by calling | |
pauljensen
2014/08/28 15:48:39
remove "be"
mmenke
2014/08/28 16:46:00
Done.
| |
709 // URLRequestContext::CreateRequest. | |
710 // | |
711 // If no cookie store or network delegate are passed in, will use the ones | |
712 // from the URLRequestContext. | |
713 URLRequest(const GURL& url, | |
714 RequestPriority priority, | |
715 Delegate* delegate, | |
716 const URLRequestContext* context, | |
717 CookieStore* cookie_store, | |
718 NetworkDelegate* network_delegate); | |
717 | 719 |
718 // Registers or unregisters a network interception class. | 720 // Registers or unregisters a network interception class. |
719 static void RegisterRequestInterceptor(Interceptor* interceptor); | 721 static void RegisterRequestInterceptor(Interceptor* interceptor); |
720 static void UnregisterRequestInterceptor(Interceptor* interceptor); | 722 static void UnregisterRequestInterceptor(Interceptor* interceptor); |
721 | 723 |
722 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest | 724 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest |
723 // handler. If |blocked| is true, the request is blocked and an error page is | 725 // handler. If |blocked| is true, the request is blocked and an error page is |
724 // returned indicating so. This should only be called after Start is called | 726 // returned indicating so. This should only be called after Start is called |
725 // and OnBeforeRequest returns true (signalling that the request should be | 727 // and OnBeforeRequest returns true (signalling that the request should be |
726 // paused). | 728 // paused). |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
890 | 892 |
891 // The proxy server used for this request, if any. | 893 // The proxy server used for this request, if any. |
892 HostPortPair proxy_server_; | 894 HostPortPair proxy_server_; |
893 | 895 |
894 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 896 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
895 }; | 897 }; |
896 | 898 |
897 } // namespace net | 899 } // namespace net |
898 | 900 |
899 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 901 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
OLD | NEW |