0

Plumb a NetworkQualityEstimator* into TCPClientSocket.

This is strictly a re-factor, however a follow-up CL uses the parameter for access the estimated transport RTT.

Bug: 1123197
Change-Id: I0e697d59c87e9397f35f41222fb5399950c1ca41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382956
Reviewed-by: Tarun Bansal <tbansal@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Eric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807578}
This commit is contained in:
Eric Roman
2020-09-16 18:30:45 +00:00
committed by Commit Bot
parent 7f956b9263
commit 2bc771681e
44 changed files with 175 additions and 108 deletions

@ -283,8 +283,12 @@ void HttpFirewallRoutine::AttemptSocketConnections() {
resolved_address =
net::AddressList::CopyWithPort(resolved_address, kHttpPort);
// TODO(crbug.com/1123197): Pass non-null NetworkQualityEstimator.
net::NetworkQualityEstimator* network_quality_estimator = nullptr;
sockets_.emplace_back(client_socket_factory_->CreateTransportClientSocket(
resolved_address, nullptr, net_log_.net_log(), net_log_.source()));
resolved_address, nullptr, network_quality_estimator,
net_log_.net_log(), net_log_.source()));
}
// Connect the sockets.

@ -144,6 +144,7 @@ class FakeClientSocketFactory : public net::ClientSocketFactory {
std::unique_ptr<net::TransportClientSocket> CreateTransportClientSocket(
const net::AddressList& addresses,
std::unique_ptr<net::SocketPerformanceWatcher> socket_performance_watcher,
net::NetworkQualityEstimator* network_quality_estimator,
net::NetLog* net_log,
const net::NetLogSource& source) override {
net::SocketDataProvider* socket_data_provider =

@ -189,8 +189,8 @@ void AdbClientSocket::Connect(net::CompletionOnceCallback callback) {
net::AddressList address_list =
net::AddressList::CreateFromIPAddress(ip_address, port_);
socket_.reset(
new net::TCPClientSocket(address_list, NULL, NULL, net::NetLogSource()));
socket_.reset(new net::TCPClientSocket(address_list, nullptr, nullptr,
nullptr, net::NetLogSource()));
connect_callback_ = std::move(callback);
int result = socket_->Connect(base::BindOnce(
&AdbClientSocket::RunConnectCallback, base::Unretained(this)));

@ -256,8 +256,8 @@ class SocketTunnel {
void OnResolved(net::AddressList resolved_addresses) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
host_socket_.reset(new net::TCPClientSocket(resolved_addresses, nullptr,
nullptr, net::NetLogSource()));
host_socket_.reset(new net::TCPClientSocket(
resolved_addresses, nullptr, nullptr, nullptr, net::NetLogSource()));
int result = host_socket_->Connect(
base::BindOnce(&SocketTunnel::OnConnected, base::Unretained(this)));
if (result != net::ERR_IO_PENDING)

@ -79,8 +79,9 @@ class ResolveHostAndOpenSocket final : public network::ResolveHostClientBase {
delete this;
return;
}
std::unique_ptr<net::StreamSocket> socket(new net::TCPClientSocket(
resolved_addresses.value(), nullptr, nullptr, net::NetLogSource()));
std::unique_ptr<net::StreamSocket> socket(
new net::TCPClientSocket(resolved_addresses.value(), nullptr, nullptr,
nullptr, net::NetLogSource()));
net::StreamSocket* socket_ptr = socket.get();
net::CompletionRepeatingCallback on_connect =
base::AdaptCallbackForRepeating(

@ -505,6 +505,7 @@ class TestSocketFactory : public net::ClientSocketFactory {
std::unique_ptr<net::TransportClientSocket> CreateTransportClientSocket(
const net::AddressList&,
std::unique_ptr<net::SocketPerformanceWatcher>,
net::NetworkQualityEstimator* network_quality_estimator,
net::NetLog*,
const net::NetLogSource&) override {
providers_.push_back(std::make_unique<net::StaticSocketDataProvider>(

@ -112,7 +112,7 @@ bool TestProxyTunnelConnection::ConnectToPeerOnLocalhost(int port) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
client_socket_ = std::make_unique<net::TCPClientSocket>(
net::AddressList(net::IPEndPoint(net::IPAddress::IPv4Localhost(), port)),
nullptr, nullptr, net::NetLogSource());
nullptr, nullptr, nullptr, net::NetLogSource());
int result = client_socket_->Connect(base::BindOnce(
&TestProxyTunnelConnection::HandleConnectResult, base::Unretained(this)));

@ -505,8 +505,8 @@ void AdbClientSocket::Connect(net::CompletionOnceCallback callback) {
net::AddressList address_list = net::AddressList::CopyWithPort(
ip_list, port_);
socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL,
net::NetLogSource()));
socket_.reset(new net::TCPClientSocket(address_list, nullptr, nullptr,
nullptr, net::NetLogSource()));
net::CompletionRepeatingCallback copyable_callback =
base::AdaptCallbackForRepeating(std::move(callback));

@ -107,7 +107,8 @@ void WebSocket::Connect(net::CompletionOnceCallback callback) {
}
net::NetLogSource source;
socket_.reset(new net::TCPClientSocket(addresses, nullptr, nullptr, source));
socket_.reset(
new net::TCPClientSocket(addresses, nullptr, nullptr, nullptr, source));
state_ = CONNECTING;
connect_callback_ = std::move(callback);

@ -28,8 +28,9 @@ std::unique_ptr<net::StreamSocket> AudioSocketService::Connect(
const std::string& endpoint,
int port) {
net::IPEndPoint ip_endpoint(net::IPAddress::IPv4Localhost(), port);
return std::make_unique<net::TCPClientSocket>(
net::AddressList(ip_endpoint), nullptr, nullptr, net::NetLogSource());
return std::make_unique<net::TCPClientSocket>(net::AddressList(ip_endpoint),
nullptr, nullptr, nullptr,
net::NetLogSource());
}
AudioSocketService::AudioSocketService(const std::string& endpoint,

@ -37,6 +37,7 @@
#include "net/base/address_list.h"
#include "net/base/net_errors.h"
#include "net/cert/pem.h"
#include "net/socket/client_socket_factory.h"
#include "net/socket/socket_test_util.h"
#include "net/socket/ssl_client_socket.h"
#include "net/socket/ssl_server_socket.h"
@ -298,6 +299,7 @@ class TestSocketFactory : public net::ClientSocketFactory {
std::unique_ptr<net::TransportClientSocket> CreateTransportClientSocket(
const net::AddressList&,
std::unique_ptr<net::SocketPerformanceWatcher>,
net::NetworkQualityEstimator*,
net::NetLog*,
const net::NetLogSource&) override {
if (tcp_client_socket_)
@ -489,7 +491,7 @@ class SslCastSocketTest : public CastSocketTestBase {
ASSERT_EQ(net::OK, tcp_server_socket_->GetLocalAddress(&server_address));
tcp_client_socket_.reset(
new net::TCPClientSocket(net::AddressList(server_address), nullptr,
nullptr, net::NetLogSource()));
nullptr, nullptr, net::NetLogSource()));
std::unique_ptr<net::StreamSocket> accepted_socket;
accept_result_ = tcp_server_socket_->Accept(

@ -50,7 +50,7 @@ TEST(UIDevToolsServerTest, MAYBE_ConnectionToViewsServer) {
net::AddressList addr(
net::IPEndPoint(net::IPAddress(127, 0, 0, 1), fake_port));
auto client_socket = std::make_unique<net::TCPClientSocket>(
addr, nullptr, nullptr, net::NetLogSource());
addr, nullptr, nullptr, nullptr, net::NetLogSource());
net::TestCompletionCallback callback;
int connect_result =
callback.GetResult(client_socket->Connect(callback.callback()));

@ -437,7 +437,7 @@ TEST_F(WebEngineIntegrationTest, RemoteDebuggingPort) {
net::TCPClientSocket connecting_socket(
net::AddressList(net::IPEndPoint(net::IPAddress::IPv4Localhost(),
remote_debugging_port)),
nullptr, nullptr, net::NetLogSource());
nullptr, nullptr, nullptr, net::NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
connect_result = connect_callback.GetResult(connect_result);

@ -108,7 +108,7 @@ class FakeSSLClientSocketTest : public testing::Test {
std::unique_ptr<net::StreamSocket> MakeClientSocket() {
return mock_client_socket_factory_.CreateTransportClientSocket(
net::AddressList(), NULL, NULL, net::NetLogSource());
net::AddressList(), nullptr, nullptr, nullptr, net::NetLogSource());
}
void SetData(const net::MockConnect& mock_connect,

@ -155,6 +155,7 @@ class TestSocketFactory : public ClientSocketFactory {
std::unique_ptr<TransportClientSocket> CreateTransportClientSocket(
const AddressList&,
std::unique_ptr<SocketPerformanceWatcher>,
net::NetworkQualityEstimator*,
NetLog*,
const NetLogSource&) override {
NOTIMPLEMENTED();

@ -68,8 +68,12 @@ std::unique_ptr<StreamSocket> DnsSocketAllocator::CreateTcpSocket(
const NetLogSource& source) {
DCHECK_LT(server_index, nameservers_.size());
// TODO(https://crbug.com/1123197): Pass a non-null NetworkQualityEstimator.
NetworkQualityEstimator* network_quality_estimator = nullptr;
return socket_factory_->CreateTransportClientSocket(
AddressList(nameservers_[server_index]), nullptr, net_log_, source);
AddressList(nameservers_[server_index]), nullptr,
network_quality_estimator, net_log_, source);
}
} // namespace net

@ -680,10 +680,13 @@ int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) {
int FtpNetworkTransaction::DoCtrlConnect() {
next_state_ = STATE_CTRL_CONNECT_COMPLETE;
// TODO(https://crbug.com/1123197): Pass a non-null NetworkQualityEstimator.
NetworkQualityEstimator* network_quality_estimator = nullptr;
DCHECK(resolve_request_ && resolve_request_->GetAddressResults());
ctrl_socket_ = socket_factory_->CreateTransportClientSocket(
resolve_request_->GetAddressResults().value(), nullptr,
net_log_.net_log(), net_log_.source());
network_quality_estimator, net_log_.net_log(), net_log_.source());
net_log_.AddEventReferencingSource(NetLogEventType::FTP_CONTROL_CONNECTION,
ctrl_socket_->NetLog().source());
return ctrl_socket_->Connect(io_callback_);
@ -1235,8 +1238,12 @@ int FtpNetworkTransaction::DoDataConnect() {
return Stop(rv);
data_address = AddressList::CreateFromIPAddress(
ip_endpoint.address(), data_connection_port_);
// TODO(https://crbug.com/1123197): Pass a non-null NetworkQualityEstimator.
NetworkQualityEstimator* network_quality_estimator = nullptr;
data_socket_ = socket_factory_->CreateTransportClientSocket(
data_address, nullptr, net_log_.net_log(), net_log_.source());
data_address, nullptr, network_quality_estimator, net_log_.net_log(),
net_log_.source());
net_log_.AddEventReferencingSource(NetLogEventType::FTP_DATA_CONNECTION,
data_socket_->NetLog().source());
return data_socket_->Connect(io_callback_);

@ -64,7 +64,8 @@ class TestHttpClient {
int ConnectAndWait(const IPEndPoint& address) {
AddressList addresses(address);
NetLogSource source;
socket_.reset(new TCPClientSocket(addresses, nullptr, nullptr, source));
socket_.reset(
new TCPClientSocket(addresses, nullptr, nullptr, nullptr, source));
TestCompletionCallback callback;
int rv = socket_->Connect(callback.callback());

@ -37,10 +37,12 @@ class DefaultClientSocketFactory : public ClientSocketFactory {
std::unique_ptr<TransportClientSocket> CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) override {
return std::make_unique<TCPClientSocket>(
addresses, std::move(socket_performance_watcher), net_log, source);
addresses, std::move(socket_performance_watcher),
network_quality_estimator, net_log, source);
}
std::unique_ptr<SSLClientSocket> CreateSSLClientSocket(

@ -29,6 +29,7 @@ class ProxyClientSocket;
class ProxyDelegate;
class ProxyServer;
class HttpAuthController;
class NetworkQualityEstimator;
// An interface used to instantiate StreamSocket objects. Used to facilitate
// testing code with mock socket implementations.
@ -43,9 +44,13 @@ class NET_EXPORT ClientSocketFactory {
NetLog* net_log,
const NetLogSource& source) = 0;
// |network_quality_estimator| is optional. If not specified, the network
// quality will not be considered when determining TCP connect handshake
// timeouts, or when histogramming the handshake duration.
virtual std::unique_ptr<TransportClientSocket> CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) = 0;

@ -241,6 +241,7 @@ class MockClientSocketFactory : public ClientSocketFactory {
const AddressList& addresses,
std::unique_ptr<
SocketPerformanceWatcher> /* socket_performance_watcher */,
NetworkQualityEstimator* /* network_quality_estimator */,
NetLog* /* net_log */,
const NetLogSource& /*source*/) override {
allocation_count_++;
@ -375,7 +376,7 @@ class TestConnectJob : public ConnectJob {
int ConnectInternal() override {
AddressList ignored;
client_socket_factory_->CreateTransportClientSocket(
ignored, nullptr, nullptr, NetLogSource());
ignored, nullptr, nullptr, nullptr, NetLogSource());
switch (job_type_) {
case kMockJob:
return DoConnect(true /* successful */, false /* sync */,

@ -123,6 +123,7 @@ std::unique_ptr<TransportClientSocket>
FuzzedSocketFactory::CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) {
std::unique_ptr<FuzzedSocket> socket(

@ -42,6 +42,7 @@ class FuzzedSocketFactory : public ClientSocketFactory {
std::unique_ptr<TransportClientSocket> CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) override;

@ -250,7 +250,8 @@ void SequencedSocketDataTest::Initialize(base::span<const MockRead> reads,
socket_factory_.AddSocketDataProvider(data_.get());
sock_ = socket_factory_.CreateTransportClientSocket(
AddressList(IPEndPoint(IPAddress::IPv4Localhost(), 443)),
nullptr /* socket_performance_watcher */, nullptr /* net_log */,
nullptr /* socket_performance_watcher */,
nullptr /* network_quality_estimator */, nullptr /* net_log */,
NetLogSource());
TestCompletionCallback callback;
EXPECT_EQ(OK, sock_->Connect(callback.callback()));

@ -50,7 +50,7 @@ class SocketBIOAdapterTest : public testing::TestWithParam<ReadIfReadySupport>,
data->set_connect_data(MockConnect(SYNCHRONOUS, OK));
factory_.AddSocketDataProvider(data);
std::unique_ptr<StreamSocket> socket = factory_.CreateTransportClientSocket(
AddressList(), nullptr, nullptr, NetLogSource());
AddressList(), nullptr, nullptr, nullptr, NetLogSource());
CHECK_EQ(OK, socket->Connect(CompletionOnceCallback()));
return socket;
}

@ -791,6 +791,7 @@ std::unique_ptr<TransportClientSocket>
MockClientSocketFactory::CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) {
SocketDataProvider* data_provider = mock_tcp_data_.GetNextWithoutAsserting();
@ -2179,7 +2180,7 @@ int MockTransportClientSocketPool::RequestSocket(
last_request_priority_ = priority;
std::unique_ptr<StreamSocket> socket =
client_socket_factory_->CreateTransportClientSocket(
AddressList(), nullptr, net_log.net_log(), NetLogSource());
AddressList(), nullptr, nullptr, net_log.net_log(), NetLogSource());
MockConnectJob* job = new MockConnectJob(
std::move(socket), handle, socket_tag, std::move(callback), priority);
job_list_.push_back(base::WrapUnique(job));
@ -2339,11 +2340,13 @@ std::unique_ptr<TransportClientSocket>
MockTaggingClientSocketFactory::CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) {
std::unique_ptr<MockTaggingStreamSocket> socket(new MockTaggingStreamSocket(
MockClientSocketFactory::CreateTransportClientSocket(
addresses, std::move(socket_performance_watcher), net_log, source)));
addresses, std::move(socket_performance_watcher),
network_quality_estimator, net_log, source)));
tcp_socket_ = socket.get();
return std::move(socket);
}

@ -689,6 +689,7 @@ class MockClientSocketFactory : public ClientSocketFactory {
std::unique_ptr<TransportClientSocket> CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) override;
std::unique_ptr<SSLClientSocket> CreateSSLClientSocket(
@ -1403,6 +1404,7 @@ class MockTaggingClientSocketFactory : public MockClientSocketFactory {
std::unique_ptr<TransportClientSocket> CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) override;

@ -835,7 +835,7 @@ class SSLClientSocketTest : public PlatformTest, public WithTaskEnvironment {
const HostPortPair& host_port_pair,
int* result) {
std::unique_ptr<StreamSocket> transport(
new TCPClientSocket(addr_, nullptr, &log_, NetLogSource()));
new TCPClientSocket(addr_, nullptr, nullptr, &log_, NetLogSource()));
int rv = callback_.GetResult(transport->Connect(callback_.callback()));
if (rv != OK) {
LOG(ERROR) << "Could not connect to SpawnedTestServer";
@ -938,10 +938,12 @@ class ClientSocketFactoryWithoutReadIfReady : public ClientSocketFactory {
std::unique_ptr<TransportClientSocket> CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
NetLog* net_log,
const NetLogSource& source) override {
return factory_->CreateTransportClientSocket(
addresses, std::move(socket_performance_watcher), net_log, source);
addresses, std::move(socket_performance_watcher),
network_quality_estimator, net_log, source);
}
std::unique_ptr<SSLClientSocket> CreateSSLClientSocket(
@ -1139,7 +1141,7 @@ class SSLClientSocketFalseStartTest : public SSLClientSocketTest {
CHECK(spawned_test_server());
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport)));
int rv = callback->GetResult(transport->Connect(callback->callback()));
@ -1333,7 +1335,7 @@ class SSLClientSocketZeroRTTTest : public SSLClientSocketTest {
ssl_config.early_data_enabled = early_data_enabled;
real_transport_.reset(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport_)));
FakeBlockingStreamSocket* raw_transport = transport.get();
@ -1469,7 +1471,7 @@ TEST_P(SSLClientSocketVersionTest, Connect) {
TestCompletionCallback callback;
RecordingTestNetLog log;
std::unique_ptr<StreamSocket> transport(
new TCPClientSocket(addr(), nullptr, &log, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, &log, NetLogSource()));
int rv = callback.GetResult(transport->Connect(callback.callback()));
EXPECT_THAT(rv, IsOk());
@ -1546,8 +1548,8 @@ TEST_P(SSLClientSocketVersionTest, SocketDestroyedDuringVerify) {
ssl_client_session_cache_.get(), nullptr);
TestCompletionCallback callback;
auto transport =
std::make_unique<TCPClientSocket>(addr(), nullptr, &log_, NetLogSource());
auto transport = std::make_unique<TCPClientSocket>(addr(), nullptr, nullptr,
&log_, NetLogSource());
int rv = callback.GetResult(transport->Connect(callback.callback()));
ASSERT_THAT(rv, IsOk());
@ -1670,7 +1672,7 @@ TEST_P(SSLClientSocketReadTest, Read) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
EXPECT_EQ(0, transport->GetTotalReceivedBytes());
int rv = callback.GetResult(transport->Connect(callback.callback()));
@ -1727,7 +1729,7 @@ TEST_F(SSLClientSocketTest, Connect_WithSynchronousError) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<SynchronousErrorStreamSocket> transport(
new SynchronousErrorStreamSocket(std::move(real_transport)));
int rv = callback.GetResult(transport->Connect(callback.callback()));
@ -1754,7 +1756,7 @@ TEST_P(SSLClientSocketReadTest, Read_WithSynchronousError) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<SynchronousErrorStreamSocket> transport(
new SynchronousErrorStreamSocket(std::move(real_transport)));
int rv = callback.GetResult(transport->Connect(callback.callback()));
@ -1804,7 +1806,7 @@ TEST_P(SSLClientSocketVersionTest, Write_WithSynchronousError) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
// Note: |error_socket|'s ownership is handed to |transport|, but a pointer
// is retained in order to configure additional errors.
std::unique_ptr<SynchronousErrorStreamSocket> error_socket(
@ -1869,7 +1871,7 @@ TEST_P(SSLClientSocketVersionTest, Write_WithSynchronousErrorNoRead) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
// Note: intermediate sockets' ownership are handed to |sock|, but a pointer
// is retained in order to query them.
std::unique_ptr<SynchronousErrorStreamSocket> error_socket(
@ -1971,7 +1973,7 @@ TEST_P(SSLClientSocketReadTest, Read_DeleteWhilePendingFullDuplex) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
// Note: |error_socket|'s ownership is handed to |transport|, but a pointer
// is retained in order to configure additional errors.
std::unique_ptr<SynchronousErrorStreamSocket> error_socket(
@ -2055,7 +2057,7 @@ TEST_P(SSLClientSocketReadTest, Read_WithWriteError) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
// Note: |error_socket|'s ownership is handed to |transport|, but a pointer
// is retained in order to configure additional errors.
std::unique_ptr<SynchronousErrorStreamSocket> error_socket(
@ -2144,7 +2146,7 @@ TEST_F(SSLClientSocketTest, Connect_WithZeroReturn) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<SynchronousErrorStreamSocket> transport(
new SynchronousErrorStreamSocket(std::move(real_transport)));
int rv = callback.GetResult(transport->Connect(callback.callback()));
@ -2170,7 +2172,7 @@ TEST_P(SSLClientSocketReadTest, Read_WithZeroReturn) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<SynchronousErrorStreamSocket> transport(
new SynchronousErrorStreamSocket(std::move(real_transport)));
int rv = callback.GetResult(transport->Connect(callback.callback()));
@ -2201,7 +2203,7 @@ TEST_P(SSLClientSocketReadTest, Read_WithAsyncZeroReturn) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<SynchronousErrorStreamSocket> error_socket(
new SynchronousErrorStreamSocket(std::move(real_transport)));
SynchronousErrorStreamSocket* raw_error_socket = error_socket.get();
@ -2288,7 +2290,7 @@ TEST_P(SSLClientSocketReadTest, Read_ManySmallRecords) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<ReadBufferingStreamSocket> transport(
new ReadBufferingStreamSocket(std::move(real_transport)));
ReadBufferingStreamSocket* raw_transport = transport.get();
@ -2364,7 +2366,7 @@ TEST_P(SSLClientSocketReadTest, Read_FullLogging) {
RecordingTestNetLog log;
log.SetObserverCaptureMode(NetLogCaptureMode::kEverything);
std::unique_ptr<StreamSocket> transport(
new TCPClientSocket(addr(), nullptr, &log, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, &log, NetLogSource()));
int rv = callback.GetResult(transport->Connect(callback.callback()));
EXPECT_THAT(rv, IsOk());
@ -2472,7 +2474,7 @@ TEST_F(SSLClientSocketTest, ClientSocketHandleNotFromPool) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
int rv = callback.GetResult(transport->Connect(callback.callback()));
EXPECT_THAT(rv, IsOk());
@ -3031,7 +3033,7 @@ TEST_P(SSLClientSocketVersionTest, ReusableAfterWrite) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport)));
FakeBlockingStreamSocket* raw_transport = transport.get();
@ -3093,7 +3095,7 @@ TEST_P(SSLClientSocketVersionTest, SessionResumption) {
// Using a different HostPortPair uses a different session cache key.
std::unique_ptr<StreamSocket> transport(
new TCPClientSocket(addr(), nullptr, &log_, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, &log_, NetLogSource()));
TestCompletionCallback callback;
ASSERT_THAT(callback.GetResult(transport->Connect(callback.callback())),
IsOk());
@ -3151,7 +3153,7 @@ TEST_F(SSLClientSocketTest, SessionResumption_RSA) {
SCOPED_TRACE(i);
std::unique_ptr<StreamSocket> transport(
new TCPClientSocket(addr(), nullptr, &log_, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, &log_, NetLogSource()));
TestCompletionCallback callback;
ASSERT_THAT(callback.GetResult(transport->Connect(callback.callback())),
IsOk());
@ -4639,7 +4641,7 @@ TEST_F(SSLClientSocketTest, HandshakeFailureServerHello) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport)));
FakeBlockingStreamSocket* raw_transport = transport.get();
@ -4674,7 +4676,7 @@ TEST_F(SSLClientSocketTest, HandshakeFailureNoClientCerts) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport)));
FakeBlockingStreamSocket* raw_transport = transport.get();
@ -4723,7 +4725,7 @@ TEST_F(SSLClientSocketTest, LateHandshakeFailureMissingClientCerts) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport)));
FakeBlockingStreamSocket* raw_transport = transport.get();
@ -4773,7 +4775,7 @@ TEST_F(SSLClientSocketTest, LateHandshakeFailureSendClientCerts) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport)));
FakeBlockingStreamSocket* raw_transport = transport.get();
@ -4825,7 +4827,7 @@ TEST_F(SSLClientSocketTest, AccessDeniedNoClientCerts) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport)));
FakeBlockingStreamSocket* raw_transport = transport.get();
@ -4872,7 +4874,7 @@ TEST_F(SSLClientSocketTest, AccessDeniedClientCerts) {
TestCompletionCallback callback;
std::unique_ptr<StreamSocket> real_transport(
new TCPClientSocket(addr(), nullptr, nullptr, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, nullptr, NetLogSource()));
std::unique_ptr<FakeBlockingStreamSocket> transport(
new FakeBlockingStreamSocket(std::move(real_transport)));
FakeBlockingStreamSocket* raw_transport = transport.get();
@ -5331,7 +5333,7 @@ TEST_P(SSLClientSocketReadTest, IdleAfterRead) {
TestCompletionCallback client_callback;
std::unique_ptr<TCPClientSocket> client_transport(new TCPClientSocket(
AddressList(server_address), nullptr, nullptr, NetLogSource()));
AddressList(server_address), nullptr, nullptr, nullptr, NetLogSource()));
int client_rv = client_transport->Connect(client_callback.callback());
EXPECT_THAT(server_callback.GetResult(server_rv), IsOk());
@ -5433,7 +5435,7 @@ TEST_F(SSLClientSocketTest, SSLOverSSLBadCertificate) {
TestCompletionCallback client_callback;
auto client_transport = std::make_unique<TCPClientSocket>(
AddressList(server_address), nullptr, nullptr, NetLogSource());
AddressList(server_address), nullptr, nullptr, nullptr, NetLogSource());
int client_rv = client_transport->Connect(client_callback.callback());
ASSERT_THAT(server_callback.GetResult(server_rv), IsOk());
@ -5495,7 +5497,7 @@ TEST_F(SSLClientSocketTest, Tag) {
RecordingTestNetLog log;
std::unique_ptr<StreamSocket> transport(
new TCPClientSocket(addr(), nullptr, &log, NetLogSource()));
new TCPClientSocket(addr(), nullptr, nullptr, &log, NetLogSource()));
MockTaggingStreamSocket* tagging_sock =
new MockTaggingStreamSocket(std::move(transport));

@ -30,6 +30,7 @@ class NetLogWithSource;
TCPClientSocket::TCPClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
net::NetLog* net_log,
const net::NetLogSource& source)
: TCPClientSocket(
@ -38,14 +39,18 @@ TCPClientSocket::TCPClientSocket(
source),
addresses,
-1 /* current_address_index */,
nullptr /* bind_address */) {}
nullptr /* bind_address */,
network_quality_estimator) {}
TCPClientSocket::TCPClientSocket(std::unique_ptr<TCPSocket> connected_socket,
const IPEndPoint& peer_address)
: TCPClientSocket(std::move(connected_socket),
AddressList(peer_address),
0 /* current_address_index */,
nullptr /* bind_address */) {}
nullptr /* bind_address */,
// TODO(https://crbug.com/1123197: Pass non-null
// NetworkQualityEstimator
nullptr /* network_quality_estimator */) {}
TCPClientSocket::~TCPClientSocket() {
Disconnect();
@ -57,10 +62,11 @@ TCPClientSocket::~TCPClientSocket() {
std::unique_ptr<TCPClientSocket> TCPClientSocket::CreateFromBoundSocket(
std::unique_ptr<TCPSocket> bound_socket,
const AddressList& addresses,
const IPEndPoint& bound_address) {
const IPEndPoint& bound_address,
NetworkQualityEstimator* network_quality_estimator) {
return base::WrapUnique(new TCPClientSocket(
std::move(bound_socket), addresses, -1 /* current_address_index */,
std::make_unique<IPEndPoint>(bound_address)));
std::make_unique<IPEndPoint>(bound_address), network_quality_estimator));
}
int TCPClientSocket::Bind(const IPEndPoint& address) {
@ -131,10 +137,12 @@ int TCPClientSocket::Connect(CompletionOnceCallback callback) {
return rv;
}
TCPClientSocket::TCPClientSocket(std::unique_ptr<TCPSocket> socket,
const AddressList& addresses,
int current_address_index,
std::unique_ptr<IPEndPoint> bind_address)
TCPClientSocket::TCPClientSocket(
std::unique_ptr<TCPSocket> socket,
const AddressList& addresses,
int current_address_index,
std::unique_ptr<IPEndPoint> bind_address,
NetworkQualityEstimator* network_quality_estimator)
: socket_(std::move(socket)),
bind_address_(std::move(bind_address)),
addresses_(addresses),

@ -44,6 +44,7 @@ class IPEndPoint;
class NetLog;
struct NetLogSource;
class SocketPerformanceWatcher;
class NetworkQualityEstimator;
// A client socket that uses TCP as the transport layer.
class NET_EXPORT TCPClientSocket : public TransportClientSocket,
@ -55,6 +56,7 @@ class NET_EXPORT TCPClientSocket : public TransportClientSocket,
TCPClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
NetworkQualityEstimator* network_quality_estimator,
net::NetLog* net_log,
const net::NetLogSource& source);
@ -67,7 +69,8 @@ class NET_EXPORT TCPClientSocket : public TransportClientSocket,
static std::unique_ptr<TCPClientSocket> CreateFromBoundSocket(
std::unique_ptr<TCPSocket> bound_socket,
const AddressList& addresses,
const IPEndPoint& bound_address);
const IPEndPoint& bound_address,
NetworkQualityEstimator* network_quality_estimator);
~TCPClientSocket() override;
@ -135,7 +138,8 @@ class NET_EXPORT TCPClientSocket : public TransportClientSocket,
TCPClientSocket(std::unique_ptr<TCPSocket> socket,
const AddressList& addresses,
int current_address_index,
std::unique_ptr<IPEndPoint> bind_address);
std::unique_ptr<IPEndPoint> bind_address,
NetworkQualityEstimator* network_quality_estimator);
// A helper method shared by Read() and ReadIfReady(). If |read_if_ready| is
// set to true, ReadIfReady() will be used instead of Read().

