• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_BASE_TEST_PROXY_DELEGATE_H_
6 #define NET_BASE_TEST_PROXY_DELEGATE_H_
7 
8 #include <string>
9 
10 #include "base/memory/scoped_refptr.h"
11 #include "net/base/proxy_delegate.h"
12 #include "net/base/proxy_server.h"
13 
14 class GURL;
15 
16 namespace net {
17 
18 class ProxyInfo;
19 
20 class TestProxyDelegate : public ProxyDelegate {
21  public:
22   TestProxyDelegate();
23   ~TestProxyDelegate() override;
24 
on_before_tunnel_request_called()25   bool on_before_tunnel_request_called() const {
26     return on_before_tunnel_request_called_;
27   }
28 
29   void VerifyOnTunnelHeadersReceived(
30       const ProxyServer& proxy_server,
31       const std::string& response_header_name,
32       const std::string& response_header_value) const;
33 
34   // ProxyDelegate implementation:
35   void OnResolveProxy(const GURL& url,
36                       const std::string& method,
37                       const ProxyRetryInfoMap& proxy_retry_info,
38                       ProxyInfo* result) override;
39   void OnFallback(const ProxyServer& bad_proxy, int net_error) override;
40   void OnBeforeTunnelRequest(const ProxyServer& proxy_server,
41                              HttpRequestHeaders* extra_headers) override;
42   Error OnTunnelHeadersReceived(
43       const ProxyServer& proxy_server,
44       const HttpResponseHeaders& response_headers) override;
45 
46  private:
47   bool on_before_tunnel_request_called_ = false;
48   ProxyServer on_tunnel_headers_received_proxy_server_;
49   scoped_refptr<HttpResponseHeaders> on_tunnel_headers_received_headers_;
50 };
51 
52 }  // namespace net
53 
54 #endif  // NET_BASE_TEST_PROXY_DELEGATE_H_
55