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

Unified Diff: net/base/test_proxy_delegate.cc

Issue 1547273003: Set trusted SPDY proxy dynamically on per-profile basis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added net/base/test_proxy_delegate.{h,cc} 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
« no previous file with comments | « net/base/test_proxy_delegate.h ('k') | net/http/http_network_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/test_proxy_delegate.cc
diff --git a/net/base/test_proxy_delegate.cc b/net/base/test_proxy_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d4a3c61712f13e98eaa13454dc24fffa76627681
--- /dev/null
+++ b/net/base/test_proxy_delegate.cc
@@ -0,0 +1,86 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/test_proxy_delegate.h"
+
+#include "net/http/http_request_headers.h"
+#include "net/http/http_response_headers.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+TestProxyDelegate::TestProxyDelegate()
+ : on_before_tunnel_request_called_(false),
+ on_tunnel_request_completed_called_(false),
+ on_tunnel_headers_received_called_(false) {}
+
+TestProxyDelegate::~TestProxyDelegate() {}
+
+void TestProxyDelegate::VerifyOnTunnelRequestCompleted(
+ const std::string& endpoint,
+ const std::string& proxy_server) const {
+ EXPECT_TRUE(on_tunnel_request_completed_called_);
+ EXPECT_TRUE(HostPortPair::FromString(endpoint).Equals(
+ on_tunnel_request_completed_endpoint_));
+ EXPECT_TRUE(HostPortPair::FromString(proxy_server)
+ .Equals(on_tunnel_request_completed_proxy_server_));
+}
+
+void TestProxyDelegate::VerifyOnTunnelHeadersReceived(
+ const std::string& origin,
+ const std::string& proxy_server,
+ const std::string& status_line) const {
+ EXPECT_TRUE(on_tunnel_headers_received_called_);
+ EXPECT_TRUE(HostPortPair::FromString(origin).Equals(
+ on_tunnel_headers_received_origin_));
+ EXPECT_TRUE(HostPortPair::FromString(proxy_server)
+ .Equals(on_tunnel_headers_received_proxy_server_));
+ EXPECT_EQ(status_line, on_tunnel_headers_received_status_line_);
+}
+
+void TestProxyDelegate::OnResolveProxy(const GURL& url,
+ int load_flags,
+ const ProxyService& proxy_service,
+ ProxyInfo* result) {}
+
+void TestProxyDelegate::OnTunnelConnectCompleted(
+ const HostPortPair& endpoint,
+ const HostPortPair& proxy_server,
+ int net_error) {
+ on_tunnel_request_completed_called_ = true;
+ on_tunnel_request_completed_endpoint_ = endpoint;
+ on_tunnel_request_completed_proxy_server_ = proxy_server;
+}
+
+void TestProxyDelegate::OnFallback(const ProxyServer& bad_proxy,
+ int net_error) {}
+
+void TestProxyDelegate::OnBeforeSendHeaders(URLRequest* request,
+ const ProxyInfo& proxy_info,
+ HttpRequestHeaders* headers) {}
+
+void TestProxyDelegate::OnBeforeTunnelRequest(
+ const HostPortPair& proxy_server,
+ HttpRequestHeaders* extra_headers) {
+ on_before_tunnel_request_called_ = true;
+ if (extra_headers)
+ extra_headers->SetHeader("Foo", proxy_server.ToString());
+}
+
+void TestProxyDelegate::OnTunnelHeadersReceived(
+ const HostPortPair& origin,
+ const HostPortPair& proxy_server,
+ const HttpResponseHeaders& response_headers) {
+ on_tunnel_headers_received_called_ = true;
+ on_tunnel_headers_received_origin_ = origin;
+ on_tunnel_headers_received_proxy_server_ = proxy_server;
+ on_tunnel_headers_received_status_line_ = response_headers.GetStatusLine();
+}
+
+bool TestProxyDelegate::IsTrustedSpdyProxy(
+ const net::ProxyServer& proxy_server) {
+ return proxy_server.is_valid() && trusted_spdy_proxy_ == proxy_server;
+}
+
+} // namespace net
« no previous file with comments | « net/base/test_proxy_delegate.h ('k') | net/http/http_network_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698