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 22 matching lines...) Expand all Loading... |
33 #include "url/gurl.h" | 33 #include "url/gurl.h" |
34 | 34 |
35 namespace base { | 35 namespace base { |
36 class Value; | 36 class Value; |
37 | 37 |
38 namespace debug { | 38 namespace debug { |
39 class StackTrace; | 39 class StackTrace; |
40 } // namespace debug | 40 } // namespace debug |
41 } // namespace base | 41 } // namespace base |
42 | 42 |
43 // Temporary layering violation to allow existing users of a deprecated | |
44 // interface. | |
45 namespace content { | |
46 class AppCacheInterceptor; | |
47 } | |
48 | |
49 namespace net { | 43 namespace net { |
50 | 44 |
51 class ChunkedUploadDataStream; | 45 class ChunkedUploadDataStream; |
52 class CookieOptions; | 46 class CookieOptions; |
53 class HostPortPair; | 47 class HostPortPair; |
54 class IOBuffer; | 48 class IOBuffer; |
55 struct LoadTimingInfo; | 49 struct LoadTimingInfo; |
56 struct RedirectInfo; | 50 struct RedirectInfo; |
57 class SSLCertRequestInfo; | 51 class SSLCertRequestInfo; |
58 class SSLInfo; | 52 class SSLInfo; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 107 |
114 // First-party URL redirect policy: During server redirects, the first-party | 108 // First-party URL redirect policy: During server redirects, the first-party |
115 // URL for cookies normally doesn't change. However, if the request is a | 109 // URL for cookies normally doesn't change. However, if the request is a |
116 // top-level first-party request, the first-party URL should be updated to the | 110 // top-level first-party request, the first-party URL should be updated to the |
117 // URL on every redirect. | 111 // URL on every redirect. |
118 enum FirstPartyURLPolicy { | 112 enum FirstPartyURLPolicy { |
119 NEVER_CHANGE_FIRST_PARTY_URL, | 113 NEVER_CHANGE_FIRST_PARTY_URL, |
120 UPDATE_FIRST_PARTY_URL_ON_REDIRECT, | 114 UPDATE_FIRST_PARTY_URL_ON_REDIRECT, |
121 }; | 115 }; |
122 | 116 |
123 // This class handles network interception. Use with | |
124 // (Un)RegisterRequestInterceptor. | |
125 class NET_EXPORT Interceptor { | |
126 public: | |
127 virtual ~Interceptor() {} | |
128 | |
129 // Called for every request made. Should return a new job to handle the | |
130 // request if it should be intercepted, or NULL to allow the request to | |
131 // be handled in the normal manner. | |
132 virtual URLRequestJob* MaybeIntercept( | |
133 URLRequest* request, NetworkDelegate* network_delegate) = 0; | |
134 | |
135 // Called after having received a redirect response, but prior to the | |
136 // the request delegate being informed of the redirect. Can return a new | |
137 // job to replace the existing job if it should be intercepted, or NULL | |
138 // to allow the normal handling to continue. If a new job is provided, | |
139 // the delegate never sees the original redirect response, instead the | |
140 // response produced by the intercept job will be returned. | |
141 virtual URLRequestJob* MaybeInterceptRedirect( | |
142 URLRequest* request, | |
143 NetworkDelegate* network_delegate, | |
144 const GURL& location); | |
145 | |
146 // Called after having received a final response, but prior to the | |
147 // the request delegate being informed of the response. This is also | |
148 // called when there is no server response at all to allow interception | |
149 // on dns or network errors. Can return a new job to replace the existing | |
150 // job if it should be intercepted, or NULL to allow the normal handling to | |
151 // continue. If a new job is provided, the delegate never sees the original | |
152 // response, instead the response produced by the intercept job will be | |
153 // returned. | |
154 virtual URLRequestJob* MaybeInterceptResponse( | |
155 URLRequest* request, NetworkDelegate* network_delegate); | |
156 }; | |
157 | |
158 // Deprecated interfaces in net::URLRequest. They have been moved to | |
159 // URLRequest's private section to prevent new uses. Existing uses are | |
160 // explicitly friended here and should be removed over time. | |
161 class NET_EXPORT Deprecated { | |
162 private: | |
163 // TODO(willchan): Kill off these friend declarations. | |
164 friend class TestInterceptor; | |
165 friend class content::AppCacheInterceptor; | |
166 | |
167 // TODO(pauljensen): Remove this when AppCacheInterceptor is a | |
168 // ProtocolHandler, see crbug.com/161547. | |
169 static void RegisterRequestInterceptor(Interceptor* interceptor); | |
170 static void UnregisterRequestInterceptor(Interceptor* interceptor); | |
171 | |
172 DISALLOW_IMPLICIT_CONSTRUCTORS(Deprecated); | |
173 }; | |
174 | |
175 // The delegate's methods are called from the message loop of the thread | 117 // The delegate's methods are called from the message loop of the thread |
176 // on which the request's Start() method is called. See above for the | 118 // on which the request's Start() method is called. See above for the |
177 // ordering of callbacks. | 119 // ordering of callbacks. |
178 // | 120 // |
179 // The callbacks will be called in the following order: | 121 // The callbacks will be called in the following order: |
180 // Start() | 122 // Start() |
181 // - OnCertificateRequested* (zero or more calls, if the SSL server and/or | 123 // - OnCertificateRequested* (zero or more calls, if the SSL server and/or |
182 // SSL proxy requests a client certificate for authentication) | 124 // SSL proxy requests a client certificate for authentication) |
183 // - OnSSLCertificateError* (zero or one call, if the SSL server's | 125 // - OnSSLCertificateError* (zero or one call, if the SSL server's |
184 // certificate has an error) | 126 // certificate has an error) |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 // | 652 // |
711 // If no cookie store or network delegate are passed in, will use the ones | 653 // If no cookie store or network delegate are passed in, will use the ones |
712 // from the URLRequestContext. | 654 // from the URLRequestContext. |
713 URLRequest(const GURL& url, | 655 URLRequest(const GURL& url, |
714 RequestPriority priority, | 656 RequestPriority priority, |
715 Delegate* delegate, | 657 Delegate* delegate, |
716 const URLRequestContext* context, | 658 const URLRequestContext* context, |
717 CookieStore* cookie_store, | 659 CookieStore* cookie_store, |
718 NetworkDelegate* network_delegate); | 660 NetworkDelegate* network_delegate); |
719 | 661 |
720 // Registers or unregisters a network interception class. | |
721 static void RegisterRequestInterceptor(Interceptor* interceptor); | |
722 static void UnregisterRequestInterceptor(Interceptor* interceptor); | |
723 | |
724 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest | 662 // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest |
725 // handler. If |blocked| is true, the request is blocked and an error page is | 663 // handler. If |blocked| is true, the request is blocked and an error page is |
726 // returned indicating so. This should only be called after Start is called | 664 // returned indicating so. This should only be called after Start is called |
727 // and OnBeforeRequest returns true (signalling that the request should be | 665 // and OnBeforeRequest returns true (signalling that the request should be |
728 // paused). | 666 // paused). |
729 void BeforeRequestComplete(int error); | 667 void BeforeRequestComplete(int error); |
730 | 668 |
731 void StartJob(URLRequestJob* job); | 669 void StartJob(URLRequestJob* job); |
732 | 670 |
733 // Restarting involves replacing the current job with a new one such as what | 671 // Restarting involves replacing the current job with a new one such as what |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 | 834 |
897 // The proxy server used for this request, if any. | 835 // The proxy server used for this request, if any. |
898 HostPortPair proxy_server_; | 836 HostPortPair proxy_server_; |
899 | 837 |
900 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 838 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
901 }; | 839 }; |
902 | 840 |
903 } // namespace net | 841 } // namespace net |
904 | 842 |
905 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 843 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
OLD | NEW |