Chromium Code Reviews| 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_BASE_NETWORK_DELEGATE_H_ | 5 #ifndef NET_BASE_NETWORK_DELEGATE_H_ |
| 6 #define NET_BASE_NETWORK_DELEGATE_H_ | 6 #define NET_BASE_NETWORK_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 // | 31 // |
| 32 // NOTE: It is not okay to add any compile-time dependencies on symbols outside | 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 | 33 // of net/base here, because we have a net_base library. Forward declarations |
| 34 // are ok. | 34 // are ok. |
| 35 class CookieOptions; | 35 class CookieOptions; |
| 36 class HttpRequestHeaders; | 36 class HttpRequestHeaders; |
| 37 class HttpResponseHeaders; | 37 class HttpResponseHeaders; |
| 38 class ProxyInfo; | 38 class ProxyInfo; |
| 39 class SocketStream; | 39 class SocketStream; |
| 40 class URLRequest; | 40 class URLRequest; |
| 41 class ProxyInfo; | |
|
mmenke
2014/07/01 19:45:12
nit: Alphabetize.
rcs
2014/07/02 00:56:20
Done.
| |
| 41 | 42 |
| 42 class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { | 43 class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { |
| 43 public: | 44 public: |
| 44 // AuthRequiredResponse indicates how a NetworkDelegate handles an | 45 // AuthRequiredResponse indicates how a NetworkDelegate handles an |
| 45 // OnAuthRequired call. It's placed in this file to prevent url_request.h | 46 // OnAuthRequired call. It's placed in this file to prevent url_request.h |
| 46 // from having to include network_delegate.h. | 47 // from having to include network_delegate.h. |
| 47 enum AuthRequiredResponse { | 48 enum AuthRequiredResponse { |
| 48 AUTH_REQUIRED_RESPONSE_NO_ACTION, | 49 AUTH_REQUIRED_RESPONSE_NO_ACTION, |
| 49 AUTH_REQUIRED_RESPONSE_SET_AUTH, | 50 AUTH_REQUIRED_RESPONSE_SET_AUTH, |
| 50 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, | 51 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, |
| 51 AUTH_REQUIRED_RESPONSE_IO_PENDING, | 52 AUTH_REQUIRED_RESPONSE_IO_PENDING, |
| 52 }; | 53 }; |
| 53 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; | 54 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; |
| 54 | 55 |
| 55 virtual ~NetworkDelegate() {} | 56 virtual ~NetworkDelegate() {} |
| 56 | 57 |
| 57 // Notification interface called by the network stack. Note that these | 58 // Notification interface called by the network stack. Note that these |
| 58 // functions mostly forward to the private virtuals. They also add some sanity | 59 // functions mostly forward to the private virtuals. They also add some sanity |
| 59 // checking on parameters. See the corresponding virtuals for explanations of | 60 // checking on parameters. See the corresponding virtuals for explanations of |
| 60 // the methods and their arguments. | 61 // the methods and their arguments. |
| 61 int NotifyBeforeURLRequest(URLRequest* request, | 62 int NotifyBeforeURLRequest(URLRequest* request, |
| 62 const CompletionCallback& callback, | 63 const CompletionCallback& callback, |
| 63 GURL* new_url); | 64 GURL* new_url); |
| 65 void NotifyResolveProxy(const GURL& url, int load_flags, | |
| 66 ProxyInfo* result); | |
| 64 int NotifyBeforeSendHeaders(URLRequest* request, | 67 int NotifyBeforeSendHeaders(URLRequest* request, |
| 65 const CompletionCallback& callback, | 68 const CompletionCallback& callback, |
| 66 HttpRequestHeaders* headers); | 69 HttpRequestHeaders* headers); |
| 67 void NotifyBeforeSendProxyHeaders(URLRequest* request, | 70 void NotifyBeforeSendProxyHeaders(URLRequest* request, |
| 68 const ProxyInfo& proxy_info, | 71 const ProxyInfo& proxy_info, |
| 69 HttpRequestHeaders* headers); | 72 HttpRequestHeaders* headers); |
| 70 void NotifySendHeaders(URLRequest* request, | 73 void NotifySendHeaders(URLRequest* request, |
| 71 const HttpRequestHeaders& headers); | 74 const HttpRequestHeaders& headers); |
| 72 int NotifyHeadersReceived( | 75 int NotifyHeadersReceived( |
| 73 URLRequest* request, | 76 URLRequest* request, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 // called for this request. Returns a net status code, generally either OK to | 117 // called for this request. Returns a net status code, generally either OK to |
| 115 // continue with the request or ERR_IO_PENDING if the result is not ready yet. | 118 // continue with the request or ERR_IO_PENDING if the result is not ready yet. |
| 116 // A status code other than OK and ERR_IO_PENDING will cancel the request and | 119 // A status code other than OK and ERR_IO_PENDING will cancel the request and |
| 117 // report the status code as the reason. | 120 // report the status code as the reason. |
| 118 // | 121 // |
| 119 // The default implementation returns OK (continue with request). | 122 // The default implementation returns OK (continue with request). |
| 120 virtual int OnBeforeURLRequest(URLRequest* request, | 123 virtual int OnBeforeURLRequest(URLRequest* request, |
| 121 const CompletionCallback& callback, | 124 const CompletionCallback& callback, |
| 122 GURL* new_url); | 125 GURL* new_url); |
| 123 | 126 |
| 127 // Called as the proxy is being resolved for |url|. Allows the delegate to | |
| 128 // override the proxy resolution decision made by ProxyService. The delegate | |
| 129 // may override the decision by modifying the ProxyInfo |result|. | |
| 130 virtual void OnResolveProxy(const GURL& url, | |
| 131 int load_flags, | |
| 132 ProxyInfo* result); | |
| 133 | |
| 124 // Called right before the HTTP headers are sent. Allows the delegate to | 134 // Called right before the HTTP headers are sent. Allows the delegate to |
| 125 // read/write |headers| before they get sent out. |callback| and |headers| are | 135 // read/write |headers| before they get sent out. |callback| and |headers| are |
| 126 // valid only until OnCompleted or OnURLRequestDestroyed is called for this | 136 // valid only until OnCompleted or OnURLRequestDestroyed is called for this |
| 127 // request. | 137 // request. |
| 128 // See OnBeforeURLRequest for return value description. Returns OK by default. | 138 // See OnBeforeURLRequest for return value description. Returns OK by default. |
| 129 virtual int OnBeforeSendHeaders(URLRequest* request, | 139 virtual int OnBeforeSendHeaders(URLRequest* request, |
| 130 const CompletionCallback& callback, | 140 const CompletionCallback& callback, |
| 131 HttpRequestHeaders* headers); | 141 HttpRequestHeaders* headers); |
| 132 | 142 |
| 133 // Called after a proxy connection. Allows the delegate to read/write | 143 // Called after a proxy connection. Allows the delegate to read/write |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 | 255 |
| 246 // Called before a SocketStream tries to connect. | 256 // Called before a SocketStream tries to connect. |
| 247 // See OnBeforeURLRequest for return value description. Returns OK by default. | 257 // See OnBeforeURLRequest for return value description. Returns OK by default. |
| 248 virtual int OnBeforeSocketStreamConnect( | 258 virtual int OnBeforeSocketStreamConnect( |
| 249 SocketStream* socket, const CompletionCallback& callback); | 259 SocketStream* socket, const CompletionCallback& callback); |
| 250 }; | 260 }; |
| 251 | 261 |
| 252 } // namespace net | 262 } // namespace net |
| 253 | 263 |
| 254 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 264 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
| OLD | NEW |