test_proxy_delegate.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2016 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.
  4. #ifndef NET_BASE_TEST_PROXY_DELEGATE_H_
  5. #define NET_BASE_TEST_PROXY_DELEGATE_H_
  6. #include <string>
  7. #include "base/memory/ref_counted.h"
  8. #include "net/base/proxy_delegate.h"
  9. #include "net/base/proxy_server.h"
  10. class GURL;
  11. namespace net {
  12. class ProxyInfo;
  13. class TestProxyDelegate : public ProxyDelegate {
  14. public:
  15. TestProxyDelegate();
  16. ~TestProxyDelegate() override;
  17. bool on_before_tunnel_request_called() const {
  18. return on_before_tunnel_request_called_;
  19. }
  20. void VerifyOnTunnelHeadersReceived(
  21. const ProxyServer& proxy_server,
  22. const std::string& response_header_name,
  23. const std::string& response_header_value) const;
  24. // ProxyDelegate implementation:
  25. void OnResolveProxy(const GURL& url,
  26. const std::string& method,
  27. const ProxyRetryInfoMap& proxy_retry_info,
  28. ProxyInfo* result) override;
  29. void OnFallback(const ProxyServer& bad_proxy, int net_error) override;
  30. void OnBeforeTunnelRequest(const ProxyServer& proxy_server,
  31. HttpRequestHeaders* extra_headers) override;
  32. Error OnTunnelHeadersReceived(
  33. const ProxyServer& proxy_server,
  34. const HttpResponseHeaders& response_headers) override;
  35. private:
  36. bool on_before_tunnel_request_called_ = false;
  37. ProxyServer on_tunnel_headers_received_proxy_server_;
  38. scoped_refptr<HttpResponseHeaders> on_tunnel_headers_received_headers_;
  39. };
  40. } // namespace net
  41. #endif // NET_BASE_TEST_PROXY_DELEGATE_H_