@ -93,7 +93,7 @@ class TCPClientSocketTest : public testing::Test {
ASSERT_THAT(server_socket->GetLocalAddress(&server_address), IsOk());
*client_socket = std::make_unique<TCPClientSocket>(
AddressList(server_address), nullptr, nullptr, NetLogSource());
AddressList(server_address), nullptr, nullptr, nullptr, NetLogSource());
EXPECT_THAT((*client_socket)->Bind(IPEndPoint(local_address, 0)), IsOk());
@ -135,7 +135,7 @@ TEST_F(TCPClientSocketTest, BindLoopbackToLoopback) {
IPEndPoint server_address;
ASSERT_THAT(server.GetLocalAddress(&server_address), IsOk());
TCPClientSocket socket(AddressList(server_address), nullptr, nullptr,
TCPClientSocket socket(AddressList(server_address), nullptr, nullptr, nullptr,
NetLogSource());
EXPECT_THAT(socket.Bind(IPEndPoint(lo_address, 0)), IsOk());
@ -167,7 +167,7 @@ TEST_F(TCPClientSocketTest, BindLoopbackToLoopback) {
TEST_F(TCPClientSocketTest, BindLoopbackToExternal) {
IPAddress external_ip(72, 14, 213, 105);
TCPClientSocket socket(AddressList::CreateFromIPAddress(external_ip, 80),
nullptr, nullptr, NetLogSource());
nullptr, nullptr, nullptr, NetLogSource());
EXPECT_THAT(socket.Bind(IPEndPoint(IPAddress::IPv4Localhost(), 0)), IsOk());
@ -193,7 +193,7 @@ TEST_F(TCPClientSocketTest, BindLoopbackToIPv6) {
IPEndPoint server_address;
ASSERT_THAT(server.GetLocalAddress(&server_address), IsOk());
TCPClientSocket socket(AddressList(server_address), nullptr, nullptr,
TCPClientSocket socket(AddressList(server_address), nullptr, nullptr, nullptr,
NetLogSource());
EXPECT_THAT(socket.Bind(IPEndPoint(IPAddress::IPv4Localhost(), 0)), IsOk());
@ -211,7 +211,7 @@ TEST_F(TCPClientSocketTest, WasEverUsed) {
IPEndPoint server_address;
ASSERT_THAT(server.GetLocalAddress(&server_address), IsOk());
TCPClientSocket socket(AddressList(server_address), nullptr, nullptr,
TCPClientSocket socket(AddressList(server_address), nullptr, nullptr, nullptr,
NetLogSource());
EXPECT_FALSE(socket.WasEverUsed());
@ -291,7 +291,7 @@ TEST_F(TCPClientSocketTest, MAYBE_TestSocketPerformanceWatcher) {
TCPClientSocket socket(
AddressList::CreateFromIPAddressList(ip_list, "example.com"),
std::move(watcher), nullptr, NetLogSource());
std::move(watcher), nullptr, nullptr, NetLogSource());
EXPECT_THAT(socket.Bind(IPEndPoint(IPAddress::IPv4Localhost(), 0)), IsOk());
@ -319,7 +319,7 @@ TEST_F(TCPClientSocketTest, Tag) {
AddressList addr_list;
ASSERT_TRUE(test_server.GetAddressList(&addr_list));
TCPClientSocket s(addr_list, NULL, NULL, NetLogSource());
TCPClientSocket s(addr_list, nullptr, nullptr, nullptr, NetLogSource());
// Verify TCP connect packets are tagged and counted properly.
int32_t tag_val1 = 0x12345678;
@ -376,7 +376,7 @@ TEST_F(TCPClientSocketTest, TagAfterConnect) {
AddressList addr_list;
ASSERT_TRUE(test_server.GetAddressList(&addr_list));
TCPClientSocket s(addr_list, NULL, NULL, NetLogSource());
TCPClientSocket s(addr_list, nullptr, nullptr, nullptr, NetLogSource());
// Connect socket.
TestCompletionCallback connect_callback;
@ -430,7 +430,7 @@ TEST_F(TCPClientSocketTest, SuspendBeforeConnect) {
IPEndPoint server_address;
ASSERT_THAT(server.GetLocalAddress(&server_address), IsOk());
TCPClientSocket socket(AddressList(server_address), nullptr, nullptr,
TCPClientSocket socket(AddressList(server_address), nullptr, nullptr, nullptr,
NetLogSource());
EXPECT_THAT(socket.Bind(IPEndPoint(lo_address, 0)), IsOk());
@ -471,6 +471,7 @@ class NeverConnectingTCPClientSocket : public TCPClientSocket {
const net::NetLogSource& source)
: TCPClientSocket(addresses,
std::move(socket_performance_watcher),
nullptr,
net_log,
source) {}

@ -74,7 +74,7 @@ TEST_F(TCPServerSocketTest, Accept) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
TestCompletionCallback accept_callback;
@ -111,7 +111,7 @@ TEST_F(TCPServerSocketTest, AcceptAsync) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
EXPECT_THAT(connect_callback.GetResult(connect_result), IsOk());
@ -137,7 +137,7 @@ TEST_F(TCPServerSocketTest, AcceptClientDisconnectAfterConnect) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
EXPECT_THAT(connect_callback.GetResult(connect_result), IsOk());
@ -167,12 +167,12 @@ TEST_F(TCPServerSocketTest, Accept2Connections) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
TestCompletionCallback connect_callback2;
TCPClientSocket connecting_socket2(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result2 =
connecting_socket2.Connect(connect_callback2.callback());
@ -209,7 +209,7 @@ TEST_F(TCPServerSocketTest, AcceptIPv6) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
TestCompletionCallback accept_callback;
@ -237,7 +237,7 @@ TEST_F(TCPServerSocketTest, AcceptIO) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
TestCompletionCallback accept_callback;

@ -135,7 +135,7 @@ class TCPSocketTest : public PlatformTest, public WithTaskEnvironment {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
EXPECT_THAT(connect_callback.GetResult(connect_result), IsOk());
@ -236,7 +236,7 @@ TEST_F(TCPSocketTest, Accept) {
// TODO(yzshen): Switch to use TCPSocket when it supports client socket
// operations.
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
TestCompletionCallback accept_callback;
@ -273,7 +273,7 @@ TEST_F(TCPSocketTest, AdoptConnectedSocket) {
// TODO(yzshen): Switch to use TCPSocket when it supports client socket
// operations.
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
TestCompletionCallback accept_callback;
@ -329,12 +329,12 @@ TEST_F(TCPSocketTest, Accept2Connections) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
TestCompletionCallback connect_callback2;
TCPClientSocket connecting_socket2(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result2 =
connecting_socket2.Connect(connect_callback2.callback());
@ -368,7 +368,7 @@ TEST_F(TCPSocketTest, AcceptIPv6) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
int connect_result = connecting_socket.Connect(connect_callback.callback());
TestCompletionCallback accept_callback;
@ -610,7 +610,7 @@ TEST_F(TCPSocketTest, IsConnected) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
// Immediately after creation, the socket should not be connected.
EXPECT_FALSE(connecting_socket.IsConnected());
@ -689,7 +689,7 @@ TEST_F(TCPSocketTest, BeforeConnectCallback) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
connecting_socket.SetBeforeConnectCallback(base::BindLambdaForTesting([&] {
EXPECT_FALSE(connecting_socket.IsConnected());
@ -734,7 +734,7 @@ TEST_F(TCPSocketTest, BeforeConnectCallbackFails) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
// Set a callback that returns a nonsensical error, and make sure it's
// returned.
@ -762,7 +762,7 @@ TEST_F(TCPSocketTest, SetKeepAlive) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
// Non-connected sockets should not be able to set KeepAlive.
ASSERT_FALSE(connecting_socket.IsConnected());
@ -794,7 +794,7 @@ TEST_F(TCPSocketTest, SetNoDelay) {
TestCompletionCallback connect_callback;
TCPClientSocket connecting_socket(local_address_list(), nullptr, nullptr,
NetLogSource());
nullptr, NetLogSource());
// Non-connected sockets should not be able to set NoDelay.
ASSERT_FALSE(connecting_socket.IsConnected());

@ -392,6 +392,7 @@ std::unique_ptr<TransportClientSocket>
MockTransportClientSocketFactory::CreateTransportClientSocket(
const AddressList& addresses,
std::unique_ptr<SocketPerformanceWatcher> /* socket_performance_watcher */,
NetworkQualityEstimator* /* network_quality_estimator */,
NetLog* /* net_log */,
const NetLogSource& /* source */) {
allocation_count_++;

@ -83,6 +83,7 @@ class MockTransportClientSocketFactory : public ClientSocketFactory {
const AddressList& addresses,
std::unique_ptr<
SocketPerformanceWatcher> /* socket_performance_watcher */,
NetworkQualityEstimator* /* network_quality_estimator */,
NetLog* /* net_log */,
const NetLogSource& /* source */) override;

@ -118,8 +118,8 @@ void TransportClientSocketTest::SetUp() {
AddressList addr = AddressList::CreateFromIPAddress(
IPAddress::IPv4Localhost(), listen_port_);
sock_ = socket_factory_->CreateTransportClientSocket(addr, nullptr, &net_log_,
NetLogSource());
sock_ = socket_factory_->CreateTransportClientSocket(
addr, nullptr, nullptr, &net_log_, NetLogSource());
}
int TransportClientSocketTest::DrainClientSocket(

@ -323,8 +323,8 @@ int TransportConnectJob::DoTransportConnect() {
}
transport_socket_ = client_socket_factory()->CreateTransportClientSocket(
request_->GetAddressResults().value(),
std::move(socket_performance_watcher), net_log().net_log(),
net_log().source());
std::move(socket_performance_watcher), network_quality_estimator(),
net_log().net_log(), net_log().source());
// If the list contains IPv6 and IPv4 addresses, and the first address
// is IPv6, the IPv4 addresses will be tried as fallback addresses, per
@ -412,7 +412,7 @@ void TransportConnectJob::DoIPv6FallbackTransportConnect() {
fallback_transport_socket_ =
client_socket_factory()->CreateTransportClientSocket(
*fallback_addresses_, std::move(socket_performance_watcher),
net_log().net_log(), net_log().source());
network_quality_estimator(), net_log().net_log(), net_log().source());
fallback_connect_start_time_ = base::TimeTicks::Now();
int rv = fallback_transport_socket_->Connect(base::BindOnce(
&TransportConnectJob::DoIPv6FallbackTransportConnectComplete,

@ -238,8 +238,12 @@ int WebSocketTransportConnectSubJob::DoTransportConnect() {
// ConnectInterval.
next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE;
AddressList one_address(CurrentAddress());
// TODO(https://crbug.com/1123197): Pass a non-null NetworkQualityEstimator.
NetworkQualityEstimator* network_quality_estimator = nullptr;
transport_socket_ = client_socket_factory()->CreateTransportClientSocket(
one_address, nullptr, net_log().net_log(), net_log().source());
one_address, nullptr, network_quality_estimator, net_log().net_log(),
net_log().source());
// This use of base::Unretained() is safe because transport_socket_ is
// destroyed in the destructor.
return transport_socket_->Connect(base::BindOnce(

@ -299,7 +299,7 @@ TEST_P(EmbeddedTestServerTest, ConnectionListenerAccept) {
std::unique_ptr<StreamSocket> socket =
ClientSocketFactory::GetDefaultFactory()->CreateTransportClientSocket(
address_list, nullptr, &net_log, NetLogSource());
address_list, nullptr, nullptr, &net_log, NetLogSource());
TestCompletionCallback callback;
ASSERT_THAT(callback.GetResult(socket->Connect(callback.callback())), IsOk());

@ -153,7 +153,8 @@ bool StreamPacketSocket::InitClientTcp(
}
auto socket = std::make_unique<net::TCPClientSocket>(
net::AddressList(remote_endpoint), nullptr, nullptr, net::NetLogSource());
net::AddressList(remote_endpoint), nullptr, nullptr, nullptr,
net::NetLogSource());
int result = socket->Bind(local_endpoint);
if (result != net::OK) {

@ -250,6 +250,7 @@ class MockSocketFactory : public net::ClientSocketFactory {
std::unique_ptr<net::TransportClientSocket> CreateTransportClientSocket(
const net::AddressList& addresses,
std::unique_ptr<net::SocketPerformanceWatcher> socket_performance_watcher,
net::NetworkQualityEstimator* network_quality_estimator,
net::NetLog* net_log,
const net::NetLogSource& source) override {
ADD_FAILURE() << "Called CreateTransportClientSocket()";

@ -91,7 +91,8 @@ class SocketDataPumpTest : public testing::Test,
send_handle_ = std::move(send_pipe.producer_handle);
socket_ = mock_client_socket_factory_.CreateTransportClientSocket(
net::AddressList(), nullptr /*socket_performance_watcher*/,
nullptr /*netlog*/, net::NetLogSource());
nullptr /*network_quality_estimator*/, nullptr /*netlog*/,
net::NetLogSource());
net::TestCompletionCallback callback;
int result = socket_->Connect(callback.callback());
if (result == net::ERR_IO_PENDING)

@ -123,7 +123,7 @@ void TCPBoundSocket::Connect(
nullptr /* client_socket_factory */, traffic_annotation_);
connecting_socket_->ConnectWithSocket(
net::TCPClientSocket::CreateFromBoundSocket(
std::move(socket_), remote_addr_list, bind_address_),
std::move(socket_), remote_addr_list, bind_address_, nullptr),
std::move(tcp_connected_socket_options),
base::BindOnce(&TCPBoundSocket::OnConnectComplete,
base::Unretained(this)));

@ -113,10 +113,13 @@ void TCPConnectedSocket::Connect(
DCHECK(!socket_);
DCHECK(callback);
// TODO(https://crbug.com/1123197): Pass a non-null NetworkQualityEstimator.
net::NetworkQualityEstimator* network_quality_estimator = nullptr;
std::unique_ptr<net::TransportClientSocket> socket =
client_socket_factory_->CreateTransportClientSocket(
remote_addr_list, nullptr /*socket_performance_watcher*/, net_log_,
net::NetLogSource());
remote_addr_list, nullptr /*socket_performance_watcher*/,
network_quality_estimator, net_log_, net::NetLogSource());
if (local_addr) {
int result = socket->Bind(local_addr.value());