Commit 5f86fe20 authored by Maks Orlovich's avatar Maks Orlovich Committed by Commit Bot

ProxyResolvingSocketFactory: support "fake SSL" mode for XMPP.

This is arguably way too weird to have at this level, but
jingle_glue::FakesSSLClientSocket is already pulled in via
services/network/p2p, and the alternative would require hundreds
of lines of new code to implement rather than basically a single
if statement.

Bug: 875032
Change-Id: I6fa2007b907378e43f1a619112f812e3d0bbfd50
Reviewed-on: https://chromium-review.googlesource.com/c/1310638Reviewed-by: default avatarNicolas Zea <zea@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605399}
parent 0a2ee0a3
...@@ -222,8 +222,11 @@ void GCMSocketStreamTest::OpenConnection() { ...@@ -222,8 +222,11 @@ void GCMSocketStreamTest::OpenConnection() {
base::RunLoop run_loop; base::RunLoop run_loop;
int net_error = net::ERR_FAILED; int net_error = net::ERR_FAILED;
const GURL kDestination("https://example.com"); const GURL kDestination("https://example.com");
network::mojom::ProxyResolvingSocketOptionsPtr options =
network::mojom::ProxyResolvingSocketOptions::New();
options->use_tls = true;
mojo_socket_factory_ptr_->CreateProxyResolvingSocket( mojo_socket_factory_ptr_->CreateProxyResolvingSocket(
kDestination, true /* use_tls */, kDestination, std::move(options),
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS), net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS),
mojo::MakeRequest(&mojo_socket_ptr_), nullptr /* observer */, mojo::MakeRequest(&mojo_socket_ptr_), nullptr /* observer */,
base::BindLambdaForTesting( base::BindLambdaForTesting(
......
...@@ -348,8 +348,11 @@ void ConnectionFactoryImpl::StartConnection() { ...@@ -348,8 +348,11 @@ void ConnectionFactoryImpl::StartConnection() {
"but does not have any effect on other Google Cloud messages." "but does not have any effect on other Google Cloud messages."
)"); )");
network::mojom::ProxyResolvingSocketOptionsPtr options =
network::mojom::ProxyResolvingSocketOptions::New();
options->use_tls = true;
socket_factory_->CreateProxyResolvingSocket( socket_factory_->CreateProxyResolvingSocket(
current_endpoint, true /* use_tls */, current_endpoint, std::move(options),
net::MutableNetworkTrafficAnnotationTag(traffic_annotation), net::MutableNetworkTrafficAnnotationTag(traffic_annotation),
mojo::MakeRequest(&socket_), nullptr /* observer */, mojo::MakeRequest(&socket_), nullptr /* observer */,
base::BindOnce(&ConnectionFactoryImpl::OnConnectDone, base::BindOnce(&ConnectionFactoryImpl::OnConnectDone,
......
...@@ -236,8 +236,11 @@ void GCMConnectionHandlerImplTest::BuildSocket(const ReadList& read_list, ...@@ -236,8 +236,11 @@ void GCMConnectionHandlerImplTest::BuildSocket(const ReadList& read_list,
base::RunLoop run_loop; base::RunLoop run_loop;
int net_error = net::ERR_FAILED; int net_error = net::ERR_FAILED;
const GURL kDestination("https://example.com"); const GURL kDestination("https://example.com");
network::mojom::ProxyResolvingSocketOptionsPtr options =
network::mojom::ProxyResolvingSocketOptions::New();
options->use_tls = true;
mojo_socket_factory_ptr_->CreateProxyResolvingSocket( mojo_socket_factory_ptr_->CreateProxyResolvingSocket(
kDestination, true /* use_tls */, kDestination, std::move(options),
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS), net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS),
mojo::MakeRequest(&mojo_socket_ptr_), nullptr /* observer */, mojo::MakeRequest(&mojo_socket_ptr_), nullptr /* observer */,
base::BindLambdaForTesting( base::BindLambdaForTesting(
......
...@@ -102,6 +102,20 @@ int FakeSSLClientSocket::Read(net::IOBuffer* buf, ...@@ -102,6 +102,20 @@ int FakeSSLClientSocket::Read(net::IOBuffer* buf,
return transport_socket_->Read(buf, buf_len, std::move(callback)); return transport_socket_->Read(buf, buf_len, std::move(callback));
} }
int FakeSSLClientSocket::ReadIfReady(net::IOBuffer* buf,
int buf_len,
net::CompletionOnceCallback callback) {
DCHECK_EQ(next_handshake_state_, STATE_NONE);
DCHECK(handshake_completed_);
return transport_socket_->ReadIfReady(buf, buf_len, std::move(callback));
}
int FakeSSLClientSocket::CancelReadIfReady() {
DCHECK_EQ(next_handshake_state_, STATE_NONE);
DCHECK(handshake_completed_);
return transport_socket_->CancelReadIfReady();
}
int FakeSSLClientSocket::Write( int FakeSSLClientSocket::Write(
net::IOBuffer* buf, net::IOBuffer* buf,
int buf_len, int buf_len,
......
...@@ -51,6 +51,10 @@ class FakeSSLClientSocket : public net::StreamSocket { ...@@ -51,6 +51,10 @@ class FakeSSLClientSocket : public net::StreamSocket {
int Read(net::IOBuffer* buf, int Read(net::IOBuffer* buf,
int buf_len, int buf_len,
net::CompletionOnceCallback callback) override; net::CompletionOnceCallback callback) override;
int ReadIfReady(net::IOBuffer* buf,
int buf_len,
net::CompletionOnceCallback callback) override;
int CancelReadIfReady() override;
int Write( int Write(
net::IOBuffer* buf, net::IOBuffer* buf,
int buf_len, int buf_len,
......
...@@ -22,11 +22,13 @@ namespace jingle_glue { ...@@ -22,11 +22,13 @@ namespace jingle_glue {
NetworkServiceAsyncSocket::NetworkServiceAsyncSocket( NetworkServiceAsyncSocket::NetworkServiceAsyncSocket(
GetProxyResolvingFactoryCallback get_socket_factory_callback, GetProxyResolvingFactoryCallback get_socket_factory_callback,
bool use_fake_tls_handshake,
size_t read_buf_size, size_t read_buf_size,
size_t write_buf_size, size_t write_buf_size,
const net::NetworkTrafficAnnotationTag& traffic_annotation) const net::NetworkTrafficAnnotationTag& traffic_annotation)
: get_socket_factory_callback_(get_socket_factory_callback), : get_socket_factory_callback_(get_socket_factory_callback),
socket_observer_binding_(this), socket_observer_binding_(this),
use_fake_tls_handshake_(use_fake_tls_handshake),
state_(STATE_CLOSED), state_(STATE_CLOSED),
error_(ERROR_NONE), error_(ERROR_NONE),
net_error_(net::OK), net_error_(net::OK),
...@@ -160,8 +162,12 @@ bool NetworkServiceAsyncSocket::Connect(const rtc::SocketAddress& address) { ...@@ -160,8 +162,12 @@ bool NetworkServiceAsyncSocket::Connect(const rtc::SocketAddress& address) {
network::mojom::SocketObserverPtr socket_observer; network::mojom::SocketObserverPtr socket_observer;
network::mojom::SocketObserverRequest socket_observer_request = network::mojom::SocketObserverRequest socket_observer_request =
mojo::MakeRequest(&socket_observer); mojo::MakeRequest(&socket_observer);
network::mojom::ProxyResolvingSocketOptionsPtr options =
network::mojom::ProxyResolvingSocketOptions::New();
options->use_tls = false;
options->fake_tls_handshake = use_fake_tls_handshake_;
socket_factory_->CreateProxyResolvingSocket( socket_factory_->CreateProxyResolvingSocket(
GURL("https://" + dest_host_port_pair.ToString()), false /*use_tls*/, GURL("https://" + dest_host_port_pair.ToString()), std::move(options),
net::MutableNetworkTrafficAnnotationTag(traffic_annotation_), net::MutableNetworkTrafficAnnotationTag(traffic_annotation_),
mojo::MakeRequest(&socket_), std::move(socket_observer), mojo::MakeRequest(&socket_), std::move(socket_observer),
base::BindOnce(&NetworkServiceAsyncSocket::ProcessConnectDone, base::BindOnce(&NetworkServiceAsyncSocket::ProcessConnectDone,
......
...@@ -34,6 +34,7 @@ class NetworkServiceAsyncSocket : public buzz::AsyncSocket, ...@@ -34,6 +34,7 @@ class NetworkServiceAsyncSocket : public buzz::AsyncSocket,
public: public:
NetworkServiceAsyncSocket( NetworkServiceAsyncSocket(
GetProxyResolvingFactoryCallback get_socket_factory_callback, GetProxyResolvingFactoryCallback get_socket_factory_callback,
bool use_fake_tls_handshake,
size_t read_buf_size, size_t read_buf_size,
size_t write_buf_size, size_t write_buf_size,
const net::NetworkTrafficAnnotationTag& traffic_annotation); const net::NetworkTrafficAnnotationTag& traffic_annotation);
...@@ -212,6 +213,8 @@ class NetworkServiceAsyncSocket : public buzz::AsyncSocket, ...@@ -212,6 +213,8 @@ class NetworkServiceAsyncSocket : public buzz::AsyncSocket,
// Used to route error notifications here. // Used to route error notifications here.
mojo::Binding<network::mojom::SocketObserver> socket_observer_binding_; mojo::Binding<network::mojom::SocketObserver> socket_observer_binding_;
bool use_fake_tls_handshake_;
// buzz::AsyncSocket state. // buzz::AsyncSocket state.
buzz::AsyncSocket::State state_; buzz::AsyncSocket::State state_;
buzz::AsyncSocket::Error error_; buzz::AsyncSocket::Error error_;
......
...@@ -187,7 +187,7 @@ class MockProxyResolvingSocketFactory ...@@ -187,7 +187,7 @@ class MockProxyResolvingSocketFactory
// mojom::ProxyResolvingSocketFactory implementation. // mojom::ProxyResolvingSocketFactory implementation.
void CreateProxyResolvingSocket( void CreateProxyResolvingSocket(
const GURL& url, const GURL& url,
bool use_tls, network::mojom::ProxyResolvingSocketOptionsPtr options,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
network::mojom::ProxyResolvingSocketRequest request, network::mojom::ProxyResolvingSocketRequest request,
network::mojom::SocketObserverPtr observer, network::mojom::SocketObserverPtr observer,
...@@ -317,6 +317,7 @@ class NetworkServiceAsyncSocketTest : public testing::Test, ...@@ -317,6 +317,7 @@ class NetworkServiceAsyncSocketTest : public testing::Test,
base::BindRepeating( base::BindRepeating(
&NetworkServiceAsyncSocketTest::BindToProxyResolvingSocketFactory, &NetworkServiceAsyncSocketTest::BindToProxyResolvingSocketFactory,
base::Unretained(this)), base::Unretained(this)),
false, /* use_fake_tls_handshake */
14, 20, TRAFFIC_ANNOTATION_FOR_TESTS)); 14, 20, TRAFFIC_ANNOTATION_FOR_TESTS));
ns_async_socket_->SignalConnected.connect( ns_async_socket_->SignalConnected.connect(
......
...@@ -10,6 +10,8 @@ include_rules = [ ...@@ -10,6 +10,8 @@ include_rules = [
"+components/prefs", "+components/prefs",
"+crypto", "+crypto",
"+ipc", "+ipc",
# FakeSSLClientSocket
"+jingle/glue",
"+net", "+net",
"+sandbox", "+sandbox",
"+services/proxy_resolver/public/mojom", "+services/proxy_resolver/public/mojom",
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "jingle/glue/fake_ssl_client_socket.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "services/network/proxy_resolving_client_socket.h" #include "services/network/proxy_resolving_client_socket.h"
#include "services/network/proxy_resolving_client_socket_factory.h" #include "services/network/proxy_resolving_client_socket_factory.h"
...@@ -24,13 +25,19 @@ ProxyResolvingSocketFactoryMojo::~ProxyResolvingSocketFactoryMojo() {} ...@@ -24,13 +25,19 @@ ProxyResolvingSocketFactoryMojo::~ProxyResolvingSocketFactoryMojo() {}
void ProxyResolvingSocketFactoryMojo::CreateProxyResolvingSocket( void ProxyResolvingSocketFactoryMojo::CreateProxyResolvingSocket(
const GURL& url, const GURL& url,
bool use_tls, mojom::ProxyResolvingSocketOptionsPtr options,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
mojom::ProxyResolvingSocketRequest request, mojom::ProxyResolvingSocketRequest request,
mojom::SocketObserverPtr observer, mojom::SocketObserverPtr observer,
CreateProxyResolvingSocketCallback callback) { CreateProxyResolvingSocketCallback callback) {
std::unique_ptr<net::StreamSocket> net_socket =
factory_impl_.CreateSocket(url, options && options->use_tls);
if (options && options->fake_tls_handshake)
net_socket = std::make_unique<jingle_glue::FakeSSLClientSocket>(
std::move(net_socket));
auto socket = std::make_unique<ProxyResolvingSocketMojo>( auto socket = std::make_unique<ProxyResolvingSocketMojo>(
factory_impl_.CreateSocket(url, use_tls), std::move(net_socket),
static_cast<net::NetworkTrafficAnnotationTag>(traffic_annotation), static_cast<net::NetworkTrafficAnnotationTag>(traffic_annotation),
std::move(observer), &tls_socket_factory_); std::move(observer), &tls_socket_factory_);
ProxyResolvingSocketMojo* socket_raw = socket.get(); ProxyResolvingSocketMojo* socket_raw = socket.get();
......
...@@ -31,7 +31,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyResolvingSocketFactoryMojo ...@@ -31,7 +31,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyResolvingSocketFactoryMojo
// mojom::ProxyResolvingSocketFactory implementation. // mojom::ProxyResolvingSocketFactory implementation.
void CreateProxyResolvingSocket( void CreateProxyResolvingSocket(
const GURL& url, const GURL& url,
bool use_tls, mojom::ProxyResolvingSocketOptionsPtr options,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
mojom::ProxyResolvingSocketRequest request, mojom::ProxyResolvingSocketRequest request,
mojom::SocketObserverPtr observer, mojom::SocketObserverPtr observer,
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
namespace network { namespace network {
ProxyResolvingSocketMojo::ProxyResolvingSocketMojo( ProxyResolvingSocketMojo::ProxyResolvingSocketMojo(
std::unique_ptr<ProxyResolvingClientSocket> socket, std::unique_ptr<net::StreamSocket> socket,
const net::NetworkTrafficAnnotationTag& traffic_annotation, const net::NetworkTrafficAnnotationTag& traffic_annotation,
mojom::SocketObserverPtr observer, mojom::SocketObserverPtr observer,
TLSSocketFactory* tls_socket_factory) TLSSocketFactory* tls_socket_factory)
......
...@@ -26,7 +26,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyResolvingSocketMojo ...@@ -26,7 +26,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyResolvingSocketMojo
public TLSSocketFactory::Delegate { public TLSSocketFactory::Delegate {
public: public:
ProxyResolvingSocketMojo( ProxyResolvingSocketMojo(
std::unique_ptr<ProxyResolvingClientSocket> socket, std::unique_ptr<net::StreamSocket> socket,
const net::NetworkTrafficAnnotationTag& traffic_annotation, const net::NetworkTrafficAnnotationTag& traffic_annotation,
mojom::SocketObserverPtr observer, mojom::SocketObserverPtr observer,
TLSSocketFactory* tls_socket_factory); TLSSocketFactory* tls_socket_factory);
...@@ -57,7 +57,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyResolvingSocketMojo ...@@ -57,7 +57,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) ProxyResolvingSocketMojo
mojom::SocketObserverPtr observer_; mojom::SocketObserverPtr observer_;
TLSSocketFactory* tls_socket_factory_; TLSSocketFactory* tls_socket_factory_;
std::unique_ptr<ProxyResolvingClientSocket> socket_; std::unique_ptr<net::StreamSocket> socket_;
const net::NetworkTrafficAnnotationTag traffic_annotation_; const net::NetworkTrafficAnnotationTag traffic_annotation_;
mojom::ProxyResolvingSocketFactory::CreateProxyResolvingSocketCallback mojom::ProxyResolvingSocketFactory::CreateProxyResolvingSocketCallback
connect_callback_; connect_callback_;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "jingle/glue/fake_ssl_client_socket.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/system/data_pipe_utils.h" #include "mojo/public/cpp/system/data_pipe_utils.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
...@@ -54,6 +55,7 @@ class ProxyResolvingSocketTestBase { ...@@ -54,6 +55,7 @@ class ProxyResolvingSocketTestBase {
public: public:
ProxyResolvingSocketTestBase(bool use_tls) ProxyResolvingSocketTestBase(bool use_tls)
: use_tls_(use_tls), : use_tls_(use_tls),
fake_tls_handshake_(false),
scoped_task_environment_( scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::IO) {} base::test::ScopedTaskEnvironment::MainThreadType::IO) {}
...@@ -114,8 +116,12 @@ class ProxyResolvingSocketTestBase { ...@@ -114,8 +116,12 @@ class ProxyResolvingSocketTestBase {
mojo::ScopedDataPipeProducerHandle* send_pipe_handle_out) { mojo::ScopedDataPipeProducerHandle* send_pipe_handle_out) {
base::RunLoop run_loop; base::RunLoop run_loop;
int net_error = net::ERR_FAILED; int net_error = net::ERR_FAILED;
network::mojom::ProxyResolvingSocketOptionsPtr options =
network::mojom::ProxyResolvingSocketOptions::New();
options->use_tls = use_tls_;
options->fake_tls_handshake = fake_tls_handshake_;
factory_ptr_->CreateProxyResolvingSocket( factory_ptr_->CreateProxyResolvingSocket(
url, use_tls_, url, std::move(options),
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS), net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS),
std::move(request), std::move(socket_observer), std::move(request), std::move(socket_observer),
base::BindLambdaForTesting( base::BindLambdaForTesting(
...@@ -141,11 +147,13 @@ class ProxyResolvingSocketTestBase { ...@@ -141,11 +147,13 @@ class ProxyResolvingSocketTestBase {
} }
bool use_tls() const { return use_tls_; } bool use_tls() const { return use_tls_; }
void set_fake_tls_handshake(bool val) { fake_tls_handshake_ = val; }
mojom::ProxyResolvingSocketFactory* factory() { return factory_ptr_.get(); } mojom::ProxyResolvingSocketFactory* factory() { return factory_ptr_.get(); }
private: private:
const bool use_tls_; const bool use_tls_;
bool fake_tls_handshake_;
base::test::ScopedTaskEnvironment scoped_task_environment_; base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<net::MockClientSocketFactory> mock_client_socket_factory_; std::unique_ptr<net::MockClientSocketFactory> mock_client_socket_factory_;
std::unique_ptr<TestURLRequestContextWithProxy> context_with_proxy_; std::unique_ptr<TestURLRequestContextWithProxy> context_with_proxy_;
...@@ -334,6 +342,45 @@ class ProxyResolvingSocketMojoTest : public ProxyResolvingSocketTestBase, ...@@ -334,6 +342,45 @@ class ProxyResolvingSocketMojoTest : public ProxyResolvingSocketTestBase,
DISALLOW_COPY_AND_ASSIGN(ProxyResolvingSocketMojoTest); DISALLOW_COPY_AND_ASSIGN(ProxyResolvingSocketMojoTest);
}; };
TEST_F(ProxyResolvingSocketMojoTest, ConnectWithFakeTLSHandshake) {
const GURL kDestination("https://example.com:443");
const char kTestMsg[] = "abcdefghij";
const size_t kMsgSize = strlen(kTestMsg);
Init("DIRECT");
set_fake_tls_handshake(true);
base::StringPiece client_hello =
jingle_glue::FakeSSLClientSocket::GetSslClientHello();
base::StringPiece server_hello =
jingle_glue::FakeSSLClientSocket::GetSslServerHello();
std::vector<net::MockRead> reads = {
net::MockRead(net::ASYNC, server_hello.data(), server_hello.length(), 1),
net::MockRead(net::ASYNC, 2, kTestMsg),
net::MockRead(net::ASYNC, net::OK, 3)};
std::vector<net::MockWrite> writes = {net::MockWrite(
net::ASYNC, client_hello.data(), client_hello.length(), 0)};
net::StaticSocketDataProvider data_provider(reads, writes);
data_provider.set_connect_data(net::MockConnect(net::ASYNC, net::OK));
mock_client_socket_factory()->AddSocketDataProvider(&data_provider);
mojom::ProxyResolvingSocketPtr socket;
mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle;
mojo::ScopedDataPipeProducerHandle client_socket_send_handle;
net::IPEndPoint actual_remote_addr;
EXPECT_EQ(net::OK,
CreateSocketSync(mojo::MakeRequest(&socket),
nullptr /* socket_observer*/, &actual_remote_addr,
kDestination, &client_socket_receive_handle,
&client_socket_send_handle));
EXPECT_EQ(kTestMsg, Read(&client_socket_receive_handle, kMsgSize));
EXPECT_TRUE(data_provider.AllReadDataConsumed());
EXPECT_TRUE(data_provider.AllWriteDataConsumed());
}
// Tests that when ProxyResolvingSocketPtr is destroyed but not the // Tests that when ProxyResolvingSocketPtr is destroyed but not the
// ProxyResolvingSocketFactory, the connect callback is not dropped. // ProxyResolvingSocketFactory, the connect callback is not dropped.
// Regression test for https://crbug.com/862608. // Regression test for https://crbug.com/862608.
...@@ -350,7 +397,7 @@ TEST_F(ProxyResolvingSocketMojoTest, SocketDestroyedBeforeConnectCompletes) { ...@@ -350,7 +397,7 @@ TEST_F(ProxyResolvingSocketMojoTest, SocketDestroyedBeforeConnectCompletes) {
base::RunLoop run_loop; base::RunLoop run_loop;
int net_error = net::OK; int net_error = net::OK;
factory()->CreateProxyResolvingSocket( factory()->CreateProxyResolvingSocket(
kDestination, false, kDestination, nullptr,
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS), net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS),
mojo::MakeRequest(&socket), nullptr /* observer */, mojo::MakeRequest(&socket), nullptr /* observer */,
base::BindLambdaForTesting( base::BindLambdaForTesting(
......
...@@ -36,14 +36,23 @@ interface ProxyResolvingSocket { ...@@ -36,14 +36,23 @@ interface ProxyResolvingSocket {
handle<data_pipe_producer>? send_stream); handle<data_pipe_producer>? send_stream);
}; };
struct ProxyResolvingSocketOptions {
// Establish a TLS connection on top of the TCP connection.
bool use_tls = false;
// Tries to do a fake TLS handshake on the connection.
// This is sometimes used with XMPP to pass through proxies.
// See jingle_glue::FakeSSLClientSocket for more details.
bool fake_tls_handshake = false;
};
// Factory interface for creating ProxyResolvingSocket. Each factory instance // Factory interface for creating ProxyResolvingSocket. Each factory instance
// has separate socket pools from the NetworkContext which created the // has separate socket pools from the NetworkContext which created the
// factory instance. // factory instance.
interface ProxyResolvingSocketFactory { interface ProxyResolvingSocketFactory {
// Creates a socket connected to |url|. This connection might be done through // Creates a socket connected to |url|. This connection might be done through
// proxies if any is set in system's proxy settings. If |use_tls|, a TLS // proxies if any is set in system's proxy settings. On success, |result| is
// connection will be established on top of a TCP connection. On success, // net::OK. Caller is to use |send_stream| to send data and
// |result| is net::OK. Caller is to use |send_stream| to send data and
// |receive_stream| to receive data over the connection. On failure, |result| // |receive_stream| to receive data over the connection. On failure, |result|
// is a network error code. |local_addr| contains the local address of the // is a network error code. |local_addr| contains the local address of the
// socket. |peer_addr| contains the peer address. If socket is connected to a // socket. |peer_addr| contains the peer address. If socket is connected to a
...@@ -54,7 +63,8 @@ interface ProxyResolvingSocketFactory { ...@@ -54,7 +63,8 @@ interface ProxyResolvingSocketFactory {
// //
// Any sockets that are created but are yet to be destroyed will be destroyed // Any sockets that are created but are yet to be destroyed will be destroyed
// when the implementation of this factory goes away. // when the implementation of this factory goes away.
CreateProxyResolvingSocket(url.mojom.Url url, bool use_tls, CreateProxyResolvingSocket(url.mojom.Url url,
ProxyResolvingSocketOptions? options,
MutableNetworkTrafficAnnotationTag traffic_annotation, MutableNetworkTrafficAnnotationTag traffic_annotation,
ProxyResolvingSocket& socket, ProxyResolvingSocket& socket,
SocketObserver? observer) SocketObserver? observer)
......
...@@ -167,7 +167,7 @@ class TLSClientSocketTestBase { ...@@ -167,7 +167,7 @@ class TLSClientSocketTestBase {
base::RunLoop run_loop; base::RunLoop run_loop;
int net_error = net::ERR_FAILED; int net_error = net::ERR_FAILED;
proxy_resolving_factory_->CreateProxyResolvingSocket( proxy_resolving_factory_->CreateProxyResolvingSocket(
url, false /* use_tls */, url, nullptr /* options */,
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS), net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS),
std::move(request), nullptr /* observer */, std::move(request), nullptr /* observer */,
base::BindLambdaForTesting( base::BindLambdaForTesting(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment