Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1866)

Unified Diff: net/spdy/spdy_test_util_common.h

Issue 1547273003: Set trusted SPDY proxy dynamically on per-profile basis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mmenke comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/spdy/spdy_test_util_common.h
diff --git a/net/spdy/spdy_test_util_common.h b/net/spdy/spdy_test_util_common.h
index ed519366340f4d5dda5eeef03359ff42f298f15c..9b693cd9ed0b5fd4ffd4fd9bc28277f143c9b1b8 100644
--- a/net/spdy/spdy_test_util_common.h
+++ b/net/spdy/spdy_test_util_common.h
@@ -17,6 +17,8 @@
#include "crypto/ec_private_key.h"
#include "crypto/ec_signature_creator.h"
#include "net/base/completion_callback.h"
+#include "net/base/host_port_pair.h"
+#include "net/base/proxy_delegate.h"
#include "net/base/request_priority.h"
#include "net/base/test_completion_callback.h"
#include "net/cert/cert_verifier.h"
@@ -26,6 +28,7 @@
#include "net/http/http_response_info.h"
#include "net/http/http_server_properties_impl.h"
#include "net/http/transport_security_state.h"
+#include "net/proxy/proxy_server.h"
#include "net/proxy/proxy_service.h"
#include "net/socket/next_proto.h"
#include "net/socket/socket_test_util.h"
@@ -40,11 +43,15 @@ class GURL;
namespace net {
class BoundNetLog;
+class HttpRequestHeaders;
+class HttpResponseHeaders;
+class ProxyInfo;
class SpdySession;
class SpdySessionKey;
class SpdySessionPool;
class SpdyStream;
class SpdyStreamRequest;
+class URLRequest;
// Default upload data used by both, mock objects and framer when creating
// data frames.
@@ -205,7 +212,7 @@ struct SpdySessionDependencies {
size_t stream_max_recv_window_size;
SpdySession::TimeFunc time_func;
NextProtoVector next_protos;
- std::string trusted_spdy_proxy;
+ scoped_ptr<ProxyDelegate> proxy_delegate;
bool parse_alternative_services;
bool enable_alternative_service_with_different_host;
NetLog* net_log;
@@ -585,6 +592,66 @@ class SpdyTestUtil {
std::map<int, std::vector<int>> priority_to_stream_id_list_;
};
+class TestProxyDelegate : public ProxyDelegate {
+ public:
+ TestProxyDelegate();
+ ~TestProxyDelegate() override;
+
+ bool on_before_tunnel_request_called() const {
+ return on_before_tunnel_request_called_;
+ }
+
+ bool on_tunnel_request_completed_called() const {
+ return on_tunnel_request_completed_called_;
+ }
+
+ bool on_tunnel_headers_received_called() const {
+ return on_tunnel_headers_received_called_;
+ }
+
+ void set_trusted_spdy_proxy(const net::ProxyServer& proxy_server) {
+ trusted_spdy_proxy_ = proxy_server;
+ }
+
+ void VerifyOnTunnelRequestCompleted(const std::string& endpoint,
+ const std::string& proxy_server) const;
+
+ void VerifyOnTunnelHeadersReceived(const std::string& origin,
+ const std::string& proxy_server,
+ const std::string& status_line) const;
+
+ // ProxyDelegate implementation:
+ void OnResolveProxy(const GURL& url,
+ int load_flags,
+ const ProxyService& proxy_service,
+ ProxyInfo* result) override;
+ void OnTunnelConnectCompleted(const HostPortPair& endpoint,
+ const HostPortPair& proxy_server,
+ int net_error) override;
+ void OnFallback(const ProxyServer& bad_proxy, int net_error) override;
+ void OnBeforeSendHeaders(URLRequest* request,
+ const ProxyInfo& proxy_info,
+ HttpRequestHeaders* headers) override;
+ void OnBeforeTunnelRequest(const HostPortPair& proxy_server,
+ HttpRequestHeaders* extra_headers) override;
+ void OnTunnelHeadersReceived(
+ const HostPortPair& origin,
+ const HostPortPair& proxy_server,
+ const HttpResponseHeaders& response_headers) override;
+ bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) override;
+
+ private:
+ bool on_before_tunnel_request_called_;
+ bool on_tunnel_request_completed_called_;
+ bool on_tunnel_headers_received_called_;
+ net::ProxyServer trusted_spdy_proxy_;
+ HostPortPair on_tunnel_request_completed_endpoint_;
+ HostPortPair on_tunnel_request_completed_proxy_server_;
+ HostPortPair on_tunnel_headers_received_origin_;
+ HostPortPair on_tunnel_headers_received_proxy_server_;
+ std::string on_tunnel_headers_received_status_line_;
+};
+
} // namespace net
#endif // NET_SPDY_SPDY_TEST_UTIL_COMMON_H_

Powered by Google App Engine
This is Rietveld 408576698