| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // to Read() previously. | 305 // to Read() previously. |
| 306 // | 306 // |
| 307 // If an error occurred, request->status() will contain the error, | 307 // If an error occurred, request->status() will contain the error, |
| 308 // and bytes read will be -1. | 308 // and bytes read will be -1. |
| 309 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; | 309 virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; |
| 310 | 310 |
| 311 protected: | 311 protected: |
| 312 virtual ~Delegate() {} | 312 virtual ~Delegate() {} |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 // TODO(shalev): Get rid of this constructor in favour of the one below it. |
| 315 // Initialize an URL request. | 316 // Initialize an URL request. |
| 316 URLRequest(const GURL& url, | 317 URLRequest(const GURL& url, |
| 317 Delegate* delegate, | 318 Delegate* delegate, |
| 318 const URLRequestContext* context); | 319 const URLRequestContext* context); |
| 319 | 320 |
| 321 URLRequest(const GURL& url, |
| 322 Delegate* delegate, |
| 323 const URLRequestContext* context, |
| 324 NetworkDelegate* network_delegate); |
| 325 |
| 320 // If destroyed after Start() has been called but while IO is pending, | 326 // If destroyed after Start() has been called but while IO is pending, |
| 321 // then the request will be effectively canceled and the delegate | 327 // then the request will be effectively canceled and the delegate |
| 322 // will not have any more of its methods called. | 328 // will not have any more of its methods called. |
| 323 virtual ~URLRequest(); | 329 virtual ~URLRequest(); |
| 324 | 330 |
| 325 // Changes the default cookie policy from allowing all cookies to blocking all | 331 // Changes the default cookie policy from allowing all cookies to blocking all |
| 326 // cookies. Embedders that want to implement a more flexible policy should | 332 // cookies. Embedders that want to implement a more flexible policy should |
| 327 // change the default to blocking all cookies, and provide a NetworkDelegate | 333 // change the default to blocking all cookies, and provide a NetworkDelegate |
| 328 // with the URLRequestContext that maintains the CookieStore. | 334 // with the URLRequestContext that maintains the CookieStore. |
| 329 // The cookie policy default has to be set before the first URLRequest is | 335 // The cookie policy default has to be set before the first URLRequest is |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 bool CanGetCookies(const CookieList& cookie_list) const; | 733 bool CanGetCookies(const CookieList& cookie_list) const; |
| 728 bool CanSetCookie(const std::string& cookie_line, | 734 bool CanSetCookie(const std::string& cookie_line, |
| 729 CookieOptions* options) const; | 735 CookieOptions* options) const; |
| 730 void NotifyReadCompleted(int bytes_read); | 736 void NotifyReadCompleted(int bytes_read); |
| 731 | 737 |
| 732 // Called when the delegate blocks or unblocks this request when intercepting | 738 // Called when the delegate blocks or unblocks this request when intercepting |
| 733 // certain requests. | 739 // certain requests. |
| 734 void SetBlockedOnDelegate(); | 740 void SetBlockedOnDelegate(); |
| 735 void SetUnblockedOnDelegate(); | 741 void SetUnblockedOnDelegate(); |
| 736 | 742 |
| 737 // Contextual information used for this request (can be NULL). This contains | 743 // Contextual information used for this request. Cannot be NULL. This contains |
| 738 // most of the dependencies which are shared between requests (disk cache, | 744 // most of the dependencies which are shared between requests (disk cache, |
| 739 // cookie store, socket pool, etc.) | 745 // cookie store, socket pool, etc.) |
| 740 const URLRequestContext* context_; | 746 const URLRequestContext* context_; |
| 741 | 747 |
| 748 NetworkDelegate* network_delegate_; |
| 749 |
| 742 // Tracks the time spent in various load states throughout this request. | 750 // Tracks the time spent in various load states throughout this request. |
| 743 BoundNetLog net_log_; | 751 BoundNetLog net_log_; |
| 744 | 752 |
| 745 scoped_refptr<URLRequestJob> job_; | 753 scoped_refptr<URLRequestJob> job_; |
| 746 scoped_refptr<UploadData> upload_; | 754 scoped_refptr<UploadData> upload_; |
| 747 std::vector<GURL> url_chain_; | 755 std::vector<GURL> url_chain_; |
| 748 GURL first_party_for_cookies_; | 756 GURL first_party_for_cookies_; |
| 749 GURL delegate_redirect_url_; | 757 GURL delegate_redirect_url_; |
| 750 std::string method_; // "GET", "POST", etc. Should be all uppercase. | 758 std::string method_; // "GET", "POST", etc. Should be all uppercase. |
| 751 std::string referrer_; | 759 std::string referrer_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 base::TimeTicks creation_time_; | 829 base::TimeTicks creation_time_; |
| 822 | 830 |
| 823 scoped_ptr<const base::debug::StackTrace> stack_trace_; | 831 scoped_ptr<const base::debug::StackTrace> stack_trace_; |
| 824 | 832 |
| 825 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 833 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
| 826 }; | 834 }; |
| 827 | 835 |
| 828 } // namespace net | 836 } // namespace net |
| 829 | 837 |
| 830 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 838 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
| OLD | NEW |