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

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: Updated based on design doc discussion 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 9ef8df5387618f4bfb6f4da34620fb68f75978d1..e1e8a39b6f402659691a218d097430cbf3febed8 100644
--- a/net/spdy/spdy_test_util_common.h
+++ b/net/spdy/spdy_test_util_common.h
@@ -17,6 +17,7 @@
#include "crypto/ec_private_key.h"
#include "crypto/ec_signature_creator.h"
#include "net/base/completion_callback.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"
@@ -204,7 +205,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 use_alternative_services;
NetLog* net_log;
};
@@ -583,6 +584,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;
bengr 2016/01/26 23:23:27 Forward declare ProxyInfo.
tbansal1 2016/01/27 00:13:34 Done but is it necessary since this class is overr
+ 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,
bengr 2016/01/26 23:23:27 Forward declare URLRequest.
tbansal1 2016/01/27 00:13:34 Done.
+ const ProxyInfo& proxy_info,
+ HttpRequestHeaders* headers) override;
bengr 2016/01/26 23:23:26 Forward declare HttpRequestHeaders.
tbansal1 2016/01/27 00:13:34 Done.
+ void OnBeforeTunnelRequest(const HostPortPair& proxy_server,
+ HttpRequestHeaders* extra_headers) override;
+ void OnTunnelHeadersReceived(
+ const HostPortPair& origin,
+ const HostPortPair& proxy_server,
+ const HttpResponseHeaders& response_headers) override;
bengr 2016/01/26 23:23:26 Forward declare HttpResponseHeaders.
tbansal1 2016/01/27 00:13:34 Done.
+ bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) const 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_;
bengr 2016/01/26 23:23:27 #include "net/proxy/proxy_server.h"
tbansal1 2016/01/27 00:13:34 Done.
+ HostPortPair on_tunnel_request_completed_endpoint_;
bengr 2016/01/26 23:23:26 #include "net/base/host_port_pair.h"
tbansal1 2016/01/27 00:13:34 Done.
+ 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