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
3 // found in the LICENSE file.
5 #ifndef NET_BASE_PROXY_DELEGATE_H_
6 #define NET_BASE_PROXY_DELEGATE_H_
8 #include "base/macros.h"
9 #include "net/base/net_export.h"
15 class HttpRequestHeaders
;
16 class HttpResponseHeaders
;
23 // Delegate for setting up a connection.
24 class NET_EXPORT ProxyDelegate
{
29 virtual ~ProxyDelegate() {
32 // Called as the proxy is being resolved for |url|. Allows the delegate to
33 // override the proxy resolution decision made by ProxyService. The delegate
34 // may override the decision by modifying the ProxyInfo |result|.
35 virtual void OnResolveProxy(const GURL
& url
,
37 const ProxyService
& proxy_service
,
38 ProxyInfo
* result
) = 0;
40 // 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
42 // for a reason other than a network error (e.g. the proxy service was
43 // explicitly directed to skip a proxy).
44 virtual void OnFallback(const ProxyServer
& bad_proxy
,
47 // Called after a proxy connection. Allows the delegate to read/write
48 // |headers| before they get sent out. |headers| is valid only until
49 // OnCompleted or OnURLRequestDestroyed is called for this request.
50 virtual void OnBeforeSendHeaders(URLRequest
* request
,
51 const ProxyInfo
& proxy_info
,
52 HttpRequestHeaders
* headers
) = 0;
54 // Called immediately before a proxy tunnel request is sent.
55 // Provides the embedder an opportunity to add extra request headers.
56 virtual void OnBeforeTunnelRequest(const HostPortPair
& proxy_server
,
57 HttpRequestHeaders
* extra_headers
) = 0;
59 // Called after the response headers for the tunnel request are received.
60 virtual void OnTunnelHeadersReceived(
61 const HostPortPair
& origin
,
62 const HostPortPair
& proxy_server
,
63 const HttpResponseHeaders
& response_headers
) = 0;
66 DISALLOW_COPY_AND_ASSIGN(ProxyDelegate
);
71 #endif // NET_BASE_PROXY_DELEGATE_H_