OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // TODO: Insert description here. (generated by megjablon) |
mmenke
2014/11/26 15:23:52
Need copyright header.
Also, descriptions general
megjablon
2014/12/01 19:26:56
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | 2 |
5 #ifndef NET_BASE_NETWORK_DELEGATE_H_ | 3 #ifndef NET_BASE_WRAPPING_NETWORK_DELEGATE_H_ |
6 #define NET_BASE_NETWORK_DELEGATE_H_ | 4 #define NET_BASE_WRAPPING_NETWORK_DELEGATE_H_ |
7 | 5 |
8 #include <string> | 6 #include "base/memory/scoped_ptr.h" |
9 | |
10 #include "base/callback.h" | |
11 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
12 #include "base/threading/non_thread_safe.h" | |
13 #include "net/base/auth.h" | |
14 #include "net/base/completion_callback.h" | 8 #include "net/base/completion_callback.h" |
9 #include "net/base/network_delegate.h" | |
15 #include "net/cookies/canonical_cookie.h" | 10 #include "net/cookies/canonical_cookie.h" |
16 | 11 |
17 class GURL; | 12 class GURL; |
18 | 13 |
19 namespace base { | 14 namespace base { |
20 class FilePath; | 15 class FilePath; |
21 } | 16 } |
22 | 17 |
23 namespace net { | 18 namespace net { |
24 | 19 |
25 // NOTE: Layering violations! | |
26 // We decided to accept these violations (depending | |
27 // on other net/ submodules from net/base/), because otherwise NetworkDelegate | |
28 // would have to be broken up into too many smaller interfaces targeted to each | |
29 // submodule. Also, since the lower levels in net/ may callback into higher | |
30 // levels, we may encounter dangerous casting issues. | |
31 // | |
32 // NOTE: It is not okay to add any compile-time dependencies on symbols outside | |
33 // of net/base here, because we have a net_base library. Forward declarations | |
34 // are ok. | |
35 class CookieOptions; | 20 class CookieOptions; |
36 class HttpRequestHeaders; | 21 class HttpRequestHeaders; |
37 class HttpResponseHeaders; | 22 class HttpResponseHeaders; |
38 class ProxyInfo; | 23 class ProxyInfo; |
39 class ProxyServer; | 24 class ProxyServer; |
40 class ProxyService; | 25 class ProxyService; |
41 class URLRequest; | 26 class URLRequest; |
42 | 27 |
43 class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { | 28 class NET_EXPORT WrappingNetworkDelegate : public NetworkDelegate { |
mmenke
2014/11/26 15:23:53
Maybe call this the LayeredNetworkDelegate?
megjablon
2014/12/01 19:26:56
Done.
| |
44 public: | 29 public: |
45 // AuthRequiredResponse indicates how a NetworkDelegate handles an | 30 // WrappingNetworkDelegate takes a |network_delegate| and extends it. When |
46 // OnAuthRequired call. It's placed in this file to prevent url_request.h | 31 // On*() is called, the On*Internal() method of this is first called and then |
47 // from having to include network_delegate.h. | 32 // the On*() of |network_delegate| is called. |
mmenke
2014/11/26 15:23:52
Should also mention that the internal methods have
mmenke
2014/11/26 15:23:52
This should be just above the class declaration.
megjablon
2014/12/01 19:26:56
Done.
| |
48 enum AuthRequiredResponse { | 33 WrappingNetworkDelegate(scoped_ptr<NetworkDelegate> network_delegate); |
mmenke
2014/11/26 15:23:52
Suggest network_delegate be renamed to nested_netw
mmenke
2014/11/26 15:23:52
Single argument methods should be explicit.
megjablon
2014/12/01 19:26:56
Done.
| |
49 AUTH_REQUIRED_RESPONSE_NO_ACTION, | 34 virtual ~WrappingNetworkDelegate(); |
mmenke
2014/11/26 15:23:52
nit: -virtual + override
megjablon
2014/12/01 19:26:56
Done.
| |
50 AUTH_REQUIRED_RESPONSE_SET_AUTH, | |
51 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, | |
52 AUTH_REQUIRED_RESPONSE_IO_PENDING, | |
53 }; | |
54 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; | |
55 | 35 |
56 virtual ~NetworkDelegate() {} | 36 // Protected for testing purposes. |
mmenke
2014/11/26 15:23:52
+1 indent...Also, not really sure these need to be
megjablon
2014/12/01 19:26:56
Done.
| |
57 | 37 protected: |
58 // Notification interface called by the network stack. Note that these | |
59 // functions mostly forward to the private virtuals. They also add some sanity | |
60 // checking on parameters. See the corresponding virtuals for explanations of | |
61 // the methods and their arguments. | |
62 int NotifyBeforeURLRequest(URLRequest* request, | |
63 const CompletionCallback& callback, | |
64 GURL* new_url); | |
65 void NotifyResolveProxy(const GURL& url, | |
66 int load_flags, | |
67 const ProxyService& proxy_service, | |
68 ProxyInfo* result); | |
69 void NotifyProxyFallback(const ProxyServer& bad_proxy, | |
70 int net_error); | |
71 int NotifyBeforeSendHeaders(URLRequest* request, | |
72 const CompletionCallback& callback, | |
73 HttpRequestHeaders* headers); | |
74 void NotifyBeforeSendProxyHeaders(URLRequest* request, | |
75 const ProxyInfo& proxy_info, | |
76 HttpRequestHeaders* headers); | |
77 void NotifySendHeaders(URLRequest* request, | |
78 const HttpRequestHeaders& headers); | |
79 int NotifyHeadersReceived( | |
80 URLRequest* request, | |
81 const CompletionCallback& callback, | |
82 const HttpResponseHeaders* original_response_headers, | |
83 scoped_refptr<HttpResponseHeaders>* override_response_headers, | |
84 GURL* allowed_unsafe_redirect_url); | |
85 void NotifyBeforeRedirect(URLRequest* request, | |
86 const GURL& new_location); | |
87 void NotifyResponseStarted(URLRequest* request); | |
88 void NotifyRawBytesRead(const URLRequest& request, int bytes_read); | |
89 void NotifyCompleted(URLRequest* request, bool started); | |
90 void NotifyURLRequestDestroyed(URLRequest* request); | |
91 void NotifyPACScriptError(int line_number, const base::string16& error); | |
92 AuthRequiredResponse NotifyAuthRequired(URLRequest* request, | |
93 const AuthChallengeInfo& auth_info, | |
94 const AuthCallback& callback, | |
95 AuthCredentials* credentials); | |
96 bool CanGetCookies(const URLRequest& request, | |
97 const CookieList& cookie_list); | |
98 bool CanSetCookie(const URLRequest& request, | |
99 const std::string& cookie_line, | |
100 CookieOptions* options); | |
101 bool CanAccessFile(const URLRequest& request, | |
102 const base::FilePath& path) const; | |
103 bool CanThrottleRequest(const URLRequest& request) const; | |
104 bool CanEnablePrivacyMode(const GURL& url, | |
105 const GURL& first_party_for_cookies) const; | |
106 | |
107 bool CancelURLRequestWithPolicyViolatingReferrerHeader( | |
108 const URLRequest& request, | |
109 const GURL& target_url, | |
110 const GURL& referrer_url) const; | |
111 | |
112 private: | |
113 // This is the interface for subclasses of NetworkDelegate to implement. These | |
114 // member functions will be called by the respective public notification | |
115 // member function, which will perform basic sanity checking. | |
116 | 38 |
117 // Called before a request is sent. Allows the delegate to rewrite the URL | 39 // Called before a request is sent. Allows the delegate to rewrite the URL |
118 // being fetched by modifying |new_url|. If set, the URL must be valid. The | 40 // being fetched by modifying |new_url|. If set, the URL must be valid. The |
119 // reference fragment from the original URL is not automatically appended to | 41 // reference fragment from the original URL is not automatically appended to |
120 // |new_url|; callers are responsible for copying the reference fragment if | 42 // |new_url|; callers are responsible for copying the reference fragment if |
121 // desired. | 43 // desired. |
122 // |callback| and |new_url| are valid only until OnURLRequestDestroyed is | 44 // |callback| and |new_url| are valid only until OnURLRequestDestroyed is |
123 // called for this request. Returns a net status code, generally either OK to | 45 // called for this request. Returns a net status code, generally either OK to |
124 // continue with the request or ERR_IO_PENDING if the result is not ready yet. | 46 // continue with the request or ERR_IO_PENDING if the result is not ready yet. |
125 // A status code other than OK and ERR_IO_PENDING will cancel the request and | 47 // A status code other than OK and ERR_IO_PENDING will cancel the request and |
126 // report the status code as the reason. | 48 // report the status code as the reason. |
127 // | 49 // |
128 // The default implementation returns OK (continue with request). | 50 // The default implementation returns OK (continue with request). |
mmenke
2014/11/26 15:23:52
Should not duplicate comments like this (They'll b
megjablon
2014/12/01 19:26:56
Done.
| |
129 virtual int OnBeforeURLRequest(URLRequest* request, | 51 virtual int OnBeforeURLRequest(URLRequest* request, |
130 const CompletionCallback& callback, | 52 const CompletionCallback& callback, |
131 GURL* new_url); | 53 GURL* new_url) final; |
mmenke
2014/11/26 15:23:52
The overridden methods should be grouped together,
mmenke
2014/11/26 15:23:53
-virtual + override (And keep the final) for all o
megjablon
2014/12/01 19:26:56
Done.
| |
54 | |
55 virtual void OnBeforeURLRequestInternal(URLRequest* request, | |
56 const CompletionCallback& callback, | |
57 GURL* new_url); | |
132 | 58 |
133 // Called as the proxy is being resolved for |url|. Allows the delegate to | 59 // Called as the proxy is being resolved for |url|. Allows the delegate to |
134 // override the proxy resolution decision made by ProxyService. The delegate | 60 // override the proxy resolution decision made by ProxyService. The delegate |
135 // may override the decision by modifying the ProxyInfo |result|. | 61 // may override the decision by modifying the ProxyInfo |result|. |
136 virtual void OnResolveProxy(const GURL& url, | 62 virtual void OnResolveProxy(const GURL& url, |
137 int load_flags, | 63 int load_flags, |
138 const ProxyService& proxy_service, | 64 const ProxyService& proxy_service, |
139 ProxyInfo* result); | 65 ProxyInfo* result) final; |
66 | |
67 virtual void OnResolveProxyInternal(const GURL& url, | |
68 int load_flags, | |
69 const ProxyService& proxy_service, | |
70 ProxyInfo* result); | |
140 | 71 |
141 // Called when use of |bad_proxy| fails due to |net_error|. |net_error| is | 72 // Called when use of |bad_proxy| fails due to |net_error|. |net_error| is |
142 // the network error encountered, if any, and OK if the fallback was | 73 // the network error encountered, if any, and OK if the fallback was |
143 // for a reason other than a network error (e.g. the proxy service was | 74 // for a reason other than a network error (e.g. the proxy service was |
144 // explicitly directed to skip a proxy). | 75 // explicitly directed to skip a proxy). |
145 virtual void OnProxyFallback(const ProxyServer& bad_proxy, | 76 virtual void OnProxyFallback(const ProxyServer& bad_proxy, |
146 int net_error); | 77 int net_error) final; |
78 | |
79 virtual void OnProxyFallbackInternal(const ProxyServer& bad_proxy, | |
80 int net_error); | |
147 | 81 |
148 // Called right before the HTTP headers are sent. Allows the delegate to | 82 // Called right before the HTTP headers are sent. Allows the delegate to |
149 // read/write |headers| before they get sent out. |callback| and |headers| are | 83 // read/write |headers| before they get sent out. |callback| and |headers| are |
150 // valid only until OnCompleted or OnURLRequestDestroyed is called for this | 84 // valid only until OnCompleted or OnURLRequestDestroyed is called for this |
151 // request. | 85 // request. |
152 // See OnBeforeURLRequest for return value description. Returns OK by default. | 86 // See OnBeforeURLRequest for return value description. Returns OK by default. |
153 virtual int OnBeforeSendHeaders(URLRequest* request, | 87 virtual int OnBeforeSendHeaders(URLRequest* request, |
154 const CompletionCallback& callback, | 88 const CompletionCallback& callback, |
155 HttpRequestHeaders* headers); | 89 HttpRequestHeaders* headers) final; |
90 | |
91 virtual void OnBeforeSendHeadersInternal(URLRequest* request, | |
92 const CompletionCallback& callback, | |
93 HttpRequestHeaders* headers); | |
156 | 94 |
157 // Called after a proxy connection. Allows the delegate to read/write | 95 // Called after a proxy connection. Allows the delegate to read/write |
158 // |headers| before they get sent out. |headers| is valid only until | 96 // |headers| before they get sent out. |headers| is valid only until |
159 // OnCompleted or OnURLRequestDestroyed is called for this request. | 97 // OnCompleted or OnURLRequestDestroyed is called for this request. |
160 virtual void OnBeforeSendProxyHeaders(URLRequest* request, | 98 virtual void OnBeforeSendProxyHeaders(URLRequest* request, |
161 const ProxyInfo& proxy_info, | 99 const ProxyInfo& proxy_info, |
162 HttpRequestHeaders* headers); | 100 HttpRequestHeaders* headers) final; |
101 | |
102 virtual void OnBeforeSendProxyHeadersInternal(URLRequest* request, | |
103 const ProxyInfo& proxy_info, | |
104 HttpRequestHeaders* headers); | |
163 | 105 |
164 // Called right before the HTTP request(s) are being sent to the network. | 106 // Called right before the HTTP request(s) are being sent to the network. |
165 // |headers| is only valid until OnCompleted or OnURLRequestDestroyed is | 107 // |headers| is only valid until OnCompleted or OnURLRequestDestroyed is |
166 // called for this request. | 108 // called for this request. |
167 virtual void OnSendHeaders(URLRequest* request, | 109 virtual void OnSendHeaders(URLRequest* request, |
168 const HttpRequestHeaders& headers); | 110 const HttpRequestHeaders& headers) final; |
111 | |
112 virtual void OnSendHeadersInternal(URLRequest* request, | |
113 const HttpRequestHeaders& headers); | |
169 | 114 |
170 // Called for HTTP requests when the headers have been received. | 115 // Called for HTTP requests when the headers have been received. |
171 // |original_response_headers| contains the headers as received over the | 116 // |original_response_headers| contains the headers as received over the |
172 // network, these must not be modified. |override_response_headers| can be set | 117 // network, these must not be modified. |override_response_headers| can be set |
173 // to new values, that should be considered as overriding | 118 // to new values, that should be considered as overriding |
174 // |original_response_headers|. | 119 // |original_response_headers|. |
175 // If the response is a redirect, and the Location response header value is | 120 // If the response is a redirect, and the Location response header value is |
176 // identical to |allowed_unsafe_redirect_url|, then the redirect is never | 121 // identical to |allowed_unsafe_redirect_url|, then the redirect is never |
177 // blocked and the reference fragment is not copied from the original URL | 122 // blocked and the reference fragment is not copied from the original URL |
178 // to the redirection target. | 123 // to the redirection target. |
179 // | 124 // |
180 // |callback|, |original_response_headers|, and |override_response_headers| | 125 // |callback|, |original_response_headers|, and |override_response_headers| |
181 // are only valid until OnURLRequestDestroyed is called for this request. | 126 // are only valid until OnURLRequestDestroyed is called for this request. |
182 // See OnBeforeURLRequest for return value description. Returns OK by default. | 127 // See OnBeforeURLRequest for return value description. Returns OK by default. |
183 virtual int OnHeadersReceived( | 128 virtual int OnHeadersReceived( |
184 URLRequest* request, | 129 URLRequest* request, |
185 const CompletionCallback& callback, | 130 const CompletionCallback& callback, |
186 const HttpResponseHeaders* original_response_headers, | 131 const HttpResponseHeaders* original_response_headers, |
187 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 132 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
133 GURL* allowed_unsafe_redirect_url) final; | |
134 | |
135 virtual void OnHeadersReceivedInternal( | |
136 URLRequest* request, | |
137 const CompletionCallback& callback, | |
138 const HttpResponseHeaders* original_response_headers, | |
139 scoped_refptr<HttpResponseHeaders>* override_response_headers, | |
188 GURL* allowed_unsafe_redirect_url); | 140 GURL* allowed_unsafe_redirect_url); |
189 | 141 |
190 // Called right after a redirect response code was received. | 142 // Called right after a redirect response code was received. |
191 // |new_location| is only valid until OnURLRequestDestroyed is called for this | 143 // |new_location| is only valid until OnURLRequestDestroyed is called for this |
192 // request. | 144 // request. |
193 virtual void OnBeforeRedirect(URLRequest* request, | 145 virtual void OnBeforeRedirect(URLRequest* request, |
194 const GURL& new_location); | 146 const GURL& new_location) final; |
147 | |
148 virtual void OnBeforeRedirectInternal(URLRequest* request, | |
149 const GURL& new_location); | |
195 | 150 |
196 // This corresponds to URLRequestDelegate::OnResponseStarted. | 151 // This corresponds to URLRequestDelegate::OnResponseStarted. |
197 virtual void OnResponseStarted(URLRequest* request); | 152 virtual void OnResponseStarted(URLRequest* request) final; |
153 | |
154 virtual void OnResponseStartedInternal(URLRequest* request); | |
198 | 155 |
199 // Called every time we read raw bytes. | 156 // Called every time we read raw bytes. |
200 virtual void OnRawBytesRead(const URLRequest& request, int bytes_read); | 157 virtual void OnRawBytesRead(const URLRequest& request, int bytes_read) final; |
158 | |
159 virtual void OnRawBytesReadInternal(const URLRequest& request, | |
160 int bytes_read); | |
201 | 161 |
202 // Indicates that the URL request has been completed or failed. | 162 // Indicates that the URL request has been completed or failed. |
203 // |started| indicates whether the request has been started. If false, | 163 // |started| indicates whether the request has been started. If false, |
204 // some information like the socket address is not available. | 164 // some information like the socket address is not available. |
205 virtual void OnCompleted(URLRequest* request, bool started); | 165 virtual void OnCompleted(URLRequest* request, bool started) final; |
166 | |
167 virtual void OnCompletedInternal(URLRequest* request, bool started); | |
206 | 168 |
207 // Called when an URLRequest is being destroyed. Note that the request is | 169 // Called when an URLRequest is being destroyed. Note that the request is |
208 // being deleted, so it's not safe to call any methods that may result in | 170 // being deleted, so it's not safe to call any methods that may result in |
209 // a virtual method call. | 171 // a virtual method call. |
210 virtual void OnURLRequestDestroyed(URLRequest* request); | 172 virtual void OnURLRequestDestroyed(URLRequest* request) final; |
173 | |
174 virtual void OnURLRequestDestroyedInternal(URLRequest* request); | |
211 | 175 |
212 // Corresponds to ProxyResolverJSBindings::OnError. | 176 // Corresponds to ProxyResolverJSBindings::OnError. |
213 virtual void OnPACScriptError(int line_number, | 177 virtual void OnPACScriptError(int line_number, |
214 const base::string16& error); | 178 const base::string16& error) final; |
179 | |
180 virtual void OnPACScriptErrorInternal(int line_number, | |
181 const base::string16& error); | |
215 | 182 |
216 // Called when a request receives an authentication challenge | 183 // Called when a request receives an authentication challenge |
217 // specified by |auth_info|, and is unable to respond using cached | 184 // specified by |auth_info|, and is unable to respond using cached |
218 // credentials. |callback| and |credentials| must be non-NULL, and must | 185 // credentials. |callback| and |credentials| must be non-NULL, and must |
219 // be valid until OnURLRequestDestroyed is called for |request|. | 186 // be valid until OnURLRequestDestroyed is called for |request|. |
220 // | 187 // |
221 // The following return values are allowed: | 188 // The following return values are allowed: |
222 // - AUTH_REQUIRED_RESPONSE_NO_ACTION: |auth_info| is observed, but | 189 // - AUTH_REQUIRED_RESPONSE_NO_ACTION: |auth_info| is observed, but |
223 // no action is being taken on it. | 190 // no action is being taken on it. |
224 // - AUTH_REQUIRED_RESPONSE_SET_AUTH: |credentials| is filled in with | 191 // - AUTH_REQUIRED_RESPONSE_SET_AUTH: |credentials| is filled in with |
225 // a username and password, which should be used in a response to | 192 // a username and password, which should be used in a response to |
226 // |auth_info|. | 193 // |auth_info|. |
227 // - AUTH_REQUIRED_RESPONSE_CANCEL_AUTH: The authentication challenge | 194 // - AUTH_REQUIRED_RESPONSE_CANCEL_AUTH: The authentication challenge |
228 // should not be attempted. | 195 // should not be attempted. |
229 // - AUTH_REQUIRED_RESPONSE_IO_PENDING: The action will be decided | 196 // - AUTH_REQUIRED_RESPONSE_IO_PENDING: The action will be decided |
230 // asynchronously. |callback| will be invoked when the decision is made, | 197 // asynchronously. |callback| will be invoked when the decision is made, |
231 // and one of the other AuthRequiredResponse values will be passed in with | 198 // and one of the other AuthRequiredResponse values will be passed in with |
232 // the same semantics as described above. | 199 // the same semantics as described above. |
233 virtual AuthRequiredResponse OnAuthRequired( | 200 virtual AuthRequiredResponse OnAuthRequired( |
234 URLRequest* request, | 201 URLRequest* request, |
235 const AuthChallengeInfo& auth_info, | 202 const AuthChallengeInfo& auth_info, |
236 const AuthCallback& callback, | 203 const AuthCallback& callback, |
204 AuthCredentials* credentials) final; | |
205 | |
206 virtual void OnAuthRequiredInternal( | |
207 URLRequest* request, | |
208 const AuthChallengeInfo& auth_info, | |
209 const AuthCallback& callback, | |
237 AuthCredentials* credentials); | 210 AuthCredentials* credentials); |
238 | 211 |
239 // Called when reading cookies to allow the network delegate to block access | 212 // Called when reading cookies to allow the network delegate to block access |
240 // to the cookie. This method will never be invoked when | 213 // to the cookie. This method will never be invoked when |
241 // LOAD_DO_NOT_SEND_COOKIES is specified. | 214 // LOAD_DO_NOT_SEND_COOKIES is specified. |
242 virtual bool OnCanGetCookies(const URLRequest& request, | 215 virtual bool OnCanGetCookies(const URLRequest& request, |
243 const CookieList& cookie_list); | 216 const CookieList& cookie_list) final; |
217 | |
218 virtual void OnCanGetCookiesInternal(const URLRequest& request, | |
219 const CookieList& cookie_list); | |
244 | 220 |
245 // Called when a cookie is set to allow the network delegate to block access | 221 // Called when a cookie is set to allow the network delegate to block access |
246 // to the cookie. This method will never be invoked when | 222 // to the cookie. This method will never be invoked when |
247 // LOAD_DO_NOT_SAVE_COOKIES is specified. | 223 // LOAD_DO_NOT_SAVE_COOKIES is specified. |
248 virtual bool OnCanSetCookie(const URLRequest& request, | 224 virtual bool OnCanSetCookie(const URLRequest& request, |
249 const std::string& cookie_line, | 225 const std::string& cookie_line, |
250 CookieOptions* options); | 226 CookieOptions* options) final; |
227 | |
228 virtual void OnCanSetCookieInternal(const URLRequest& request, | |
229 const std::string& cookie_line, | |
230 CookieOptions* options); | |
251 | 231 |
252 // Called when a file access is attempted to allow the network delegate to | 232 // Called when a file access is attempted to allow the network delegate to |
253 // allow or block access to the given file path. Returns true if access is | 233 // allow or block access to the given file path. Returns true if access is |
254 // allowed. | 234 // allowed. |
255 virtual bool OnCanAccessFile(const URLRequest& request, | 235 virtual bool OnCanAccessFile(const URLRequest& request, |
256 const base::FilePath& path) const; | 236 const base::FilePath& path) const final; |
237 | |
238 virtual void OnCanAccessFileInternal(const URLRequest& request, | |
239 const base::FilePath& path) const; | |
257 | 240 |
258 // Returns true if the given request may be rejected when the | 241 // Returns true if the given request may be rejected when the |
259 // URLRequestThrottlerManager believes the server servicing the | 242 // URLRequestThrottlerManager believes the server servicing the |
260 // request is overloaded or down. | 243 // request is overloaded or down. |
261 virtual bool OnCanThrottleRequest(const URLRequest& request) const; | 244 virtual bool OnCanThrottleRequest(const URLRequest& request) const final; |
245 | |
246 virtual void OnCanThrottleRequestInternal(const URLRequest& request) const; | |
262 | 247 |
263 // Returns true if the given |url| has to be requested over connection that | 248 // Returns true if the given |url| has to be requested over connection that |
264 // is not tracked by the server. Usually is false, unless user privacy | 249 // is not tracked by the server. Usually is false, unless user privacy |
265 // settings block cookies from being get or set. | 250 // settings block cookies from being get or set. |
266 virtual bool OnCanEnablePrivacyMode( | 251 virtual bool OnCanEnablePrivacyMode( |
267 const GURL& url, | 252 const GURL& url, |
253 const GURL& first_party_for_cookies) const final; | |
254 | |
255 virtual void OnCanEnablePrivacyModeInternal( | |
256 const GURL& url, | |
268 const GURL& first_party_for_cookies) const; | 257 const GURL& first_party_for_cookies) const; |
269 | 258 |
270 // Called when the |referrer_url| for requesting |target_url| during handling | 259 // Called when the |referrer_url| for requesting |target_url| during handling |
271 // of the |request| is does not comply with the referrer policy (e.g. a | 260 // of the |request| is does not comply with the referrer policy (e.g. a |
272 // secure referrer for an insecure initial target). | 261 // secure referrer for an insecure initial target). |
273 // Returns true if the request should be cancelled. Otherwise, the referrer | 262 // Returns true if the request should be cancelled. Otherwise, the referrer |
274 // header is stripped from the request. | 263 // header is stripped from the request. |
275 virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 264 virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
276 const URLRequest& request, | 265 const URLRequest& request, |
277 const GURL& target_url, | 266 const GURL& target_url, |
267 const GURL& referrer_url) const final; | |
268 | |
269 virtual void OnCancelURLRequestWithPolicyViolatingReferrerHeaderInternal( | |
270 const URLRequest& request, | |
271 const GURL& target_url, | |
278 const GURL& referrer_url) const; | 272 const GURL& referrer_url) const; |
273 | |
274 private: | |
275 // WrappingNetworkDelegate takes ownership of this. | |
mmenke
2014/11/26 15:23:52
Not needed (It's implied by the fact it's a scoped
megjablon
2014/12/01 19:26:56
Done.
| |
276 scoped_ptr<NetworkDelegate> wrapped_network_delegate_; | |
279 }; | 277 }; |
280 | 278 |
281 } // namespace net | 279 } // namespace net |
282 | 280 |
283 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 281 #endif // NET_BASE_WRAPPING_NETWORK_DELEGATE_H_ |
OLD | NEW |