| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PROXY_DELEGATE_H_ | 5 #ifndef NET_BASE_PROXY_DELEGATE_H_ | 
| 6 #define NET_BASE_PROXY_DELEGATE_H_ | 6 #define NET_BASE_PROXY_DELEGATE_H_ | 
| 7 | 7 | 
| 8 #include "base/macros.h" | 8 #include "base/macros.h" | 
| 9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" | 
| 10 | 10 | 
| 11 class GURL; | 11 class GURL; | 
| 12 | 12 | 
| 13 namespace net { | 13 namespace net { | 
| 14 | 14 | 
| 15 class HttpRequestHeaders; | 15 class HttpRequestHeaders; | 
| 16 class HttpResponseHeaders; | 16 class HttpResponseHeaders; | 
| 17 class HostPortPair; | 17 class HostPortPair; | 
| 18 class ProxyInfo; | 18 class ProxyInfo; | 
| 19 class ProxyServer; | 19 class ProxyServer; | 
| 20 class ProxyService; | 20 class ProxyService; | 
| 21 class URLRequest; | 21 class URLRequest; | 
| 22 | 22 | 
| 23 // Delegate for setting up a connection. | 23 // Delegate for setting up a connection. | 
| 24 class NET_EXPORT ProxyDelegate { | 24 class NET_EXPORT ProxyDelegate { | 
| 25  public: | 25  public: | 
| 26   ProxyDelegate() { | 26   ProxyDelegate() {} | 
| 27   } |  | 
| 28 | 27 | 
| 29   virtual ~ProxyDelegate() { | 28   virtual ~ProxyDelegate() {} | 
| 30   } |  | 
| 31 | 29 | 
| 32   // Called as the proxy is being resolved for |url|. Allows the delegate to | 30   // Called as the proxy is being resolved for |url|. Allows the delegate to | 
| 33   // override the proxy resolution decision made by ProxyService. The delegate | 31   // override the proxy resolution decision made by ProxyService. The delegate | 
| 34   // may override the decision by modifying the ProxyInfo |result|. | 32   // may override the decision by modifying the ProxyInfo |result|. | 
| 35   virtual void OnResolveProxy(const GURL& url, | 33   virtual void OnResolveProxy(const GURL& url, | 
| 36                               int load_flags, | 34                               int load_flags, | 
| 37                               const ProxyService& proxy_service, | 35                               const ProxyService& proxy_service, | 
| 38                               ProxyInfo* result) = 0; | 36                               ProxyInfo* result) = 0; | 
| 39 | 37 | 
| 40   // Called when use of |bad_proxy| fails due to |net_error|. |net_error| is | 38   // Called when use of |bad_proxy| fails due to |net_error|. |net_error| is | 
| 41   // the network error encountered, if any, and OK if the fallback was | 39   // the network error encountered, if any, and OK if the fallback was | 
| 42   // for a reason other than a network error (e.g. the proxy service was | 40   // for a reason other than a network error (e.g. the proxy service was | 
| 43   // explicitly directed to skip a proxy). | 41   // explicitly directed to skip a proxy). | 
| 44   virtual void OnFallback(const ProxyServer& bad_proxy, | 42   virtual void OnFallback(const ProxyServer& bad_proxy, int net_error) = 0; | 
| 45                           int net_error) = 0; |  | 
| 46 | 43 | 
| 47   // Called after a proxy connection. Allows the delegate to read/write | 44   // Called after a proxy connection. Allows the delegate to read/write | 
| 48   // |headers| before they get sent out. |headers| is valid only until | 45   // |headers| before they get sent out. |headers| is valid only until | 
| 49   // OnCompleted or OnURLRequestDestroyed is called for this request. | 46   // OnCompleted or OnURLRequestDestroyed is called for this request. | 
| 50   virtual void OnBeforeSendHeaders(URLRequest* request, | 47   virtual void OnBeforeSendHeaders(URLRequest* request, | 
| 51                                    const ProxyInfo& proxy_info, | 48                                    const ProxyInfo& proxy_info, | 
| 52                                    HttpRequestHeaders* headers) = 0; | 49                                    HttpRequestHeaders* headers) = 0; | 
| 53 | 50 | 
| 54   // Called immediately before a proxy tunnel request is sent. | 51   // Called immediately before a proxy tunnel request is sent. | 
| 55   // Provides the embedder an opportunity to add extra request headers. | 52   // Provides the embedder an opportunity to add extra request headers. | 
| 56   virtual void OnBeforeTunnelRequest(const HostPortPair& proxy_server, | 53   virtual void OnBeforeTunnelRequest(const HostPortPair& proxy_server, | 
| 57                                      HttpRequestHeaders* extra_headers) = 0; | 54                                      HttpRequestHeaders* extra_headers) = 0; | 
| 58 | 55 | 
| 59   // Called after the response headers for the tunnel request are received. | 56   // Called after the response headers for the tunnel request are received. | 
| 60   virtual void OnTunnelHeadersReceived( | 57   virtual void OnTunnelHeadersReceived( | 
| 61       const HostPortPair& origin, | 58       const HostPortPair& origin, | 
| 62       const HostPortPair& proxy_server, | 59       const HostPortPair& proxy_server, | 
| 63       const HttpResponseHeaders& response_headers) = 0; | 60       const HttpResponseHeaders& response_headers) = 0; | 
| 64 | 61 | 
| 65  private: | 62  private: | 
| 66   DISALLOW_COPY_AND_ASSIGN(ProxyDelegate); | 63   DISALLOW_COPY_AND_ASSIGN(ProxyDelegate); | 
| 67 }; | 64 }; | 
| 68 |  | 
| 69 } | 65 } | 
| 70 | 66 | 
| 71 #endif  // NET_BASE_PROXY_DELEGATE_H_ | 67 #endif  // NET_BASE_PROXY_DELEGATE_H_ | 
| OLD | NEW | 
|---|