| 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/memory/scoped_ptr.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/supports_user_data.h" | 16 #include "base/supports_user_data.h" |
| 17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "net/base/auth.h" | 19 #include "net/base/auth.h" |
| 20 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
| 21 #include "net/base/load_states.h" | 21 #include "net/base/load_states.h" |
| 22 #include "net/base/load_timing_info.h" | 22 #include "net/base/load_timing_info.h" |
| 23 #include "net/base/net_export.h" | 23 #include "net/base/net_export.h" |
| 24 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
| 25 #include "net/base/network_delegate.h" | 25 #include "net/base/network_delegate.h" |
| 26 #include "net/base/request_priority.h" | 26 #include "net/base/request_priority.h" |
| 27 #include "net/base/upload_progress.h" | 27 #include "net/base/upload_progress.h" |
| 28 #include "net/cookies/canonical_cookie.h" | 28 #include "net/cookies/canonical_cookie.h" |
| 29 #include "net/cookies/cookie_store.h" | |
| 30 #include "net/http/http_request_headers.h" | 29 #include "net/http/http_request_headers.h" |
| 31 #include "net/http/http_response_info.h" | 30 #include "net/http/http_response_info.h" |
| 32 #include "net/url_request/url_request_status.h" | 31 #include "net/url_request/url_request_status.h" |
| 33 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 34 | 33 |
| 35 namespace base { | 34 namespace base { |
| 36 class Value; | 35 class Value; |
| 37 | 36 |
| 38 namespace debug { | 37 namespace debug { |
| 39 class StackTrace; | 38 class StackTrace; |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 return proxy_server_; | 608 return proxy_server_; |
| 610 } | 609 } |
| 611 | 610 |
| 612 protected: | 611 protected: |
| 613 // Allow the URLRequestJob class to control the is_pending() flag. | 612 // Allow the URLRequestJob class to control the is_pending() flag. |
| 614 void set_is_pending(bool value) { is_pending_ = value; } | 613 void set_is_pending(bool value) { is_pending_ = value; } |
| 615 | 614 |
| 616 // Allow the URLRequestJob class to set our status too | 615 // Allow the URLRequestJob class to set our status too |
| 617 void set_status(const URLRequestStatus& value) { status_ = value; } | 616 void set_status(const URLRequestStatus& value) { status_ = value; } |
| 618 | 617 |
| 619 CookieStore* cookie_store() const { return cookie_store_.get(); } | |
| 620 | |
| 621 // Allow the URLRequestJob to redirect this request. Returns OK if | 618 // Allow the URLRequestJob to redirect this request. Returns OK if |
| 622 // successful, otherwise an error code is returned. | 619 // successful, otherwise an error code is returned. |
| 623 int Redirect(const RedirectInfo& redirect_info); | 620 int Redirect(const RedirectInfo& redirect_info); |
| 624 | 621 |
| 625 // Called by URLRequestJob to allow interception when a redirect occurs. | 622 // Called by URLRequestJob to allow interception when a redirect occurs. |
| 626 void NotifyReceivedRedirect(const RedirectInfo& redirect_info, | 623 void NotifyReceivedRedirect(const RedirectInfo& redirect_info, |
| 627 bool* defer_redirect); | 624 bool* defer_redirect); |
| 628 | 625 |
| 629 // Called by URLRequestHttpJob (note, only HTTP(S) jobs will call this) to | 626 // Called by URLRequestHttpJob (note, only HTTP(S) jobs will call this) to |
| 630 // allow deferral of network initialization. | 627 // allow deferral of network initialization. |
| 631 void NotifyBeforeNetworkStart(bool* defer); | 628 void NotifyBeforeNetworkStart(bool* defer); |
| 632 | 629 |
| 633 // Allow an interceptor's URLRequestJob to restart this request. | 630 // Allow an interceptor's URLRequestJob to restart this request. |
| 634 // Should only be called if the original job has not started a response. | 631 // Should only be called if the original job has not started a response. |
| 635 void Restart(); | 632 void Restart(); |
| 636 | 633 |
| 637 private: | 634 private: |
| 638 friend class URLRequestJob; | 635 friend class URLRequestJob; |
| 639 friend class URLRequestContext; | 636 friend class URLRequestContext; |
| 640 | 637 |
| 641 // URLRequests are always created by calling URLRequestContext::CreateRequest. | 638 // URLRequests are always created by calling URLRequestContext::CreateRequest. |
| 642 // | 639 // |
| 643 // If no cookie store or network delegate are passed in, will use the ones | 640 // If no network delegate is passed in, will use the ones from the |
| 644 // from the URLRequestContext. | 641 // URLRequestContext. |
| 645 URLRequest(const GURL& url, | 642 URLRequest(const GURL& url, |
| 646 RequestPriority priority, | 643 RequestPriority priority, |
| 647 Delegate* delegate, | 644 Delegate* delegate, |
| 648 const URLRequestContext* context, | 645 const URLRequestContext* context, |
| 649 CookieStore* cookie_store, | |
| 650 NetworkDelegate* network_delegate); | 646 NetworkDelegate* network_delegate); |
| 651 | 647 |
| 652 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest | 648 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest |
| 653 // handler. If |blocked| is true, the request is blocked and an error page is | 649 // handler. If |blocked| is true, the request is blocked and an error page is |
| 654 // returned indicating so. This should only be called after Start is called | 650 // returned indicating so. This should only be called after Start is called |
| 655 // and OnBeforeRequest returns true (signalling that the request should be | 651 // and OnBeforeRequest returns true (signalling that the request should be |
| 656 // paused). | 652 // paused). |
| 657 void BeforeRequestComplete(int error); | 653 void BeforeRequestComplete(int error); |
| 658 | 654 |
| 659 void StartJob(URLRequestJob* job); | 655 void StartJob(URLRequestJob* job); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 808 |
| 813 // Timing information for the most recent request. Its start times are | 809 // Timing information for the most recent request. Its start times are |
| 814 // populated during Start(), and the rest are populated in OnResponseReceived. | 810 // populated during Start(), and the rest are populated in OnResponseReceived. |
| 815 LoadTimingInfo load_timing_info_; | 811 LoadTimingInfo load_timing_info_; |
| 816 | 812 |
| 817 scoped_ptr<const base::debug::StackTrace> stack_trace_; | 813 scoped_ptr<const base::debug::StackTrace> stack_trace_; |
| 818 | 814 |
| 819 // Keeps track of whether or not OnBeforeNetworkStart has been called yet. | 815 // Keeps track of whether or not OnBeforeNetworkStart has been called yet. |
| 820 bool notified_before_network_start_; | 816 bool notified_before_network_start_; |
| 821 | 817 |
| 822 // The cookie store to be used for this request. | |
| 823 scoped_refptr<CookieStore> cookie_store_; | |
| 824 | |
| 825 // The proxy server used for this request, if any. | 818 // The proxy server used for this request, if any. |
| 826 HostPortPair proxy_server_; | 819 HostPortPair proxy_server_; |
| 827 | 820 |
| 828 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 821 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
| 829 }; | 822 }; |
| 830 | 823 |
| 831 } // namespace net | 824 } // namespace net |
| 832 | 825 |
| 833 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 826 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
| OLD | NEW |