| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 int NotifyBeforeSocketStreamConnect(SocketStream* socket, | 96 int NotifyBeforeSocketStreamConnect(SocketStream* socket, |
| 97 const CompletionCallback& callback); | 97 const CompletionCallback& callback); |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 // This is the interface for subclasses of NetworkDelegate to implement. These | 100 // This is the interface for subclasses of NetworkDelegate to implement. These |
| 101 // member functions will be called by the respective public notification | 101 // member functions will be called by the respective public notification |
| 102 // member function, which will perform basic sanity checking. | 102 // member function, which will perform basic sanity checking. |
| 103 | 103 |
| 104 // Called before a request is sent. Allows the delegate to rewrite the URL | 104 // Called before a request is sent. Allows the delegate to rewrite the URL |
| 105 // being fetched by modifying |new_url|. |callback| and |new_url| are valid | 105 // being fetched by modifying |new_url|. If set, the URL must be valid. The |
| 106 // only until OnURLRequestDestroyed is called for this request. Returns a net | 106 // reference fragment from the original URL is not automatically appended to |
| 107 // status code, generally either OK to continue with the request or | 107 // |new_url|; callers are responsible for copying the reference fragment if |
| 108 // ERR_IO_PENDING if the result is not ready yet. A status code other than OK | 108 // desired. |
| 109 // and ERR_IO_PENDING will cancel the request and report the status code as | 109 // |callback| and |new_url| are valid only until OnURLRequestDestroyed is |
| 110 // the reason. | 110 // 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. |
| 112 // A status code other than OK and ERR_IO_PENDING will cancel the request and |
| 113 // report the status code as the reason. |
| 111 // | 114 // |
| 112 // The default implementation returns OK (continue with request). | 115 // The default implementation returns OK (continue with request). |
| 113 virtual int OnBeforeURLRequest(URLRequest* request, | 116 virtual int OnBeforeURLRequest(URLRequest* request, |
| 114 const CompletionCallback& callback, | 117 const CompletionCallback& callback, |
| 115 GURL* new_url); | 118 GURL* new_url); |
| 116 | 119 |
| 117 // Called right before the HTTP headers are sent. Allows the delegate to | 120 // Called right before the HTTP headers are sent. Allows the delegate to |
| 118 // read/write |headers| before they get sent out. |callback| and |headers| are | 121 // read/write |headers| before they get sent out. |callback| and |headers| are |
| 119 // valid only until OnCompleted or OnURLRequestDestroyed is called for this | 122 // valid only until OnCompleted or OnURLRequestDestroyed is called for this |
| 120 // request. | 123 // request. |
| 121 // See OnBeforeURLRequest for return value description. Returns OK by default. | 124 // See OnBeforeURLRequest for return value description. Returns OK by default. |
| 122 virtual int OnBeforeSendHeaders(URLRequest* request, | 125 virtual int OnBeforeSendHeaders(URLRequest* request, |
| 123 const CompletionCallback& callback, | 126 const CompletionCallback& callback, |
| 124 HttpRequestHeaders* headers); | 127 HttpRequestHeaders* headers); |
| 125 | 128 |
| 126 // Called right before the HTTP request(s) are being sent to the network. | 129 // Called right before the HTTP request(s) are being sent to the network. |
| 127 // |headers| is only valid until OnCompleted or OnURLRequestDestroyed is | 130 // |headers| is only valid until OnCompleted or OnURLRequestDestroyed is |
| 128 // called for this request. | 131 // called for this request. |
| 129 virtual void OnSendHeaders(URLRequest* request, | 132 virtual void OnSendHeaders(URLRequest* request, |
| 130 const HttpRequestHeaders& headers); | 133 const HttpRequestHeaders& headers); |
| 131 | 134 |
| 132 // Called for HTTP requests when the headers have been received. | 135 // Called for HTTP requests when the headers have been received. |
| 133 // |original_response_headers| contains the headers as received over the | 136 // |original_response_headers| contains the headers as received over the |
| 134 // network, these must not be modified. |override_response_headers| can be set | 137 // network, these must not be modified. |override_response_headers| can be set |
| 135 // to new values, that should be considered as overriding | 138 // to new values, that should be considered as overriding |
| 136 // |original_response_headers|. | 139 // |original_response_headers|. |
| 140 // If the response is a redirect, and the Location response header value is |
| 141 // identical to |allowed_unsafe_redirect_url|, then the redirect is never |
| 142 // blocked and the reference fragment is not copied from the original URL |
| 143 // to the redirection target. |
| 144 // |
| 137 // |callback|, |original_response_headers|, and |override_response_headers| | 145 // |callback|, |original_response_headers|, and |override_response_headers| |
| 138 // are only valid until OnURLRequestDestroyed is called for this request. | 146 // are only valid until OnURLRequestDestroyed is called for this request. |
| 139 // See OnBeforeURLRequest for return value description. Returns OK by default. | 147 // See OnBeforeURLRequest for return value description. Returns OK by default. |
| 140 virtual int OnHeadersReceived( | 148 virtual int OnHeadersReceived( |
| 141 URLRequest* request, | 149 URLRequest* request, |
| 142 const CompletionCallback& callback, | 150 const CompletionCallback& callback, |
| 143 const HttpResponseHeaders* original_response_headers, | 151 const HttpResponseHeaders* original_response_headers, |
| 144 scoped_refptr<HttpResponseHeaders>* override_response_headers, | 152 scoped_refptr<HttpResponseHeaders>* override_response_headers, |
| 145 GURL* allowed_unsafe_redirect_url); | 153 GURL* allowed_unsafe_redirect_url); |
| 146 | 154 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 234 |
| 227 // Called before a SocketStream tries to connect. | 235 // Called before a SocketStream tries to connect. |
| 228 // See OnBeforeURLRequest for return value description. Returns OK by default. | 236 // See OnBeforeURLRequest for return value description. Returns OK by default. |
| 229 virtual int OnBeforeSocketStreamConnect( | 237 virtual int OnBeforeSocketStreamConnect( |
| 230 SocketStream* socket, const CompletionCallback& callback); | 238 SocketStream* socket, const CompletionCallback& callback); |
| 231 }; | 239 }; |
| 232 | 240 |
| 233 } // namespace net | 241 } // namespace net |
| 234 | 242 |
| 235 #endif // NET_BASE_NETWORK_DELEGATE_H_ | 243 #endif // NET_BASE_NETWORK_DELEGATE_H_ |
| OLD | NEW |