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 19 matching lines...) Expand all Loading... |
30 // levels, we may encounter dangerous casting issues. | 30 // levels, we may encounter dangerous casting issues. |
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 SocketStream; | 38 class SocketStream; |
39 class URLRequest; | 39 class URLRequest; |
| 40 class ProxyInfo; |
40 | 41 |
41 class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { | 42 class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { |
42 public: | 43 public: |
43 // AuthRequiredResponse indicates how a NetworkDelegate handles an | 44 // AuthRequiredResponse indicates how a NetworkDelegate handles an |
44 // OnAuthRequired call. It's placed in this file to prevent url_request.h | 45 // OnAuthRequired call. It's placed in this file to prevent url_request.h |
45 // from having to include network_delegate.h. | 46 // from having to include network_delegate.h. |
46 enum AuthRequiredResponse { | 47 enum AuthRequiredResponse { |
47 AUTH_REQUIRED_RESPONSE_NO_ACTION, | 48 AUTH_REQUIRED_RESPONSE_NO_ACTION, |
48 AUTH_REQUIRED_RESPONSE_SET_AUTH, | 49 AUTH_REQUIRED_RESPONSE_SET_AUTH, |
49 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, | 50 AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, |
50 AUTH_REQUIRED_RESPONSE_IO_PENDING, | 51 AUTH_REQUIRED_RESPONSE_IO_PENDING, |
51 }; | 52 }; |
52 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; | 53 typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; |
53 | 54 |
54 virtual ~NetworkDelegate() {} | 55 virtual ~NetworkDelegate() {} |
55 | 56 |
56 // Notification interface called by the network stack. Note that these | 57 // Notification interface called by the network stack. Note that these |
57 // functions mostly forward to the private virtuals. They also add some sanity | 58 // functions mostly forward to the private virtuals. They also add some sanity |
58 // checking on parameters. See the corresponding virtuals for explanations of | 59 // checking on parameters. See the corresponding virtuals for explanations of |
59 // the methods and their arguments. | 60 // the methods and their arguments. |
60 int NotifyBeforeURLRequest(URLRequest* request, | 61 int NotifyBeforeURLRequest(URLRequest* request, |
61 const CompletionCallback& callback, | 62 const CompletionCallback& callback, |
62 GURL* new_url); | 63 GURL* new_url); |
| 64 void NotifyResolveProxy(const GURL& url, int load_flags, |
| 65 ProxyInfo* result); |
63 int NotifyBeforeSendHeaders(URLRequest* request, | 66 int NotifyBeforeSendHeaders(URLRequest* request, |
64 const CompletionCallback& callback, | 67 const CompletionCallback& callback, |
65 HttpRequestHeaders* headers); | 68 HttpRequestHeaders* headers); |
66 void NotifySendHeaders(URLRequest* request, | 69 void NotifySendHeaders(URLRequest* request, |
67 const HttpRequestHeaders& headers); | 70 const HttpRequestHeaders& headers); |
68 int NotifyHeadersReceived( | 71 int NotifyHeadersReceived( |
69 URLRequest* request, | 72 URLRequest* request, |
70 const CompletionCallback& callback, | 73 const CompletionCallback& callback, |
71 const HttpResponseHeaders* original_response_headers, | 74 const HttpResponseHeaders* original_response_headers, |
72 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 75 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // called for this request. Returns a net status code, generally either OK to | 113 // called for this request. Returns a net status code, generally either OK to |
111 // continue with the request or ERR_IO_PENDING if the result is not ready yet. | 114 // continue with the request or ERR_IO_PENDING if the result is not ready yet. |
112 // A status code other than OK and ERR_IO_PENDING will cancel the request and | 115 // A status code other than OK and ERR_IO_PENDING will cancel the request and |
113 // report the status code as the reason. | 116 // report the status code as the reason. |
114 // | 117 // |
115 // The default implementation returns OK (continue with request). | 118 // The default implementation returns OK (continue with request). |
116 virtual int OnBeforeURLRequest(URLRequest* request, | 119 virtual int OnBeforeURLRequest(URLRequest* request, |
117 const CompletionCallback& callback, | 120 const CompletionCallback& callback, |
118 GURL* new_url); | 121 GURL* new_url); |
119 | 122 |
| 123 // Called as the proxy is being resolved for |url|. Allows the delegate to |
| 124 // override the proxy resolution decision made by ProxyService. The delegate |
| 125 // may override the decision by modifying the ProxyInfo |result|. |
| 126 virtual void OnResolveProxy(const GURL& url, |
| 127 int load_flags, |
| 128 ProxyInfo* result); |
| 129 |
120 // Called right before the HTTP headers are sent. Allows the delegate to | 130 // Called right before the HTTP headers are sent. Allows the delegate to |
121 // read/write |headers| before they get sent out. |callback| and |headers| are | 131 // read/write |headers| before they get sent out. |callback| and |headers| are |
122 // valid only until OnCompleted or OnURLRequestDestroyed is called for this | 132 // valid only until OnCompleted or OnURLRequestDestroyed is called for this |
123 // request. | 133 // request. |
124 // See OnBeforeURLRequest for return value description. Returns OK by default. | 134 // See OnBeforeURLRequest for return value description. Returns OK by default. |
125 virtual int OnBeforeSendHeaders(URLRequest* request, | 135 virtual int OnBeforeSendHeaders(URLRequest* request, |
126 const CompletionCallback& callback, | 136 const CompletionCallback& callback, |
127 HttpRequestHeaders* headers); | 137 HttpRequestHeaders* headers); |
128 | 138 |
129 // Called right before the HTTP request(s) are being sent to the network. | 139 // Called right before the HTTP request(s) are being sent to the network. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 244 |
235 // Called before a SocketStream tries to connect. | 245 // Called before a SocketStream tries to connect. |
236 // See OnBeforeURLRequest for return value description. Returns OK by default. | 246 // See OnBeforeURLRequest for return value description. Returns OK by default. |
237 virtual int OnBeforeSocketStreamConnect( | 247 virtual int OnBeforeSocketStreamConnect( |
238 SocketStream* socket, const CompletionCallback& callback); | 248 SocketStream* socket, const CompletionCallback& callback); |
239 }; | 249 }; |
240 | 250 |
241 } // namespace net | 251 } // namespace net |
242 | 252 |
243 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 253 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
OLD | NEW |