| 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 <stdint.h> | 8 #include <stdint.h> | 
| 9 | 9 | 
| 10 #include <string> | 10 #include <string> | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 31 // submodule. Also, since the lower levels in net/ may callback into higher | 31 // submodule. Also, since the lower levels in net/ may callback into higher | 
| 32 // levels, we may encounter dangerous casting issues. | 32 // levels, we may encounter dangerous casting issues. | 
| 33 // | 33 // | 
| 34 // NOTE: It is not okay to add any compile-time dependencies on symbols outside | 34 // NOTE: It is not okay to add any compile-time dependencies on symbols outside | 
| 35 // of net/base here, because we have a net_base library. Forward declarations | 35 // of net/base here, because we have a net_base library. Forward declarations | 
| 36 // are ok. | 36 // are ok. | 
| 37 class CookieOptions; | 37 class CookieOptions; | 
| 38 class HttpRequestHeaders; | 38 class HttpRequestHeaders; | 
| 39 class HttpResponseHeaders; | 39 class HttpResponseHeaders; | 
| 40 class ProxyInfo; | 40 class ProxyInfo; | 
| 41 class ProxyServer; |  | 
| 42 class ProxyService; |  | 
| 43 class URLRequest; | 41 class URLRequest; | 
| 44 | 42 | 
| 45 class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { | 43 class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { | 
| 46  public: | 44  public: | 
| 47   // AuthRequiredResponse indicates how a NetworkDelegate handles an | 45   // AuthRequiredResponse indicates how a NetworkDelegate handles an | 
| 48   // 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 | 
| 49   // from having to include network_delegate.h. | 47   // from having to include network_delegate.h. | 
| 50   enum AuthRequiredResponse { | 48   enum AuthRequiredResponse { | 
| 51     AUTH_REQUIRED_RESPONSE_NO_ACTION, | 49     AUTH_REQUIRED_RESPONSE_NO_ACTION, | 
| 52     AUTH_REQUIRED_RESPONSE_SET_AUTH, | 50     AUTH_REQUIRED_RESPONSE_SET_AUTH, | 
| 53     AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, | 51     AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, | 
| 54     AUTH_REQUIRED_RESPONSE_IO_PENDING, | 52     AUTH_REQUIRED_RESPONSE_IO_PENDING, | 
| 55   }; | 53   }; | 
| 56   typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; | 54   typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; | 
| 57 | 55 | 
| 58   virtual ~NetworkDelegate() {} | 56   virtual ~NetworkDelegate() {} | 
| 59 | 57 | 
| 60   // Notification interface called by the network stack. Note that these | 58   // Notification interface called by the network stack. Note that these | 
| 61   // 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 | 
| 62   // checking on parameters. See the corresponding virtuals for explanations of | 60   // checking on parameters. See the corresponding virtuals for explanations of | 
| 63   // the methods and their arguments. | 61   // the methods and their arguments. | 
| 64   int NotifyBeforeURLRequest(URLRequest* request, | 62   int NotifyBeforeURLRequest(URLRequest* request, | 
| 65                              const CompletionCallback& callback, | 63                              const CompletionCallback& callback, | 
| 66                              GURL* new_url); | 64                              GURL* new_url); | 
| 67   void NotifyResolveProxy(const GURL& url, |  | 
| 68                           int load_flags, |  | 
| 69                           const ProxyService& proxy_service, |  | 
| 70                           ProxyInfo* result); |  | 
| 71   void NotifyProxyFallback(const ProxyServer& bad_proxy, |  | 
| 72                            int net_error); |  | 
| 73   int NotifyBeforeSendHeaders(URLRequest* request, | 65   int NotifyBeforeSendHeaders(URLRequest* request, | 
| 74                               const CompletionCallback& callback, | 66                               const CompletionCallback& callback, | 
| 75                               HttpRequestHeaders* headers); | 67                               HttpRequestHeaders* headers); | 
| 76   void NotifyBeforeSendProxyHeaders(URLRequest* request, | 68   void NotifyBeforeSendProxyHeaders(URLRequest* request, | 
| 77                                     const ProxyInfo& proxy_info, | 69                                     const ProxyInfo& proxy_info, | 
| 78                                     HttpRequestHeaders* headers); | 70                                     HttpRequestHeaders* headers); | 
| 79   void NotifySendHeaders(URLRequest* request, | 71   void NotifySendHeaders(URLRequest* request, | 
| 80                          const HttpRequestHeaders& headers); | 72                          const HttpRequestHeaders& headers); | 
| 81   int NotifyHeadersReceived( | 73   int NotifyHeadersReceived( | 
| 82       URLRequest* request, | 74       URLRequest* request, | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 133   // called for this request. Returns a net status code, generally either OK to | 125   // called for this request. Returns a net status code, generally either OK to | 
| 134   // continue with the request or ERR_IO_PENDING if the result is not ready yet. | 126   // continue with the request or ERR_IO_PENDING if the result is not ready yet. | 
| 135   // A status code other than OK and ERR_IO_PENDING will cancel the request and | 127   // A status code other than OK and ERR_IO_PENDING will cancel the request and | 
| 136   // report the status code as the reason. | 128   // report the status code as the reason. | 
| 137   // | 129   // | 
| 138   // The default implementation returns OK (continue with request). | 130   // The default implementation returns OK (continue with request). | 
| 139   virtual int OnBeforeURLRequest(URLRequest* request, | 131   virtual int OnBeforeURLRequest(URLRequest* request, | 
| 140                                  const CompletionCallback& callback, | 132                                  const CompletionCallback& callback, | 
| 141                                  GURL* new_url) = 0; | 133                                  GURL* new_url) = 0; | 
| 142 | 134 | 
| 143   // Called as the proxy is being resolved for |url|. Allows the delegate to |  | 
| 144   // override the proxy resolution decision made by ProxyService. The delegate |  | 
| 145   // may override the decision by modifying the ProxyInfo |result|. |  | 
| 146   virtual void OnResolveProxy(const GURL& url, |  | 
| 147                               int load_flags, |  | 
| 148                               const ProxyService& proxy_service, |  | 
| 149                               ProxyInfo* result) = 0; |  | 
| 150 |  | 
| 151   // Called when use of |bad_proxy| fails due to |net_error|. |net_error| is |  | 
| 152   // the network error encountered, if any, and OK if the fallback was |  | 
| 153   // for a reason other than a network error (e.g. the proxy service was |  | 
| 154   // explicitly directed to skip a proxy). |  | 
| 155   virtual void OnProxyFallback(const ProxyServer& bad_proxy, int net_error) = 0; |  | 
| 156 |  | 
| 157   // Called right before the HTTP headers are sent. Allows the delegate to | 135   // Called right before the HTTP headers are sent. Allows the delegate to | 
| 158   // read/write |headers| before they get sent out. |callback| and |headers| are | 136   // read/write |headers| before they get sent out. |callback| and |headers| are | 
| 159   // valid only until OnCompleted or OnURLRequestDestroyed is called for this | 137   // valid only until OnCompleted or OnURLRequestDestroyed is called for this | 
| 160   // request. | 138   // request. | 
| 161   // See OnBeforeURLRequest for return value description. Returns OK by default. | 139   // See OnBeforeURLRequest for return value description. Returns OK by default. | 
| 162   virtual int OnBeforeSendHeaders(URLRequest* request, | 140   virtual int OnBeforeSendHeaders(URLRequest* request, | 
| 163                                   const CompletionCallback& callback, | 141                                   const CompletionCallback& callback, | 
| 164                                   HttpRequestHeaders* headers) = 0; | 142                                   HttpRequestHeaders* headers) = 0; | 
| 165 | 143 | 
| 166   // Called after a proxy connection. Allows the delegate to read/write | 144   // Called after a proxy connection. Allows the delegate to read/write | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 310   // header is stripped from the request. | 288   // header is stripped from the request. | 
| 311   virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 289   virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 
| 312       const URLRequest& request, | 290       const URLRequest& request, | 
| 313       const GURL& target_url, | 291       const GURL& target_url, | 
| 314       const GURL& referrer_url) const = 0; | 292       const GURL& referrer_url) const = 0; | 
| 315 }; | 293 }; | 
| 316 | 294 | 
| 317 }  // namespace net | 295 }  // namespace net | 
| 318 | 296 | 
| 319 #endif  // NET_BASE_NETWORK_DELEGATE_H_ | 297 #endif  // NET_BASE_NETWORK_DELEGATE_H_ | 
| OLD | NEW | 
|---|