diff --git a/blimp/net/tcp_client_transport.cc b/blimp/net/tcp_client_transport.cc index f9e0bd3efaa87a..f78884318c3326 100644 --- a/blimp/net/tcp_client_transport.cc +++ b/blimp/net/tcp_client_transport.cc @@ -37,7 +37,7 @@ void TCPClientTransport::Connect(const net::CompletionCallback& callback) { connect_callback_ = callback; socket_ = socket_factory_->CreateTransportClientSocket( - net::AddressList(ip_endpoint_), net_log_, net::NetLog::Source()); + net::AddressList(ip_endpoint_), nullptr, net_log_, net::NetLog::Source()); net::CompletionCallback completion_callback = base::Bind( &TCPClientTransport::OnTCPConnectComplete, base::Unretained(this)); diff --git a/chrome/browser/devtools/device/adb/adb_client_socket.cc b/chrome/browser/devtools/device/adb/adb_client_socket.cc index 81eaaac3f5d8bd..3757c7108c67a9 100644 --- a/chrome/browser/devtools/device/adb/adb_client_socket.cc +++ b/chrome/browser/devtools/device/adb/adb_client_socket.cc @@ -183,7 +183,7 @@ void AdbClientSocket::Connect(const net::CompletionCallback& callback) { net::AddressList address_list = net::AddressList::CreateFromIPAddress(ip_address, port_); - socket_.reset(new net::TCPClientSocket(address_list, NULL, + socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL, net::NetLog::Source())); int result = socket_->Connect(callback); if (result != net::ERR_IO_PENDING) diff --git a/chrome/browser/devtools/device/port_forwarding_controller.cc b/chrome/browser/devtools/device/port_forwarding_controller.cc index 29188b41360fee..459e5c3fcbb314 100644 --- a/chrome/browser/devtools/device/port_forwarding_controller.cc +++ b/chrome/browser/devtools/device/port_forwarding_controller.cc @@ -83,7 +83,7 @@ class SocketTunnel : public base::NonThreadSafe { return; } - host_socket_.reset(new net::TCPClientSocket(address_list_, nullptr, + host_socket_.reset(new net::TCPClientSocket(address_list_, nullptr, nullptr, net::NetLog::Source())); result = host_socket_->Connect(base::Bind(&SocketTunnel::OnConnected, base::Unretained(this))); diff --git a/chrome/browser/devtools/device/tcp_device_provider.cc b/chrome/browser/devtools/device/tcp_device_provider.cc index 3504f546df8053..ea5b43ea9cc7ae 100644 --- a/chrome/browser/devtools/device/tcp_device_provider.cc +++ b/chrome/browser/devtools/device/tcp_device_provider.cc @@ -52,8 +52,8 @@ class ResolveHostAndOpenSocket final { delete this; return; } - std::unique_ptr socket( - new net::TCPClientSocket(address_list_, NULL, net::NetLog::Source())); + std::unique_ptr socket(new net::TCPClientSocket( + address_list_, NULL, NULL, net::NetLog::Source())); socket->Connect( base::Bind(&RunSocketCallback, callback_, base::Passed(&socket))); delete this; diff --git a/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h b/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h index 443c10f8180f88..ec8847262b420f 100644 --- a/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h +++ b/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h @@ -48,7 +48,10 @@ class MockTCPClientSocket : public net::TCPClientSocket { }; MockTCPClientSocket::MockTCPClientSocket() - : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()) {} + : TCPClientSocket(net::AddressList(), + nullptr, + nullptr, + net::NetLog::Source()) {} MockTCPClientSocket::~MockTCPClientSocket() {} } // namespace extensions diff --git a/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc b/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc index f844dc0ca9a98d..892778d32f1677 100644 --- a/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc +++ b/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc @@ -25,8 +25,7 @@ namespace extensions { class MockTCPSocket : public net::TCPClientSocket { public: explicit MockTCPSocket(const net::AddressList& address_list) - : net::TCPClientSocket(address_list, NULL, net::NetLog::Source()) { - } + : net::TCPClientSocket(address_list, NULL, NULL, net::NetLog::Source()) {} MOCK_METHOD3(Read, int(net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback)); diff --git a/chrome/browser/extensions/api/socket/tls_socket_unittest.cc b/chrome/browser/extensions/api/socket/tls_socket_unittest.cc index dd172da21bf485..ae8aa96c6f5414 100644 --- a/chrome/browser/extensions/api/socket/tls_socket_unittest.cc +++ b/chrome/browser/extensions/api/socket/tls_socket_unittest.cc @@ -85,7 +85,7 @@ class MockSSLClientSocket : public net::SSLClientSocket { class MockTCPSocket : public net::TCPClientSocket { public: explicit MockTCPSocket(const net::AddressList& address_list) - : net::TCPClientSocket(address_list, NULL, net::NetLog::Source()) {} + : net::TCPClientSocket(address_list, NULL, NULL, net::NetLog::Source()) {} MOCK_METHOD3(Read, int(net::IOBuffer* buf, diff --git a/chrome/test/chromedriver/net/adb_client_socket.cc b/chrome/test/chromedriver/net/adb_client_socket.cc index 73ec141d95a6a6..0a398acf8d3cdc 100644 --- a/chrome/test/chromedriver/net/adb_client_socket.cc +++ b/chrome/test/chromedriver/net/adb_client_socket.cc @@ -366,7 +366,7 @@ AdbClientSocket::~AdbClientSocket() { void AdbClientSocket::Connect(const net::CompletionCallback& callback) { net::AddressList address_list = net::AddressList::CreateFromIPAddress( net::IPAddress::IPv4Localhost(), port_); - socket_.reset(new net::TCPClientSocket(address_list, NULL, + socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL, net::NetLog::Source())); int result = socket_->Connect(callback); if (result != net::ERR_IO_PENDING) diff --git a/chrome/test/chromedriver/net/websocket.cc b/chrome/test/chromedriver/net/websocket.cc index cb93056e4359b9..0658ea1194de66 100644 --- a/chrome/test/chromedriver/net/websocket.cc +++ b/chrome/test/chromedriver/net/websocket.cc @@ -81,7 +81,7 @@ void WebSocket::Connect(const net::CompletionCallback& callback) { } net::NetLog::Source source; - socket_.reset(new net::TCPClientSocket(addresses, NULL, source)); + socket_.reset(new net::TCPClientSocket(addresses, NULL, NULL, source)); state_ = CONNECTING; connect_callback_ = callback; diff --git a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc index d29a59d09c334b..37e95ee02c9ac9 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc @@ -184,7 +184,7 @@ void PepperTCPServerSocketMessageFilter::DoListen( state_ = STATE_LISTEN_IN_PROGRESS; - socket_.reset(new net::TCPSocket(NULL, net::NetLog::Source())); + socket_.reset(new net::TCPSocket(NULL, NULL, net::NetLog::Source())); int net_result = net::OK; do { net::IPEndPoint ip_end_point(net::IPAddress(address), port); diff --git a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc index 648a600bb0881e..ecabca0e8abcd9 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc @@ -77,7 +77,7 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter( rcvbuf_size_(0), sndbuf_size_(0), address_index_(0), - socket_(new net::TCPSocket(NULL, net::NetLog::Source())), + socket_(new net::TCPSocket(NULL, NULL, net::NetLog::Source())), ssl_context_helper_(host->ssl_context_helper()), pending_accept_(false), pending_read_on_unthrottle_(false), @@ -860,7 +860,7 @@ void PepperTCPSocketMessageFilter::OnConnectCompleted( // We have to recreate |socket_| because it doesn't allow a second connect // attempt. We won't lose any state such as bound address or set options, // because in the private or v1.0 API, connect must be the first operation. - socket_.reset(new net::TCPSocket(NULL, net::NetLog::Source())); + socket_.reset(new net::TCPSocket(NULL, NULL, net::NetLog::Source())); if (address_index_ + 1 < address_list_.size()) { DCHECK_EQ(version_, ppapi::TCP_SOCKET_VERSION_PRIVATE); diff --git a/device/bluetooth/bluetooth_socket_net.cc b/device/bluetooth/bluetooth_socket_net.cc index 875f8cf4d1a8a3..6d44bf4fc56e5a 100644 --- a/device/bluetooth/bluetooth_socket_net.cc +++ b/device/bluetooth/bluetooth_socket_net.cc @@ -117,7 +117,7 @@ void BluetoothSocketNet::ResetData() { } void BluetoothSocketNet::ResetTCPSocket() { - tcp_socket_.reset(new net::TCPSocket(NULL, net::NetLog::Source())); + tcp_socket_.reset(new net::TCPSocket(NULL, NULL, net::NetLog::Source())); } void BluetoothSocketNet::SetTCPSocket( diff --git a/device/bluetooth/bluetooth_socket_win.cc b/device/bluetooth/bluetooth_socket_win.cc index b2e9b24040da07..f6a5eeb6ac6308 100644 --- a/device/bluetooth/bluetooth_socket_win.cc +++ b/device/bluetooth/bluetooth_socket_win.cc @@ -194,7 +194,7 @@ void BluetoothSocketWin::DoConnect( } std::unique_ptr scoped_socket( - new net::TCPSocket(NULL, net::NetLog::Source())); + new net::TCPSocket(NULL, NULL, net::NetLog::Source())); net::EnsureWinsockInit(); SOCKET socket_fd = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); SOCKADDR_BTH sa; @@ -261,7 +261,7 @@ void BluetoothSocketWin::DoListen( // TCPSocket methods that involve address could not be called. So bind() // is called on |socket_fd| directly. std::unique_ptr scoped_socket( - new net::TCPSocket(NULL, net::NetLog::Source())); + new net::TCPSocket(NULL, NULL, net::NetLog::Source())); scoped_socket->AdoptListenSocket(socket_fd); SOCKADDR_BTH sa; diff --git a/extensions/browser/api/cast_channel/cast_socket.cc b/extensions/browser/api/cast_channel/cast_socket.cc index 12df2bf382e854..71d6efa7f8f2a3 100644 --- a/extensions/browser/api/cast_channel/cast_socket.cc +++ b/extensions/browser/api/cast_channel/cast_socket.cc @@ -174,7 +174,7 @@ bool CastSocketImpl::audio_only() const { scoped_ptr CastSocketImpl::CreateTcpSocket() { net::AddressList addresses(ip_endpoint_); return scoped_ptr( - new net::TCPClientSocket(addresses, net_log_, net_log_source_)); + new net::TCPClientSocket(addresses, nullptr, net_log_, net_log_source_)); // Options cannot be set on the TCPClientSocket yet, because the // underlying platform socket will not be created until Bind() // or Connect() is called. diff --git a/extensions/browser/api/cast_channel/cast_socket_unittest.cc b/extensions/browser/api/cast_channel/cast_socket_unittest.cc index dbc46dcef32498..352a55967662f6 100644 --- a/extensions/browser/api/cast_channel/cast_socket_unittest.cc +++ b/extensions/browser/api/cast_channel/cast_socket_unittest.cc @@ -83,12 +83,18 @@ CastMessage CreateTestMessage() { class MockTCPSocket : public net::TCPClientSocket { public: explicit MockTCPSocket(const net::MockConnect& connect_data) - : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()), + : TCPClientSocket(net::AddressList(), + nullptr, + nullptr, + net::NetLog::Source()), connect_data_(connect_data), do_nothing_(false) {} explicit MockTCPSocket(bool do_nothing) - : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()) { + : TCPClientSocket(net::AddressList(), + nullptr, + nullptr, + net::NetLog::Source()) { CHECK(do_nothing); do_nothing_ = do_nothing; } diff --git a/extensions/browser/api/socket/tcp_socket.cc b/extensions/browser/api/socket/tcp_socket.cc index d4aaafbd6c226c..9584c4805e511d 100644 --- a/extensions/browser/api/socket/tcp_socket.cc +++ b/extensions/browser/api/socket/tcp_socket.cc @@ -99,7 +99,7 @@ void TCPSocket::Connect(const net::AddressList& address, int result = net::ERR_CONNECTION_FAILED; if (!is_connected_) { socket_.reset( - new net::TCPClientSocket(address, NULL, net::NetLog::Source())); + new net::TCPClientSocket(address, NULL, NULL, net::NetLog::Source())); result = socket_->Connect( base::Bind(&TCPSocket::OnConnectComplete, base::Unretained(this))); } diff --git a/google_apis/gcm/base/socket_stream_unittest.cc b/google_apis/gcm/base/socket_stream_unittest.cc index 2f04308c3c742e..78299acf1e8b55 100644 --- a/google_apis/gcm/base/socket_stream_unittest.cc +++ b/google_apis/gcm/base/socket_stream_unittest.cc @@ -176,7 +176,7 @@ void GCMSocketStreamTest::WaitForData(int msg_size) { void GCMSocketStreamTest::OpenConnection() { socket_ = socket_factory_.CreateTransportClientSocket( - address_list_, NULL, net::NetLog::Source()); + address_list_, NULL, NULL, net::NetLog::Source()); socket_->Connect( base::Bind(&GCMSocketStreamTest::ConnectCallback, base::Unretained(this))); diff --git a/google_apis/gcm/engine/connection_handler_impl_unittest.cc b/google_apis/gcm/engine/connection_handler_impl_unittest.cc index 9ca9c6483ea346..97a026849ca604 100644 --- a/google_apis/gcm/engine/connection_handler_impl_unittest.cc +++ b/google_apis/gcm/engine/connection_handler_impl_unittest.cc @@ -210,7 +210,7 @@ net::StreamSocket* GCMConnectionHandlerImplTest::BuildSocket( socket_factory_.AddSocketDataProvider(data_provider_.get()); socket_ = socket_factory_.CreateTransportClientSocket( - address_list_, NULL, net::NetLog::Source()); + address_list_, NULL, NULL, net::NetLog::Source()); socket_->Connect(net::CompletionCallback()); run_loop_.reset(new base::RunLoop()); diff --git a/jingle/glue/chrome_async_socket_unittest.cc b/jingle/glue/chrome_async_socket_unittest.cc index d4c774d40f9e8b..146ea8390219d0 100644 --- a/jingle/glue/chrome_async_socket_unittest.cc +++ b/jingle/glue/chrome_async_socket_unittest.cc @@ -127,7 +127,7 @@ class MockXmppClientSocketFactory : public ResolvingClientSocketFactory { scoped_ptr CreateTransportClientSocket( const net::HostPortPair& host_and_port) override { return mock_client_socket_factory_->CreateTransportClientSocket( - address_list_, NULL, net::NetLog::Source()); + address_list_, NULL, NULL, net::NetLog::Source()); } scoped_ptr CreateSSLClientSocket( diff --git a/jingle/glue/fake_ssl_client_socket_unittest.cc b/jingle/glue/fake_ssl_client_socket_unittest.cc index aa1cfb3b5aa484..583e1967e02fb4 100644 --- a/jingle/glue/fake_ssl_client_socket_unittest.cc +++ b/jingle/glue/fake_ssl_client_socket_unittest.cc @@ -101,7 +101,7 @@ class FakeSSLClientSocketTest : public testing::Test { scoped_ptr MakeClientSocket() { return mock_client_socket_factory_.CreateTransportClientSocket( - net::AddressList(), NULL, net::NetLog::Source()); + net::AddressList(), NULL, NULL, net::NetLog::Source()); } void SetData(const net::MockConnect& mock_connect, diff --git a/net/base/network_quality_estimator_unittest.cc b/net/base/network_quality_estimator_unittest.cc index 13d35b1b1a0b63..8641c84dcf4d7c 100644 --- a/net/base/network_quality_estimator_unittest.cc +++ b/net/base/network_quality_estimator_unittest.cc @@ -4,6 +4,7 @@ #include "net/base/network_quality_estimator.h" +#include #include #include @@ -1122,4 +1123,59 @@ TEST(NetworkQualityEstimatorTest, TestObservers) { rtt_observer.observations().at(3).rtt_ms); } +// TestTCPSocketRTT requires kernel support for tcp_info struct, and so it is +// enabled only on certain platforms. +#if defined(TCP_INFO) || defined(OS_LINUX) +#define MAYBE_TestTCPSocketRTT TestTCPSocketRTT +#else +#define MAYBE_TestTCPSocketRTT DISABLED_TestTCPSocketRTT +#endif +// Tests that the TCP socket notifies the Network Quality Estimator of TCP RTTs, +// which in turn notifies registered RTT observers. +TEST(NetworkQualityEstimatorTest, MAYBE_TestTCPSocketRTT) { + TestRTTObserver rtt_observer; + std::map variation_params; + TestNetworkQualityEstimator estimator(variation_params); + estimator.AddRTTObserver(&rtt_observer); + + TestDelegate test_delegate; + TestURLRequestContext context(true); + context.set_network_quality_estimator(&estimator); + + scoped_ptr params(new HttpNetworkSession::Params); + // |estimator| should be notified of TCP RTT observations. + params->socket_performance_watcher_factory = + estimator.GetSocketPerformanceWatcherFactory(); + context.set_http_network_session_params(std::move(params)); + context.Init(); + + EXPECT_EQ(0U, rtt_observer.observations().size()); + + // Send two requests. Verify that the completion of each request generates at + // least one TCP RTT observation. + for (size_t i = 0; i < 2; ++i) { + size_t before_count_tcp_rtt_observations = 0; + for (const auto& observation : rtt_observer.observations()) { + if (observation.source == NetworkQualityEstimator::TCP) + ++before_count_tcp_rtt_observations; + } + + scoped_ptr request(context.CreateRequest( + estimator.GetEchoURL(), DEFAULT_PRIORITY, &test_delegate)); + request->Start(); + base::RunLoop().Run(); + + size_t after_count_tcp_rtt_observations = 0; + for (const auto& observation : rtt_observer.observations()) { + if (observation.source == NetworkQualityEstimator::TCP) + ++after_count_tcp_rtt_observations; + } + // At least one notification should be received per socket performance + // watcher. + EXPECT_LE(1U, after_count_tcp_rtt_observations - + before_count_tcp_rtt_observations) + << i; + } +} + } // namespace net diff --git a/net/dns/address_sorter_posix_unittest.cc b/net/dns/address_sorter_posix_unittest.cc index c10745bb92db15..b3728291a70ba1 100644 --- a/net/dns/address_sorter_posix_unittest.cc +++ b/net/dns/address_sorter_posix_unittest.cc @@ -9,6 +9,7 @@ #include "base/macros.h" #include "net/base/ip_address.h" #include "net/base/net_errors.h" +#include "net/base/socket_performance_watcher.h" #include "net/base/test_completion_callback.h" #include "net/socket/client_socket_factory.h" #include "net/socket/ssl_client_socket.h" @@ -108,6 +109,7 @@ class TestSocketFactory : public ClientSocketFactory { } scoped_ptr CreateTransportClientSocket( const AddressList&, + scoped_ptr, NetLog*, const NetLog::Source&) override { NOTIMPLEMENTED(); diff --git a/net/dns/dns_session_unittest.cc b/net/dns/dns_session_unittest.cc index e6040850bf659d..5d9006ce0abd53 100644 --- a/net/dns/dns_session_unittest.cc +++ b/net/dns/dns_session_unittest.cc @@ -12,6 +12,7 @@ #include "base/rand_util.h" #include "base/stl_util.h" #include "net/base/ip_address.h" +#include "net/base/socket_performance_watcher.h" #include "net/dns/dns_protocol.h" #include "net/dns/dns_socket_pool.h" #include "net/log/net_log.h" @@ -36,6 +37,7 @@ class TestClientSocketFactory : public ClientSocketFactory { scoped_ptr CreateTransportClientSocket( const AddressList& addresses, + scoped_ptr, NetLog*, const NetLog::Source&) override { NOTIMPLEMENTED(); diff --git a/net/dns/dns_socket_pool.cc b/net/dns/dns_socket_pool.cc index e365d57a190434..cfa55e2e4c4f57 100644 --- a/net/dns/dns_socket_pool.cc +++ b/net/dns/dns_socket_pool.cc @@ -62,9 +62,8 @@ scoped_ptr DnsSocketPool::CreateTCPSocket( const NetLog::Source& source) { DCHECK_LT(server_index, nameservers_->size()); - return scoped_ptr( - socket_factory_->CreateTransportClientSocket( - AddressList((*nameservers_)[server_index]), net_log_, source)); + return scoped_ptr(socket_factory_->CreateTransportClientSocket( + AddressList((*nameservers_)[server_index]), NULL, net_log_, source)); } scoped_ptr DnsSocketPool::CreateConnectedSocket( diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index 0b458007e90ab0..45e57fd06f7cbc 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -655,7 +655,7 @@ int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { int FtpNetworkTransaction::DoCtrlConnect() { next_state_ = STATE_CTRL_CONNECT_COMPLETE; ctrl_socket_ = socket_factory_->CreateTransportClientSocket( - addresses_, net_log_.net_log(), net_log_.source()); + addresses_, NULL, net_log_.net_log(), net_log_.source()); net_log_.AddEvent( NetLog::TYPE_FTP_CONTROL_CONNECTION, ctrl_socket_->NetLog().source().ToEventParametersCallback()); @@ -1232,7 +1232,7 @@ int FtpNetworkTransaction::DoDataConnect() { data_address = AddressList::CreateFromIPAddress( ip_endpoint.address(), data_connection_port_); data_socket_ = socket_factory_->CreateTransportClientSocket( - data_address, net_log_.net_log(), net_log_.source()); + data_address, NULL, net_log_.net_log(), net_log_.source()); net_log_.AddEvent( NetLog::TYPE_FTP_DATA_CONNECTION, data_socket_->NetLog().source().ToEventParametersCallback()); diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index 5b95d69e2a2cae..613a0ee307845d 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -48,7 +48,8 @@ ClientSocketPoolManager* CreateSocketPoolManager( params.net_log, params.client_socket_factory ? params.client_socket_factory : ClientSocketFactory::GetDefaultFactory(), - params.host_resolver, params.cert_verifier, params.channel_id_service, + params.socket_performance_watcher_factory, params.host_resolver, + params.cert_verifier, params.channel_id_service, params.transport_security_state, params.cert_transparency_verifier, params.ct_policy_enforcer, ssl_session_cache_shard, params.ssl_config_service, pool_type); diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 6be19d7e408157..3b180d8918c5f4 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -631,8 +631,7 @@ template CaptureGroupNameSocketPool::CaptureGroupNameSocketPool( HostResolver* host_resolver, CertVerifier* /* cert_verifier */) - : ParentPool(0, 0, host_resolver, NULL, NULL) { -} + : ParentPool(0, 0, host_resolver, NULL, NULL, NULL) {} template <> CaptureGroupNameHttpProxySocketPool::CaptureGroupNameSocketPool( @@ -11674,9 +11673,8 @@ TEST_P(HttpNetworkTransactionTest, MultiRoundAuth) { TransportClientSocketPool* transport_pool = new TransportClientSocketPool( 50, // Max sockets for pool 1, // Max sockets per group - session_deps_.host_resolver.get(), - session_deps_.socket_factory.get(), - session_deps_.net_log); + session_deps_.host_resolver.get(), session_deps_.socket_factory.get(), + NULL, session_deps_.net_log); scoped_ptr mock_pool_manager( new MockClientSocketPoolManager); mock_pool_manager->SetTransportSocketPool(transport_pool); diff --git a/net/http/http_stream_factory_impl_unittest.cc b/net/http/http_stream_factory_impl_unittest.cc index f95ea511fa3a17..847a995fceff07 100644 --- a/net/http/http_stream_factory_impl_unittest.cc +++ b/net/http/http_stream_factory_impl_unittest.cc @@ -433,8 +433,8 @@ template CapturePreconnectsSocketPool::CapturePreconnectsSocketPool( HostResolver* host_resolver, CertVerifier* /* cert_verifier */) - : ParentPool(0, 0, host_resolver, nullptr, nullptr), last_num_streams_(-1) { -} + : ParentPool(0, 0, host_resolver, nullptr, nullptr, nullptr), + last_num_streams_(-1) {} template <> CapturePreconnectsHttpProxySocketPool::CapturePreconnectsSocketPool( diff --git a/net/server/http_server_unittest.cc b/net/server/http_server_unittest.cc index 2c72323db9890f..2b4c9e6e4fc883 100644 --- a/net/server/http_server_unittest.cc +++ b/net/server/http_server_unittest.cc @@ -78,7 +78,7 @@ class TestHttpClient { int ConnectAndWait(const IPEndPoint& address) { AddressList addresses(address); NetLog::Source source; - socket_.reset(new TCPClientSocket(addresses, NULL, source)); + socket_.reset(new TCPClientSocket(addresses, NULL, NULL, source)); base::RunLoop run_loop; connect_result_ = socket_->Connect(base::Bind(&TestHttpClient::OnConnect, diff --git a/net/socket/client_socket_factory.cc b/net/socket/client_socket_factory.cc index 311f926b59fcef..72aa24572da10d 100644 --- a/net/socket/client_socket_factory.cc +++ b/net/socket/client_socket_factory.cc @@ -60,10 +60,11 @@ class DefaultClientSocketFactory : public ClientSocketFactory, scoped_ptr CreateTransportClientSocket( const AddressList& addresses, + scoped_ptr socket_performance_watcher, NetLog* net_log, const NetLog::Source& source) override { - return scoped_ptr( - new TCPClientSocket(addresses, net_log, source)); + return scoped_ptr(new TCPClientSocket( + addresses, std::move(socket_performance_watcher), net_log, source)); } scoped_ptr CreateSSLClientSocket( diff --git a/net/socket/client_socket_factory.h b/net/socket/client_socket_factory.h index 668f39e3032766..be12df748788be 100644 --- a/net/socket/client_socket_factory.h +++ b/net/socket/client_socket_factory.h @@ -10,6 +10,7 @@ #include "base/memory/scoped_ptr.h" #include "net/base/net_export.h" #include "net/base/rand_callback.h" +#include "net/base/socket_performance_watcher.h" #include "net/log/net_log.h" #include "net/udp/datagram_socket.h" @@ -40,6 +41,7 @@ class NET_EXPORT ClientSocketFactory { virtual scoped_ptr CreateTransportClientSocket( const AddressList& addresses, + scoped_ptr socket_performance_watcher, NetLog* net_log, const NetLog::Source& source) = 0; diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index 308d4af9248efe..78093ccd481768 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -29,6 +29,7 @@ #include "net/base/load_timing_info_test_util.h" #include "net/base/net_errors.h" #include "net/base/request_priority.h" +#include "net/base/socket_performance_watcher.h" #include "net/base/test_completion_callback.h" #include "net/http/http_response_headers.h" #include "net/log/net_log.h" @@ -214,6 +215,7 @@ class MockClientSocketFactory : public ClientSocketFactory { scoped_ptr CreateTransportClientSocket( const AddressList& addresses, + scoped_ptr /* socket_performance_watcher */, NetLog* /* net_log */, const NetLog::Source& /*source*/) override { allocation_count_++; @@ -309,7 +311,7 @@ class TestConnectJob : public ConnectJob { int ConnectInternal() override { AddressList ignored; - client_socket_factory_->CreateTransportClientSocket(ignored, NULL, + client_socket_factory_->CreateTransportClientSocket(ignored, NULL, NULL, NetLog::Source()); SetSocket( scoped_ptr(new MockClientSocket(net_log().net_log()))); diff --git a/net/socket/client_socket_pool_manager_impl.cc b/net/socket/client_socket_pool_manager_impl.cc index f2d512c2a91fab..def70d0b459758 100644 --- a/net/socket/client_socket_pool_manager_impl.cc +++ b/net/socket/client_socket_pool_manager_impl.cc @@ -19,6 +19,8 @@ namespace net { +class SocketPerformanceWatcherFactory; + namespace { // Appends information about all |socket_pools| to the end of |list|. @@ -40,6 +42,7 @@ void AddSocketPoolsToList(base::ListValue* list, ClientSocketPoolManagerImpl::ClientSocketPoolManagerImpl( NetLog* net_log, ClientSocketFactory* socket_factory, + SocketPerformanceWatcherFactory* socket_performance_watcher_factory, HostResolver* host_resolver, CertVerifier* cert_verifier, ChannelIDService* channel_id_service, @@ -51,6 +54,7 @@ ClientSocketPoolManagerImpl::ClientSocketPoolManagerImpl( HttpNetworkSession::SocketPoolType pool_type) : net_log_(net_log), socket_factory_(socket_factory), + socket_performance_watcher_factory_(socket_performance_watcher_factory), host_resolver_(host_resolver), cert_verifier_(cert_verifier), channel_id_service_(channel_id_service), @@ -60,19 +64,21 @@ ClientSocketPoolManagerImpl::ClientSocketPoolManagerImpl( ssl_session_cache_shard_(ssl_session_cache_shard), ssl_config_service_(ssl_config_service), pool_type_(pool_type), - transport_socket_pool_( - pool_type == HttpNetworkSession::WEBSOCKET_SOCKET_POOL - ? new WebSocketTransportClientSocketPool( - max_sockets_per_pool(pool_type), - max_sockets_per_group(pool_type), - host_resolver, - socket_factory_, - net_log) - : new TransportClientSocketPool(max_sockets_per_pool(pool_type), - max_sockets_per_group(pool_type), - host_resolver, - socket_factory_, - net_log)), + transport_socket_pool_(pool_type == + HttpNetworkSession::WEBSOCKET_SOCKET_POOL + ? new WebSocketTransportClientSocketPool( + max_sockets_per_pool(pool_type), + max_sockets_per_group(pool_type), + host_resolver, + socket_factory_, + net_log) + : new TransportClientSocketPool( + max_sockets_per_pool(pool_type), + max_sockets_per_group(pool_type), + host_resolver, + socket_factory_, + socket_performance_watcher_factory_, + net_log)), ssl_socket_pool_(new SSLClientSocketPool(max_sockets_per_pool(pool_type), max_sockets_per_group(pool_type), cert_verifier, @@ -216,25 +222,19 @@ SOCKSClientSocketPool* ClientSocketPoolManagerImpl::GetSocketPoolForSOCKSProxy( max_sockets_per_group(pool_type_)); std::pair tcp_ret = - transport_socket_pools_for_socks_proxies_.insert( - std::make_pair( - socks_proxy, - new TransportClientSocketPool( - sockets_per_proxy_server, - sockets_per_group, - host_resolver_, - socket_factory_, - net_log_))); + transport_socket_pools_for_socks_proxies_.insert(std::make_pair( + socks_proxy, + new TransportClientSocketPool(sockets_per_proxy_server, + sockets_per_group, host_resolver_, + socket_factory_, nullptr, net_log_))); DCHECK(tcp_ret.second); std::pair ret = - socks_socket_pools_.insert( - std::make_pair(socks_proxy, new SOCKSClientSocketPool( - sockets_per_proxy_server, - sockets_per_group, - host_resolver_, - tcp_ret.first->second, - net_log_))); + socks_socket_pools_.insert(std::make_pair( + socks_proxy, + new SOCKSClientSocketPool(sockets_per_proxy_server, sockets_per_group, + host_resolver_, tcp_ret.first->second, + nullptr, net_log_))); return ret.first->second; } @@ -260,27 +260,19 @@ ClientSocketPoolManagerImpl::GetSocketPoolForHTTPProxy( max_sockets_per_group(pool_type_)); std::pair tcp_http_ret = - transport_socket_pools_for_http_proxies_.insert( - std::make_pair( - http_proxy, - new TransportClientSocketPool( - sockets_per_proxy_server, - sockets_per_group, - host_resolver_, - socket_factory_, - net_log_))); + transport_socket_pools_for_http_proxies_.insert(std::make_pair( + http_proxy, + new TransportClientSocketPool( + sockets_per_proxy_server, sockets_per_group, host_resolver_, + socket_factory_, socket_performance_watcher_factory_, net_log_))); DCHECK(tcp_http_ret.second); std::pair tcp_https_ret = - transport_socket_pools_for_https_proxies_.insert( - std::make_pair( - http_proxy, - new TransportClientSocketPool( - sockets_per_proxy_server, - sockets_per_group, - host_resolver_, - socket_factory_, - net_log_))); + transport_socket_pools_for_https_proxies_.insert(std::make_pair( + http_proxy, + new TransportClientSocketPool( + sockets_per_proxy_server, sockets_per_group, host_resolver_, + socket_factory_, socket_performance_watcher_factory_, net_log_))); DCHECK(tcp_https_ret.second); std::pair ssl_https_ret = diff --git a/net/socket/client_socket_pool_manager_impl.h b/net/socket/client_socket_pool_manager_impl.h index e0662f190378c0..d4a3f64f367beb 100644 --- a/net/socket/client_socket_pool_manager_impl.h +++ b/net/socket/client_socket_pool_manager_impl.h @@ -27,6 +27,7 @@ class CTVerifier; class HttpProxyClientSocketPool; class HostResolver; class NetLog; +class SocketPerformanceWatcherFactory; class SOCKSClientSocketPool; class SSLClientSocketPool; class SSLConfigService; @@ -54,17 +55,19 @@ class ClientSocketPoolManagerImpl : public base::NonThreadSafe, public ClientSocketPoolManager, public CertDatabase::Observer { public: - ClientSocketPoolManagerImpl(NetLog* net_log, - ClientSocketFactory* socket_factory, - HostResolver* host_resolver, - CertVerifier* cert_verifier, - ChannelIDService* channel_id_service, - TransportSecurityState* transport_security_state, - CTVerifier* cert_transparency_verifier, - CTPolicyEnforcer* ct_policy_enforcer, - const std::string& ssl_session_cache_shard, - SSLConfigService* ssl_config_service, - HttpNetworkSession::SocketPoolType pool_type); + ClientSocketPoolManagerImpl( + NetLog* net_log, + ClientSocketFactory* socket_factory, + SocketPerformanceWatcherFactory* socket_performance_watcher_factory, + HostResolver* host_resolver, + CertVerifier* cert_verifier, + ChannelIDService* channel_id_service, + TransportSecurityState* transport_security_state, + CTVerifier* cert_transparency_verifier, + CTPolicyEnforcer* ct_policy_enforcer, + const std::string& ssl_session_cache_shard, + SSLConfigService* ssl_config_service, + HttpNetworkSession::SocketPoolType pool_type); ~ClientSocketPoolManagerImpl() override; void FlushSocketPoolsWithError(int error) override; @@ -102,6 +105,7 @@ class ClientSocketPoolManagerImpl : public base::NonThreadSafe, NetLog* const net_log_; ClientSocketFactory* const socket_factory_; + SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; HostResolver* const host_resolver_; CertVerifier* const cert_verifier_; ChannelIDService* const channel_id_service_; diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index f6b2e098feb88a..9c99cef509dde3 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -728,6 +728,7 @@ MockClientSocketFactory::CreateDatagramClientSocket( scoped_ptr MockClientSocketFactory::CreateTransportClientSocket( const AddressList& addresses, + scoped_ptr socket_performance_watcher, NetLog* net_log, const NetLog::Source& source) { SocketDataProvider* data_provider = mock_data_.GetNext(); @@ -1612,12 +1613,12 @@ MockTransportClientSocketPool::MockTransportClientSocketPool( max_sockets_per_group, NULL, NULL, + NULL, NULL), client_socket_factory_(socket_factory), last_request_priority_(DEFAULT_PRIORITY), release_count_(0), - cancel_count_(0) { -} + cancel_count_(0) {} MockTransportClientSocketPool::~MockTransportClientSocketPool() {} @@ -1632,7 +1633,7 @@ int MockTransportClientSocketPool::RequestSocket( last_request_priority_ = priority; scoped_ptr socket = client_socket_factory_->CreateTransportClientSocket( - AddressList(), net_log.net_log(), NetLog::Source()); + AddressList(), NULL, net_log.net_log(), NetLog::Source()); MockConnectJob* job = new MockConnectJob(std::move(socket), handle, callback); job_list_.push_back(make_scoped_ptr(job)); handle->set_pool_id(1); @@ -1665,9 +1666,9 @@ MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( max_sockets_per_group, NULL, transport_pool, + NULL, NULL), - transport_pool_(transport_pool) { -} + transport_pool_(transport_pool) {} MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h index dada520bd0dff1..f942a3511be628 100644 --- a/net/socket/socket_test_util.h +++ b/net/socket/socket_test_util.h @@ -25,6 +25,7 @@ #include "net/base/address_list.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" +#include "net/base/socket_performance_watcher.h" #include "net/base/test_completion_callback.h" #include "net/http/http_auth_controller.h" #include "net/http/http_proxy_client_socket_pool.h" @@ -521,6 +522,7 @@ class MockClientSocketFactory : public ClientSocketFactory { const NetLog::Source& source) override; scoped_ptr CreateTransportClientSocket( const AddressList& addresses, + scoped_ptr socket_performance_watcher, NetLog* net_log, const NetLog::Source& source) override; scoped_ptr CreateSSLClientSocket( diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc index d7f97f3ec8b762..b3d8995a43a321 100644 --- a/net/socket/socks_client_socket_pool.cc +++ b/net/socket/socks_client_socket_pool.cc @@ -188,6 +188,7 @@ SOCKSClientSocketPool::SOCKSClientSocketPool( int max_sockets_per_group, HostResolver* host_resolver, TransportClientSocketPool* transport_pool, + SocketPerformanceWatcherFactory*, NetLog* net_log) : transport_pool_(transport_pool), base_( diff --git a/net/socket/socks_client_socket_pool.h b/net/socket/socks_client_socket_pool.h index 66d0e53794e375..175ce4964fb273 100644 --- a/net/socket/socks_client_socket_pool.h +++ b/net/socket/socks_client_socket_pool.h @@ -20,6 +20,7 @@ namespace net { class ConnectJobFactory; +class SocketPerformanceWatcherFactory; class TransportClientSocketPool; class TransportSocketParams; @@ -107,12 +108,12 @@ class NET_EXPORT_PRIVATE SOCKSClientSocketPool public: typedef SOCKSSocketParams SocketParams; - SOCKSClientSocketPool( - int max_sockets, - int max_sockets_per_group, - HostResolver* host_resolver, - TransportClientSocketPool* transport_pool, - NetLog* net_log); + SOCKSClientSocketPool(int max_sockets, + int max_sockets_per_group, + HostResolver* host_resolver, + TransportClientSocketPool* transport_pool, + SocketPerformanceWatcherFactory*, + NetLog* net_log); ~SOCKSClientSocketPool() override; diff --git a/net/socket/socks_client_socket_pool_unittest.cc b/net/socket/socks_client_socket_pool_unittest.cc index 5d16ce4cdb5169..5723bef9660db9 100644 --- a/net/socket/socks_client_socket_pool_unittest.cc +++ b/net/socket/socks_client_socket_pool_unittest.cc @@ -96,6 +96,7 @@ class SOCKSClientSocketPoolTest : public testing::Test { kMaxSocketsPerGroup, &host_resolver_, &transport_socket_pool_, + NULL, NULL) {} ~SOCKSClientSocketPoolTest() override {} diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc index d5656567984ca3..d95956bfa1a16e 100644 --- a/net/socket/ssl_client_socket_unittest.cc +++ b/net/socket/ssl_client_socket_unittest.cc @@ -773,7 +773,7 @@ class SSLClientSocketTest : public PlatformTest { bool CreateAndConnectSSLClientSocket(const SSLConfig& ssl_config, int* result) { scoped_ptr transport( - new TCPClientSocket(addr_, &log_, NetLog::Source())); + new TCPClientSocket(addr_, NULL, &log_, NetLog::Source())); int rv = callback_.GetResult(transport->Connect(callback_.callback())); if (rv != OK) { LOG(ERROR) << "Could not connect to SpawnedTestServer"; @@ -836,7 +836,7 @@ class SSLClientSocketCertRequestInfoTest : public SSLClientSocketTest { TestCompletionCallback callback; TestNetLog log; scoped_ptr transport( - new TCPClientSocket(addr, &log, NetLog::Source())); + new TCPClientSocket(addr, NULL, &log, NetLog::Source())); int rv = callback.GetResult(transport->Connect(callback.callback())); EXPECT_EQ(OK, rv); @@ -882,7 +882,7 @@ class SSLClientSocketFalseStartTest : public SSLClientSocketTest { CHECK(spawned_test_server()); scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); scoped_ptr transport( new FakeBlockingStreamSocket(std::move(real_transport))); int rv = callback->GetResult(transport->Connect(callback->callback())); @@ -1001,7 +1001,7 @@ TEST_F(SSLClientSocketTest, Connect) { TestCompletionCallback callback; TestNetLog log; scoped_ptr transport( - new TCPClientSocket(addr(), &log, NetLog::Source())); + new TCPClientSocket(addr(), NULL, &log, NetLog::Source())); int rv = callback.GetResult(transport->Connect(callback.callback())); EXPECT_EQ(OK, rv); @@ -1147,7 +1147,7 @@ TEST_F(SSLClientSocketTest, Read) { TestCompletionCallback callback; scoped_ptr transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); EXPECT_EQ(0, transport->GetTotalReceivedBytes()); int rv = callback.GetResult(transport->Connect(callback.callback())); @@ -1204,7 +1204,7 @@ TEST_F(SSLClientSocketTest, Connect_WithSynchronousError) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); scoped_ptr transport( new SynchronousErrorStreamSocket(std::move(real_transport))); int rv = callback.GetResult(transport->Connect(callback.callback())); @@ -1235,7 +1235,7 @@ TEST_F(SSLClientSocketTest, Read_WithSynchronousError) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); scoped_ptr transport( new SynchronousErrorStreamSocket(std::move(real_transport))); int rv = callback.GetResult(transport->Connect(callback.callback())); @@ -1285,7 +1285,7 @@ TEST_F(SSLClientSocketTest, Write_WithSynchronousError) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); // Note: |error_socket|'s ownership is handed to |transport|, but a pointer // is retained in order to configure additional errors. scoped_ptr error_socket( @@ -1352,7 +1352,7 @@ TEST_F(SSLClientSocketTest, Write_WithSynchronousErrorNoRead) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); // Note: intermediate sockets' ownership are handed to |sock|, but a pointer // is retained in order to query them. scoped_ptr error_socket( @@ -1452,7 +1452,7 @@ TEST_F(SSLClientSocketTest, Read_DeleteWhilePendingFullDuplex) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); // Note: |error_socket|'s ownership is handed to |transport|, but a pointer // is retained in order to configure additional errors. scoped_ptr error_socket( @@ -1561,7 +1561,7 @@ TEST_F(SSLClientSocketTest, Read_WithWriteError) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); // Note: |error_socket|'s ownership is handed to |transport|, but a pointer // is retained in order to configure additional errors. scoped_ptr error_socket( @@ -1658,7 +1658,7 @@ TEST_F(SSLClientSocketTest, Connect_WithZeroReturn) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); scoped_ptr transport( new SynchronousErrorStreamSocket(std::move(real_transport))); int rv = callback.GetResult(transport->Connect(callback.callback())); @@ -1684,7 +1684,7 @@ TEST_F(SSLClientSocketTest, Read_WithZeroReturn) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); scoped_ptr transport( new SynchronousErrorStreamSocket(std::move(real_transport))); int rv = callback.GetResult(transport->Connect(callback.callback())); @@ -1717,7 +1717,7 @@ TEST_F(SSLClientSocketTest, Read_WithAsyncZeroReturn) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); scoped_ptr error_socket( new SynchronousErrorStreamSocket(std::move(real_transport))); SynchronousErrorStreamSocket* raw_error_socket = error_socket.get(); @@ -1798,7 +1798,7 @@ TEST_F(SSLClientSocketTest, Read_ManySmallRecords) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); scoped_ptr transport( new ReadBufferingStreamSocket(std::move(real_transport))); ReadBufferingStreamSocket* raw_transport = transport.get(); @@ -1869,7 +1869,7 @@ TEST_F(SSLClientSocketTest, Read_FullLogging) { TestNetLog log; log.SetCaptureMode(NetLogCaptureMode::IncludeSocketBytes()); scoped_ptr transport( - new TCPClientSocket(addr(), &log, NetLog::Source())); + new TCPClientSocket(addr(), NULL, &log, NetLog::Source())); int rv = callback.GetResult(transport->Connect(callback.callback())); EXPECT_EQ(OK, rv); @@ -1983,7 +1983,7 @@ TEST_F(SSLClientSocketTest, ClientSocketHandleNotFromPool) { TestCompletionCallback callback; scoped_ptr transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); int rv = callback.GetResult(transport->Connect(callback.callback())); EXPECT_EQ(OK, rv); @@ -2512,7 +2512,7 @@ TEST_F(SSLClientSocketTest, ReusableAfterWrite) { TestCompletionCallback callback; scoped_ptr real_transport( - new TCPClientSocket(addr(), NULL, NetLog::Source())); + new TCPClientSocket(addr(), NULL, NULL, NetLog::Source())); scoped_ptr transport( new FakeBlockingStreamSocket(std::move(real_transport))); FakeBlockingStreamSocket* raw_transport = transport.get(); @@ -2568,7 +2568,7 @@ TEST_F(SSLClientSocketTest, SessionResumption) { // Using a different HostPortPair uses a different session cache key. scoped_ptr transport( - new TCPClientSocket(addr(), &log_, NetLog::Source())); + new TCPClientSocket(addr(), NULL, &log_, NetLog::Source())); TestCompletionCallback callback; ASSERT_EQ(OK, callback.GetResult(transport->Connect(callback.callback()))); scoped_ptr sock = CreateSSLClientSocket( diff --git a/net/socket/tcp_client_socket.cc b/net/socket/tcp_client_socket.cc index 56238ba0d12cb5..1ae979ea3f90c1 100644 --- a/net/socket/tcp_client_socket.cc +++ b/net/socket/tcp_client_socket.cc @@ -14,13 +14,19 @@ #include "net/base/io_buffer.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" +#include "net/base/socket_performance_watcher.h" namespace net { -TCPClientSocket::TCPClientSocket(const AddressList& addresses, - net::NetLog* net_log, - const net::NetLog::Source& source) - : socket_(new TCPSocket(net_log, source)), +TCPClientSocket::TCPClientSocket( + const AddressList& addresses, + scoped_ptr socket_performance_watcher, + net::NetLog* net_log, + const net::NetLog::Source& source) + : socket_performance_watcher_(socket_performance_watcher.get()), + socket_(new TCPSocket(std::move(socket_performance_watcher), + net_log, + source)), addresses_(addresses), current_address_index_(-1), next_connect_state_(CONNECT_STATE_NONE), @@ -29,7 +35,8 @@ TCPClientSocket::TCPClientSocket(const AddressList& addresses, TCPClientSocket::TCPClientSocket(scoped_ptr connected_socket, const IPEndPoint& peer_address) - : socket_(std::move(connected_socket)), + : socket_performance_watcher_(nullptr), + socket_(std::move(connected_socket)), addresses_(AddressList(peer_address)), current_address_index_(0), next_connect_state_(CONNECT_STATE_NONE), @@ -152,6 +159,11 @@ int TCPClientSocket::DoConnect() { } } + // Notify |socket_performance_watcher_| only if the |socket_| is reused to + // connect to a different IP Address. + if (socket_performance_watcher_ && current_address_index_ != 0) + socket_performance_watcher_->OnConnectionChanged(); + // |socket_| is owned by this class and the callback won't be run once // |socket_| is gone. Therefore, it is safe to use base::Unretained() here. return socket_->Connect(endpoint, diff --git a/net/socket/tcp_client_socket.h b/net/socket/tcp_client_socket.h index ae6083fed6c5b3..ddda0a6431f867 100644 --- a/net/socket/tcp_client_socket.h +++ b/net/socket/tcp_client_socket.h @@ -20,15 +20,19 @@ namespace net { +class SocketPerformanceWatcher; + // A client socket that uses TCP as the transport layer. class NET_EXPORT TCPClientSocket : public StreamSocket { public: // The IP address(es) and port number to connect to. The TCP socket will try // each IP address in the list until it succeeds in establishing a // connection. - TCPClientSocket(const AddressList& addresses, - net::NetLog* net_log, - const net::NetLog::Source& source); + TCPClientSocket( + const AddressList& addresses, + scoped_ptr socket_performance_watcher, + net::NetLog* net_log, + const net::NetLog::Source& source); // Adopts the given, connected socket and then acts as if Connect() had been // called. This function is used by TCPServerSocket and for testing. @@ -104,6 +108,13 @@ class NET_EXPORT TCPClientSocket : public StreamSocket { // disconnected. void EmitTCPMetricsHistogramsOnDisconnect(); + // Socket performance statistics (such as RTT) are reported to the + // |socket_performance_watcher_|. May be nullptr. + // |socket_performance_watcher_| is owned by |socket_|. If non-null, + // |socket_performance_watcher_| is guaranteed to be destroyed when |socket_| + // is destroyed. + SocketPerformanceWatcher* socket_performance_watcher_; + scoped_ptr socket_; // Local IP address and port we are bound to. Set to NULL if Bind() diff --git a/net/socket/tcp_client_socket_unittest.cc b/net/socket/tcp_client_socket_unittest.cc index 1c39719f59d421..92d59ffe87e9cd 100644 --- a/net/socket/tcp_client_socket_unittest.cc +++ b/net/socket/tcp_client_socket_unittest.cc @@ -8,13 +8,20 @@ #include "net/socket/tcp_client_socket.h" +#include + #include "net/base/ip_address.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" +#include "net/base/socket_performance_watcher.h" #include "net/base/test_completion_callback.h" #include "net/socket/tcp_server_socket.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { +class TimeDelta; +} + namespace net { namespace { @@ -29,7 +36,8 @@ TEST(TCPClientSocketTest, BindLoopbackToLoopback) { IPEndPoint server_address; ASSERT_EQ(OK, server.GetLocalAddress(&server_address)); - TCPClientSocket socket(AddressList(server_address), NULL, NetLog::Source()); + TCPClientSocket socket(AddressList(server_address), NULL, NULL, + NetLog::Source()); EXPECT_EQ(OK, socket.Bind(IPEndPoint(lo_address, 0))); @@ -61,7 +69,7 @@ TEST(TCPClientSocketTest, BindLoopbackToLoopback) { TEST(TCPClientSocketTest, BindLoopbackToExternal) { IPAddress external_ip(72, 14, 213, 105); TCPClientSocket socket(AddressList::CreateFromIPAddress(external_ip, 80), - NULL, NetLog::Source()); + NULL, NULL, NetLog::Source()); EXPECT_EQ(OK, socket.Bind(IPEndPoint(IPAddress::IPv4Localhost(), 0))); @@ -89,7 +97,8 @@ TEST(TCPClientSocketTest, BindLoopbackToIPv6) { IPEndPoint server_address; ASSERT_EQ(OK, server.GetLocalAddress(&server_address)); - TCPClientSocket socket(AddressList(server_address), NULL, NetLog::Source()); + TCPClientSocket socket(AddressList(server_address), NULL, NULL, + NetLog::Source()); EXPECT_EQ(OK, socket.Bind(IPEndPoint(IPAddress::IPv4Localhost(), 0))); @@ -101,6 +110,58 @@ TEST(TCPClientSocketTest, BindLoopbackToIPv6) { EXPECT_NE(OK, result); } +class TestSocketPerformanceWatcher : public SocketPerformanceWatcher { + public: + TestSocketPerformanceWatcher() : connection_changed_count_(0u) {} + ~TestSocketPerformanceWatcher() override {} + + bool ShouldNotifyUpdatedRTT() const override { return true; } + + void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) override {} + + void OnConnectionChanged() override { connection_changed_count_++; } + + size_t connection_changed_count() const { return connection_changed_count_; } + + private: + size_t connection_changed_count_; + + DISALLOW_COPY_AND_ASSIGN(TestSocketPerformanceWatcher); +}; + +// TestSocketPerformanceWatcher requires kernel support for tcp_info struct, and +// so it is enabled only on certain platforms. +#if defined(TCP_INFO) || defined(OS_LINUX) +#define MAYBE_TestSocketPerformanceWatcher TestSocketPerformanceWatcher +#else +#define MAYBE_TestSocketPerformanceWatcher TestSocketPerformanceWatcher +#endif +// Tests if the socket performance watcher is notified if the same socket is +// used for a different connection. +TEST(TCPClientSocketTest, MAYBE_TestSocketPerformanceWatcher) { + const size_t kNumIPs = 2; + IPAddressList ip_list; + for (size_t i = 0; i < kNumIPs; ++i) + ip_list.push_back(IPAddress(72, 14, 213, i)); + + scoped_ptr watcher( + new TestSocketPerformanceWatcher()); + TestSocketPerformanceWatcher* watcher_ptr = watcher.get(); + + TCPClientSocket socket( + AddressList::CreateFromIPAddressList(ip_list, "example.com"), + std::move(watcher), NULL, NetLog::Source()); + + EXPECT_EQ(OK, socket.Bind(IPEndPoint(IPAddress::IPv4Localhost(), 0))); + + TestCompletionCallback connect_callback; + + ASSERT_NE(OK, connect_callback.GetResult( + socket.Connect(connect_callback.callback()))); + + EXPECT_EQ(kNumIPs - 1, watcher_ptr->connection_changed_count()); +} + } // namespace } // namespace net diff --git a/net/socket/tcp_server_socket.cc b/net/socket/tcp_server_socket.cc index 06f751220331da..7ff91553856490 100644 --- a/net/socket/tcp_server_socket.cc +++ b/net/socket/tcp_server_socket.cc @@ -15,9 +15,7 @@ namespace net { TCPServerSocket::TCPServerSocket(NetLog* net_log, const NetLog::Source& source) - : socket_(net_log, source), - pending_accept_(false) { -} + : socket_(nullptr, net_log, source), pending_accept_(false) {} TCPServerSocket::~TCPServerSocket() { } diff --git a/net/socket/tcp_server_socket_unittest.cc b/net/socket/tcp_server_socket_unittest.cc index 651cd6964ad1f0..b0d7039f84a07d 100644 --- a/net/socket/tcp_server_socket_unittest.cc +++ b/net/socket/tcp_server_socket_unittest.cc @@ -67,8 +67,8 @@ TEST_F(TCPServerSocketTest, Accept) { ASSERT_NO_FATAL_FAILURE(SetUpIPv4()); TestCompletionCallback connect_callback; - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); TestCompletionCallback accept_callback; @@ -98,8 +98,8 @@ TEST_F(TCPServerSocketTest, AcceptAsync) { socket_.Accept(&accepted_socket, accept_callback.callback())); TestCompletionCallback connect_callback; - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); EXPECT_EQ(OK, connect_callback.WaitForResult()); @@ -123,13 +123,13 @@ TEST_F(TCPServerSocketTest, Accept2Connections) { socket_.Accept(&accepted_socket, accept_callback.callback())); TestCompletionCallback connect_callback; - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); TestCompletionCallback connect_callback2; - TCPClientSocket connecting_socket2(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket2(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket2.Connect(connect_callback2.callback()); EXPECT_EQ(OK, accept_callback.WaitForResult()); @@ -160,8 +160,8 @@ TEST_F(TCPServerSocketTest, AcceptIPv6) { return; TestCompletionCallback connect_callback; - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); TestCompletionCallback accept_callback; @@ -184,8 +184,8 @@ TEST_F(TCPServerSocketTest, AcceptIO) { ASSERT_NO_FATAL_FAILURE(SetUpIPv4()); TestCompletionCallback connect_callback; - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); TestCompletionCallback accept_callback; diff --git a/net/socket/tcp_socket_posix.cc b/net/socket/tcp_socket_posix.cc index 95fe6b5bd011b8..d674463f83f3c8 100644 --- a/net/socket/tcp_socket_posix.cc +++ b/net/socket/tcp_socket_posix.cc @@ -14,8 +14,10 @@ #include "base/logging.h" #include "base/metrics/histogram_macros.h" #include "base/posix/eintr_wrapper.h" +#include "base/profiler/scoped_tracker.h" #include "base/task_runner_util.h" #include "base/threading/worker_pool.h" +#include "base/time/default_tick_clock.h" #include "net/base/address_list.h" #include "net/base/connection_type_histograms.h" #include "net/base/io_buffer.h" @@ -136,8 +138,14 @@ void CheckSupportAndMaybeEnableTCPFastOpen(bool user_enabled) { #endif } -TCPSocketPosix::TCPSocketPosix(NetLog* net_log, const NetLog::Source& source) - : use_tcp_fastopen_(false), +TCPSocketPosix::TCPSocketPosix( + scoped_ptr socket_performance_watcher, + NetLog* net_log, + const NetLog::Source& source) + : socket_performance_watcher_(std::move(socket_performance_watcher)), + tick_clock_(new base::DefaultTickClock()), + rtt_notifications_minimum_interval_(base::TimeDelta::FromSeconds(1)), + use_tcp_fastopen_(false), tcp_fastopen_write_attempted_(false), tcp_fastopen_connected_(false), tcp_fastopen_status_(TCP_FASTOPEN_STATUS_UNKNOWN), @@ -474,6 +482,11 @@ void TCPSocketPosix::EndLoggingMultipleConnectAttempts(int net_error) { } } +void TCPSocketPosix::SetTickClockForTesting( + scoped_ptr tick_clock) { + tick_clock_ = std::move(tick_clock); +} + void TCPSocketPosix::AcceptCompleted(scoped_ptr* tcp_socket, IPEndPoint* address, const CompletionCallback& callback, @@ -510,24 +523,26 @@ int TCPSocketPosix::BuildTcpSocketPosix(scoped_ptr* tcp_socket, return ERR_ADDRESS_INVALID; } - tcp_socket->reset(new TCPSocketPosix(net_log_.net_log(), net_log_.source())); + tcp_socket->reset( + new TCPSocketPosix(nullptr, net_log_.net_log(), net_log_.source())); (*tcp_socket)->socket_.reset(accept_socket_.release()); return OK; } void TCPSocketPosix::ConnectCompleted(const CompletionCallback& callback, - int rv) const { + int rv) { DCHECK_NE(ERR_IO_PENDING, rv); callback.Run(HandleConnectCompleted(rv)); } -int TCPSocketPosix::HandleConnectCompleted(int rv) const { +int TCPSocketPosix::HandleConnectCompleted(int rv) { // Log the end of this attempt (and any OS error it threw). if (rv != OK) { net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT, NetLog::IntCallback("os_error", errno)); } else { net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT); + NotifySocketPerformanceWatcher(); } // Give a more specific error when the user is offline. @@ -597,6 +612,11 @@ int TCPSocketPosix::HandleReadCompleted(IOBuffer* buf, int rv) { CreateNetLogSocketErrorCallback(rv, errno)); return rv; } + + // Notify the watcher only if at least 1 byte was read. + if (rv > 0) + NotifySocketPerformanceWatcher(); + net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, rv, buf->data()); NetworkActivityMonitor::GetInstance()->IncrementBytesReceived(rv); @@ -628,6 +648,11 @@ int TCPSocketPosix::HandleWriteCompleted(IOBuffer* buf, int rv) { CreateNetLogSocketErrorCallback(rv, errno)); return rv; } + + // Notify the watcher only if at least 1 byte was written. + if (rv > 0) + NotifySocketPerformanceWatcher(); + net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, rv, buf->data()); NetworkActivityMonitor::GetInstance()->IncrementBytesSent(rv); @@ -695,6 +720,45 @@ int TCPSocketPosix::TcpFastOpenWrite(IOBuffer* buf, return socket_->WaitForWrite(buf, buf_len, callback); } +void TCPSocketPosix::NotifySocketPerformanceWatcher() { +#if defined(TCP_INFO) + // TODO(tbansal): Remove ScopedTracker once crbug.com/590254 is fixed. + tracked_objects::ScopedTracker tracking_profile( + FROM_HERE_WITH_EXPLICIT_FUNCTION( + "590254 TCPSocketPosix::NotifySocketPerformanceWatcher")); + + const base::TimeTicks now_ticks = tick_clock_->NowTicks(); + // Do not notify |socket_performance_watcher_| if the last notification was + // recent than |rtt_notifications_minimum_interval_| ago. This helps in + // reducing the overall overhead of the tcp_info syscalls. + if (now_ticks - last_rtt_notification_ < rtt_notifications_minimum_interval_) + return; + + // Check if |socket_performance_watcher_| is interested in receiving a RTT + // update notification. + if (!socket_performance_watcher_ || + !socket_performance_watcher_->ShouldNotifyUpdatedRTT()) { + return; + } + + tcp_info info; + if (!GetTcpInfo(socket_->socket_fd(), &info)) + return; + + // Only notify the |socket_performance_watcher_| if the RTT in |tcp_info| + // struct was populated. A value of 0 may be valid in certain cases + // (on very fast networks), but it is discarded. This means that + // some of the RTT values may be missed, but the values that are kept are + // guaranteed to be correct. + if (info.tcpi_rtt == 0 && info.tcpi_rttvar == 0) + return; + + socket_performance_watcher_->OnUpdatedRTTAvailable( + base::TimeDelta::FromMicroseconds(info.tcpi_rtt)); + last_rtt_notification_ = now_ticks; +#endif // defined(TCP_INFO) +} + void TCPSocketPosix::UpdateTCPFastOpenStatusAfterRead() { DCHECK(tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN || tcp_fastopen_status_ == TCP_FASTOPEN_SLOW_CONNECT_RETURN); diff --git a/net/socket/tcp_socket_posix.h b/net/socket/tcp_socket_posix.h index 98849e45a1918d..d092b572da72d4 100644 --- a/net/socket/tcp_socket_posix.h +++ b/net/socket/tcp_socket_posix.h @@ -15,8 +15,13 @@ #include "net/base/address_family.h" #include "net/base/completion_callback.h" #include "net/base/net_export.h" +#include "net/base/socket_performance_watcher.h" #include "net/log/net_log.h" +namespace base { +class TickClock; +} + namespace net { class AddressList; @@ -26,7 +31,12 @@ class SocketPosix; class NET_EXPORT TCPSocketPosix { public: - TCPSocketPosix(NetLog* net_log, const NetLog::Source& source); + // |socket_performance_watcher| is notified of the performance metrics related + // to this socket. |socket_performance_watcher| may be null. + TCPSocketPosix( + scoped_ptr socket_performance_watcher, + NetLog* net_log, + const NetLog::Source& source); virtual ~TCPSocketPosix(); int Open(AddressFamily family); @@ -95,6 +105,8 @@ class NET_EXPORT TCPSocketPosix { void StartLoggingMultipleConnectAttempts(const AddressList& addresses); void EndLoggingMultipleConnectAttempts(int net_error); + void SetTickClockForTesting(scoped_ptr tick_clock); + const BoundNetLog& net_log() const { return net_log_; } private: @@ -177,8 +189,8 @@ class NET_EXPORT TCPSocketPosix { int BuildTcpSocketPosix(scoped_ptr* tcp_socket, IPEndPoint* address); - void ConnectCompleted(const CompletionCallback& callback, int rv) const; - int HandleConnectCompleted(int rv) const; + void ConnectCompleted(const CompletionCallback& callback, int rv); + int HandleConnectCompleted(int rv); void LogConnectBegin(const AddressList& addresses) const; void LogConnectEnd(int net_error) const; @@ -195,12 +207,30 @@ class NET_EXPORT TCPSocketPosix { int buf_len, const CompletionCallback& callback); + // Notifies |socket_performance_watcher_| of the latest RTT estimate available + // from the tcp_info struct for this TCP socket. + void NotifySocketPerformanceWatcher(); + // Called after the first read completes on a TCP FastOpen socket. void UpdateTCPFastOpenStatusAfterRead(); scoped_ptr socket_; scoped_ptr accept_socket_; + // Socket performance statistics (such as RTT) are reported to the + // |socket_performance_watcher_|. May be nullptr. + scoped_ptr socket_performance_watcher_; + + scoped_ptr tick_clock_; + + // Minimum interval betweeen consecutive notifications to + // |socket_performance_watcher_|. + const base::TimeDelta rtt_notifications_minimum_interval_; + + // Time when the |socket_performance_watcher_| was last notified of updated + // RTT. + base::TimeTicks last_rtt_notification_; + // Enables experimental TCP FastOpen option. bool use_tcp_fastopen_; diff --git a/net/socket/tcp_socket_unittest.cc b/net/socket/tcp_socket_unittest.cc index 15f935516739d3..5a34d40064fef7 100644 --- a/net/socket/tcp_socket_unittest.cc +++ b/net/socket/tcp_socket_unittest.cc @@ -4,6 +4,7 @@ #include "net/socket/tcp_socket.h" +#include #include #include @@ -11,12 +12,15 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/test/simple_test_tick_clock.h" +#include "base/time/time.h" #include "net/base/address_list.h" #include "net/base/io_buffer.h" #include "net/base/ip_endpoint.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" #include "net/base/sockaddr_storage.h" +#include "net/base/socket_performance_watcher.h" #include "net/base/test_completion_callback.h" #include "net/socket/tcp_client_socket.h" #include "testing/gtest/include/gtest/gtest.h" @@ -25,12 +29,42 @@ namespace net { namespace { + +class TestSocketPerformanceWatcher : public SocketPerformanceWatcher { + public: + explicit TestSocketPerformanceWatcher(bool should_notify_updated_rtt) + : should_notify_updated_rtt_(should_notify_updated_rtt), + connection_changed_count_(0u), + rtt_notification_count_(0u) {} + ~TestSocketPerformanceWatcher() override {} + + bool ShouldNotifyUpdatedRTT() const override { + return should_notify_updated_rtt_; + } + + void OnUpdatedRTTAvailable(const base::TimeDelta& rtt) override { + rtt_notification_count_++; + } + + void OnConnectionChanged() override { connection_changed_count_++; } + + size_t rtt_notification_count() const { return rtt_notification_count_; } + + size_t connection_changed_count() const { return connection_changed_count_; } + + private: + const bool should_notify_updated_rtt_; + size_t connection_changed_count_; + size_t rtt_notification_count_; + + DISALLOW_COPY_AND_ASSIGN(TestSocketPerformanceWatcher); +}; + const int kListenBacklog = 5; class TCPSocketTest : public PlatformTest { protected: - TCPSocketTest() : socket_(NULL, NetLog::Source()) { - } + TCPSocketTest() : socket_(NULL, NULL, NetLog::Source()) {} void SetUpListenIPv4() { ASSERT_EQ(OK, socket_.Open(ADDRESS_FAMILY_IPV4)); @@ -62,8 +96,8 @@ class TCPSocketTest : public PlatformTest { accept_callback.callback())); TestCompletionCallback connect_callback; - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); EXPECT_EQ(OK, connect_callback.WaitForResult()); @@ -75,6 +109,87 @@ class TCPSocketTest : public PlatformTest { EXPECT_EQ(accepted_address.address(), local_address_.address()); } +#if defined(TCP_INFO) || defined(OS_LINUX) + // Tests that notifications to Socket Performance Watcher (SPW) are delivered + // correctly. |advance_ticks| is the duration by which the clock is advanced + // before a message is read. |should_notify_updated_rtt| is true if the SPW + // is interested in receiving RTT notifications. |num_messages| is the number + // of messages that are written/read by the sockets. + // |expect_connection_changed_count| is the expected number of connection + // change notifications received by the SPW. |expect_rtt_notification_count| + // is the expected number of RTT notifications received by the SPW. + // This test works by writing |num_messages| to the socket. A different + // socket (with a SPW attached to it) reads the messages. + void TestSPWNotifications(const base::TimeDelta& advance_ticks, + bool should_notify_updated_rtt, + size_t num_messages, + size_t expect_connection_changed_count, + size_t expect_rtt_notification_count) { + ASSERT_NO_FATAL_FAILURE(SetUpListenIPv4()); + + scoped_ptr tick_clock( + new base::SimpleTestTickClock()); + base::SimpleTestTickClock* tick_clock_ptr = tick_clock.get(); + tick_clock_ptr->SetNowTicks(base::TimeTicks::Now()); + + TestCompletionCallback connect_callback; + + scoped_ptr watcher( + new TestSocketPerformanceWatcher(should_notify_updated_rtt)); + TestSocketPerformanceWatcher* watcher_ptr = watcher.get(); + + TCPSocket connecting_socket(std::move(watcher), NULL, NetLog::Source()); + connecting_socket.SetTickClockForTesting(std::move(tick_clock)); + + int result = connecting_socket.Open(ADDRESS_FAMILY_IPV4); + ASSERT_EQ(OK, result); + connecting_socket.Connect(local_address_, connect_callback.callback()); + + TestCompletionCallback accept_callback; + scoped_ptr accepted_socket; + IPEndPoint accepted_address; + result = socket_.Accept(&accepted_socket, &accepted_address, + accept_callback.callback()); + ASSERT_EQ(OK, accept_callback.GetResult(result)); + + ASSERT_TRUE(accepted_socket.get()); + + // Both sockets should be on the loopback network interface. + EXPECT_EQ(accepted_address.address(), local_address_.address()); + + ASSERT_EQ(OK, connect_callback.WaitForResult()); + + for (size_t i = 0; i < num_messages; ++i) { + tick_clock_ptr->Advance(advance_ticks); + + // Use a 1 byte message so that the watcher is notified at most once per + // message. + const std::string message("t"); + + scoped_refptr write_buffer( + new IOBufferWithSize(message.size())); + memmove(write_buffer->data(), message.data(), message.size()); + + TestCompletionCallback write_callback; + int write_result = accepted_socket->Write( + write_buffer.get(), write_buffer->size(), write_callback.callback()); + + scoped_refptr read_buffer( + new IOBufferWithSize(message.size())); + TestCompletionCallback read_callback; + int read_result = connecting_socket.Read( + read_buffer.get(), read_buffer->size(), read_callback.callback()); + + ASSERT_EQ(1, write_callback.GetResult(write_result)); + ASSERT_EQ(1, read_callback.GetResult(read_result)); + } + EXPECT_EQ(expect_connection_changed_count, + watcher_ptr->connection_changed_count()); + EXPECT_EQ(expect_rtt_notification_count, + watcher_ptr->rtt_notification_count()); + } +#endif // defined(TCP_INFO) || defined(OS_LINUX) + AddressList local_address_list() const { return AddressList(local_address_); } @@ -90,8 +205,8 @@ TEST_F(TCPSocketTest, Accept) { TestCompletionCallback connect_callback; // TODO(yzshen): Switch to use TCPSocket when it supports client socket // operations. - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); TestCompletionCallback accept_callback; @@ -149,13 +264,13 @@ TEST_F(TCPSocketTest, Accept2Connections) { accept_callback.callback())); TestCompletionCallback connect_callback; - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); TestCompletionCallback connect_callback2; - TCPClientSocket connecting_socket2(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket2(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket2.Connect(connect_callback2.callback()); EXPECT_EQ(OK, accept_callback.WaitForResult()); @@ -189,8 +304,8 @@ TEST_F(TCPSocketTest, AcceptIPv6) { return; TestCompletionCallback connect_callback; - TCPClientSocket connecting_socket(local_address_list(), - NULL, NetLog::Source()); + TCPClientSocket connecting_socket(local_address_list(), NULL, NULL, + NetLog::Source()); connecting_socket.Connect(connect_callback.callback()); TestCompletionCallback accept_callback; @@ -214,7 +329,7 @@ TEST_F(TCPSocketTest, ReadWrite) { ASSERT_NO_FATAL_FAILURE(SetUpListenIPv4()); TestCompletionCallback connect_callback; - TCPSocket connecting_socket(NULL, NetLog::Source()); + TCPSocket connecting_socket(NULL, NULL, NetLog::Source()); int result = connecting_socket.Open(ADDRESS_FAMILY_IPV4); ASSERT_EQ(OK, result); connecting_socket.Connect(local_address_, connect_callback.callback()); @@ -270,5 +385,30 @@ TEST_F(TCPSocketTest, ReadWrite) { ASSERT_EQ(message, received_message); } +// These tests require kernel support for tcp_info struct, and so they are +// enabled only on certain platforms. +#if defined(TCP_INFO) || defined(OS_LINUX) +// If SocketPerformanceWatcher::ShouldNotifyUpdatedRTT always returns false, +// then the wtatcher should not receive any notifications. +TEST_F(TCPSocketTest, SPWNotInterested) { + TestSPWNotifications(base::TimeDelta::FromSeconds(0), false, 2u, 0u, 0u); +} + +// One notification should be received when the socket connects. No additional +// notifications should be received when the message is read because the clock +// is not advanced. +TEST_F(TCPSocketTest, SPWNoAdvance) { + TestSPWNotifications(base::TimeDelta::FromSeconds(0), true, 2u, 0u, 1u); +} + +// One notification should be received when the socket connects. One +// additional notification should be received for each message read since this +// test advances clock by 2 seconds (which is longer than the minimum interval +// between consecutive notifications) before every read. +TEST_F(TCPSocketTest, SPWAdvance) { + TestSPWNotifications(base::TimeDelta::FromSeconds(2), true, 2u, 0u, 3u); +} +#endif // defined(TCP_INFO) || defined(OS_LINUX) + } // namespace } // namespace net diff --git a/net/socket/tcp_socket_win.cc b/net/socket/tcp_socket_win.cc index 0d11a0d74438f0..f77dbbf85aa595 100644 --- a/net/socket/tcp_socket_win.cc +++ b/net/socket/tcp_socket_win.cc @@ -242,9 +242,12 @@ void TCPSocketWin::Core::WriteDelegate::OnObjectSignaled( //----------------------------------------------------------------------------- -TCPSocketWin::TCPSocketWin(net::NetLog* net_log, - const net::NetLog::Source& source) +TCPSocketWin::TCPSocketWin( + scoped_ptr socket_performance_watcher, + net::NetLog* net_log, + const net::NetLog::Source& source) : socket_(INVALID_SOCKET), + socket_performance_watcher_(std::move(socket_performance_watcher)), accept_event_(WSA_INVALID_EVENT), accept_socket_(NULL), accept_address_(NULL), @@ -699,8 +702,8 @@ int TCPSocketWin::AcceptInternal(scoped_ptr* socket, net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, net_error); return net_error; } - scoped_ptr tcp_socket(new TCPSocketWin( - net_log_.net_log(), net_log_.source())); + scoped_ptr tcp_socket( + new TCPSocketWin(NULL, net_log_.net_log(), net_log_.source())); int adopt_result = tcp_socket->AdoptConnectedSocket(new_socket, ip_end_point); if (adopt_result != OK) { net_log_.EndEventWithNetErrorCode(NetLog::TYPE_TCP_ACCEPT, adopt_result); diff --git a/net/socket/tcp_socket_win.h b/net/socket/tcp_socket_win.h index 1786af11ada0d8..2f3be4610d25ed 100644 --- a/net/socket/tcp_socket_win.h +++ b/net/socket/tcp_socket_win.h @@ -17,6 +17,7 @@ #include "net/base/address_family.h" #include "net/base/completion_callback.h" #include "net/base/net_export.h" +#include "net/base/socket_performance_watcher.h" #include "net/log/net_log.h" namespace net { @@ -28,7 +29,9 @@ class IPEndPoint; class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe), public base::win::ObjectWatcher::Delegate { public: - TCPSocketWin(NetLog* net_log, const NetLog::Source& source); + TCPSocketWin(scoped_ptr socket_performance_watcher, + NetLog* net_log, + const NetLog::Source& source); ~TCPSocketWin() override; int Open(AddressFamily family); @@ -128,6 +131,9 @@ class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe), SOCKET socket_; + // |socket_performance_watcher_| may be nullptr. + scoped_ptr socket_performance_watcher_; + HANDLE accept_event_; base::win::ObjectWatcher accept_watcher_; diff --git a/net/socket/transport_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc index dbc701a938681a..241a71219d3d21 100644 --- a/net/socket/transport_client_socket_pool.cc +++ b/net/socket/transport_client_socket_pool.cc @@ -20,6 +20,8 @@ #include "base/values.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" +#include "net/base/socket_performance_watcher.h" +#include "net/base/socket_performance_watcher_factory.h" #include "net/log/net_log.h" #include "net/socket/client_socket_factory.h" #include "net/socket/client_socket_handle.h" @@ -200,6 +202,7 @@ TransportConnectJob::TransportConnectJob( const scoped_refptr& params, base::TimeDelta timeout_duration, ClientSocketFactory* client_socket_factory, + SocketPerformanceWatcherFactory* socket_performance_watcher_factory, HostResolver* host_resolver, Delegate* delegate, NetLog* net_log) @@ -210,6 +213,7 @@ TransportConnectJob::TransportConnectJob( delegate, BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), helper_(params, client_socket_factory, host_resolver, &connect_timing_), + socket_performance_watcher_factory_(socket_performance_watcher_factory), interval_between_connects_(CONNECT_INTERVAL_GT_20MS), resolve_result_(OK) { helper_.SetOnIOComplete(this); @@ -296,9 +300,17 @@ int TransportConnectJob::DoTransportConnect() { helper_.set_next_state( TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE); + // Create a |SocketPerformanceWatcher|, and pass the ownership. + scoped_ptr socket_performance_watcher; + if (socket_performance_watcher_factory_) { + socket_performance_watcher = + socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( + SocketPerformanceWatcherFactory::PROTOCOL_TCP); + } transport_socket_ = helper_.client_socket_factory()->CreateTransportClientSocket( - helper_.addresses(), net_log().net_log(), net_log().source()); + helper_.addresses(), std::move(socket_performance_watcher), + net_log().net_log(), net_log().source()); // If the list contains IPv6 and IPv4 addresses, the first address will // be IPv6, and the IPv4 addresses will be tried as fallback addresses, @@ -413,11 +425,20 @@ void TransportConnectJob::DoIPv6FallbackTransportConnect() { DCHECK(!fallback_transport_socket_.get()); DCHECK(!fallback_addresses_.get()); + // Create a |SocketPerformanceWatcher|, and pass the ownership. + scoped_ptr socket_performance_watcher; + if (socket_performance_watcher_factory_) { + socket_performance_watcher = + socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( + SocketPerformanceWatcherFactory::PROTOCOL_TCP); + } + fallback_addresses_.reset(new AddressList(helper_.addresses())); MakeAddressListStartWithIPv4(fallback_addresses_.get()); fallback_transport_socket_ = helper_.client_socket_factory()->CreateTransportClientSocket( - *fallback_addresses_, net_log().net_log(), net_log().source()); + *fallback_addresses_, std::move(socket_performance_watcher), + net_log().net_log(), net_log().source()); fallback_connect_start_time_ = base::TimeTicks::Now(); int rv = fallback_transport_socket_->Connect( base::Bind( @@ -492,7 +513,7 @@ TransportClientSocketPool::TransportConnectJobFactory::NewConnectJob( return scoped_ptr(new TransportConnectJob( group_name, request.priority(), request.respect_limits(), request.params(), ConnectionTimeout(), client_socket_factory_, - host_resolver_, delegate, net_log_)); + socket_performance_watcher_factory_, host_resolver_, delegate, net_log_)); } base::TimeDelta @@ -506,6 +527,7 @@ TransportClientSocketPool::TransportClientSocketPool( int max_sockets_per_group, HostResolver* host_resolver, ClientSocketFactory* client_socket_factory, + SocketPerformanceWatcherFactory* socket_performance_watcher_factory, NetLog* net_log) : base_(NULL, max_sockets, @@ -514,6 +536,7 @@ TransportClientSocketPool::TransportClientSocketPool( ClientSocketPool::used_idle_socket_timeout(), new TransportConnectJobFactory(client_socket_factory, host_resolver, + socket_performance_watcher_factory, net_log)) { base_.EnableConnectBackupJobs(); } diff --git a/net/socket/transport_client_socket_pool.h b/net/socket/transport_client_socket_pool.h index 085fbb91e86f2b..73aae2c809f479 100644 --- a/net/socket/transport_client_socket_pool.h +++ b/net/socket/transport_client_socket_pool.h @@ -22,6 +22,7 @@ namespace net { class ClientSocketFactory; +class SocketPerformanceWatcherFactory; typedef base::Callback OnHostResolutionCallback; @@ -153,15 +154,17 @@ class NET_EXPORT_PRIVATE TransportConnectJobHelper { // a headstart) and return the one that completes first to the socket pool. class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob { public: - TransportConnectJob(const std::string& group_name, - RequestPriority priority, - ClientSocketPool::RespectLimits respect_limits, - const scoped_refptr& params, - base::TimeDelta timeout_duration, - ClientSocketFactory* client_socket_factory, - HostResolver* host_resolver, - Delegate* delegate, - NetLog* net_log); + TransportConnectJob( + const std::string& group_name, + RequestPriority priority, + ClientSocketPool::RespectLimits respect_limits, + const scoped_refptr& params, + base::TimeDelta timeout_duration, + ClientSocketFactory* client_socket_factory, + SocketPerformanceWatcherFactory* socket_performance_watcher_factory, + HostResolver* host_resolver, + Delegate* delegate, + NetLog* net_log); ~TransportConnectJob() override; // ConnectJob methods. @@ -205,6 +208,7 @@ class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob { scoped_ptr fallback_addresses_; base::TimeTicks fallback_connect_start_time_; base::OneShotTimer fallback_timer_; + SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; // Track the interval between this connect and previous connect. ConnectInterval interval_between_connects_; @@ -231,6 +235,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool { int max_sockets_per_group, HostResolver* host_resolver, ClientSocketFactory* client_socket_factory, + SocketPerformanceWatcherFactory* socket_performance_watcher_factory, NetLog* net_log); ~TransportClientSocketPool() override; @@ -281,10 +286,14 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool { class TransportConnectJobFactory : public PoolBase::ConnectJobFactory { public: - TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, - HostResolver* host_resolver, - NetLog* net_log) + TransportConnectJobFactory( + ClientSocketFactory* client_socket_factory, + HostResolver* host_resolver, + SocketPerformanceWatcherFactory* socket_performance_watcher_factory, + NetLog* net_log) : client_socket_factory_(client_socket_factory), + socket_performance_watcher_factory_( + socket_performance_watcher_factory), host_resolver_(host_resolver), net_log_(net_log) {} @@ -301,6 +310,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool { private: ClientSocketFactory* const client_socket_factory_; + SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; HostResolver* const host_resolver_; NetLog* net_log_; diff --git a/net/socket/transport_client_socket_pool_test_util.cc b/net/socket/transport_client_socket_pool_test_util.cc index 190b1c575795c4..2679cf14c1a71b 100644 --- a/net/socket/transport_client_socket_pool_test_util.cc +++ b/net/socket/transport_client_socket_pool_test_util.cc @@ -372,6 +372,7 @@ MockTransportClientSocketFactory::CreateDatagramClientSocket( scoped_ptr MockTransportClientSocketFactory::CreateTransportClientSocket( const AddressList& addresses, + scoped_ptr /* socket_performance_watcher */, NetLog* /* net_log */, const NetLog::Source& /* source */) { allocation_count_++; diff --git a/net/socket/transport_client_socket_pool_test_util.h b/net/socket/transport_client_socket_pool_test_util.h index 6e38af6661361b..efab9d359822eb 100644 --- a/net/socket/transport_client_socket_pool_test_util.h +++ b/net/socket/transport_client_socket_pool_test_util.h @@ -17,6 +17,7 @@ #include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "net/base/address_list.h" +#include "net/base/socket_performance_watcher.h" #include "net/log/net_log.h" #include "net/socket/client_socket_factory.h" #include "net/socket/client_socket_handle.h" @@ -80,6 +81,7 @@ class MockTransportClientSocketFactory : public ClientSocketFactory { scoped_ptr CreateTransportClientSocket( const AddressList& addresses, + scoped_ptr /* socket_performance_watcher */, NetLog* /* net_log */, const NetLog::Source& /* source */) override; diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc index c8702f70fb2420..c79844a104edfd 100644 --- a/net/socket/transport_client_socket_pool_unittest.cc +++ b/net/socket/transport_client_socket_pool_unittest.cc @@ -39,20 +39,19 @@ class TransportClientSocketPoolTest : public testing::Test { TransportClientSocketPoolTest() : connect_backup_jobs_enabled_( ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(true)), - params_( - new TransportSocketParams( - HostPortPair("www.google.com", 80), - false, - OnHostResolutionCallback(), - TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)), + params_(new TransportSocketParams( + HostPortPair("www.google.com", 80), + false, + OnHostResolutionCallback(), + TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)), host_resolver_(new MockHostResolver), client_socket_factory_(&net_log_), pool_(kMaxSockets, kMaxSocketsPerGroup, host_resolver_.get(), &client_socket_factory_, - NULL) { - } + NULL, + NULL) {} ~TransportClientSocketPoolTest() override { internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( @@ -855,11 +854,9 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterDelay) { TEST_F(TransportClientSocketPoolTest, IPv6FallbackSocketIPv4FinishesFirst) { // Create a pool without backup jobs. ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - TransportClientSocketPool pool(kMaxSockets, - kMaxSocketsPerGroup, - host_resolver_.get(), - &client_socket_factory_, - NULL); + TransportClientSocketPool pool(kMaxSockets, kMaxSocketsPerGroup, + host_resolver_.get(), &client_socket_factory_, + NULL, NULL); MockTransportClientSocketFactory::ClientSocketType case_types[] = { // This is the IPv6 socket. It stalls, but presents one failed connection @@ -906,11 +903,9 @@ TEST_F(TransportClientSocketPoolTest, IPv6FallbackSocketIPv4FinishesFirst) { TEST_F(TransportClientSocketPoolTest, IPv6FallbackSocketIPv6FinishesFirst) { // Create a pool without backup jobs. ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - TransportClientSocketPool pool(kMaxSockets, - kMaxSocketsPerGroup, - host_resolver_.get(), - &client_socket_factory_, - NULL); + TransportClientSocketPool pool(kMaxSockets, kMaxSocketsPerGroup, + host_resolver_.get(), &client_socket_factory_, + NULL, NULL); MockTransportClientSocketFactory::ClientSocketType case_types[] = { // This is the IPv6 socket. @@ -957,11 +952,9 @@ TEST_F(TransportClientSocketPoolTest, IPv6FallbackSocketIPv6FinishesFirst) { TEST_F(TransportClientSocketPoolTest, IPv6NoIPv4AddressesToFallbackTo) { // Create a pool without backup jobs. ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - TransportClientSocketPool pool(kMaxSockets, - kMaxSocketsPerGroup, - host_resolver_.get(), - &client_socket_factory_, - NULL); + TransportClientSocketPool pool(kMaxSockets, kMaxSocketsPerGroup, + host_resolver_.get(), &client_socket_factory_, + NULL, NULL); client_socket_factory_.set_default_client_socket_type( MockTransportClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET); @@ -992,11 +985,9 @@ TEST_F(TransportClientSocketPoolTest, IPv6NoIPv4AddressesToFallbackTo) { TEST_F(TransportClientSocketPoolTest, IPv4HasNoFallback) { // Create a pool without backup jobs. ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - TransportClientSocketPool pool(kMaxSockets, - kMaxSocketsPerGroup, - host_resolver_.get(), - &client_socket_factory_, - NULL); + TransportClientSocketPool pool(kMaxSockets, kMaxSocketsPerGroup, + host_resolver_.get(), &client_socket_factory_, + NULL, NULL); client_socket_factory_.set_default_client_socket_type( MockTransportClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET); @@ -1031,11 +1022,8 @@ TEST_F(TransportClientSocketPoolTest, TCPFastOpenOnIPv4WithNoFallback) { factory.AddSocketDataProvider(&socket_data); // Create a pool without backup jobs. ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - TransportClientSocketPool pool(kMaxSockets, - kMaxSocketsPerGroup, - host_resolver_.get(), - &factory, - NULL); + TransportClientSocketPool pool(kMaxSockets, kMaxSocketsPerGroup, + host_resolver_.get(), &factory, NULL, NULL); // Resolve an AddressList with only IPv4 addresses. host_resolver_->rules()->AddIPLiteralRule("*", "1.1.1.1", std::string()); @@ -1057,11 +1045,8 @@ TEST_F(TransportClientSocketPoolTest, TCPFastOpenOnIPv6WithNoFallback) { factory.AddSocketDataProvider(&socket_data); // Create a pool without backup jobs. ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - TransportClientSocketPool pool(kMaxSockets, - kMaxSocketsPerGroup, - host_resolver_.get(), - &factory, - NULL); + TransportClientSocketPool pool(kMaxSockets, kMaxSocketsPerGroup, + host_resolver_.get(), &factory, NULL, NULL); client_socket_factory_.set_default_client_socket_type( MockTransportClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET); // Resolve an AddressList with only IPv6 addresses. @@ -1091,11 +1076,8 @@ TEST_F(TransportClientSocketPoolTest, factory.AddSocketDataProvider(&socket_data_2); // Create a pool without backup jobs. ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - TransportClientSocketPool pool(kMaxSockets, - kMaxSocketsPerGroup, - host_resolver_.get(), - &factory, - NULL); + TransportClientSocketPool pool(kMaxSockets, kMaxSocketsPerGroup, + host_resolver_.get(), &factory, NULL, NULL); // Resolve an AddressList with a IPv6 address first and then a IPv4 address. host_resolver_->rules() @@ -1126,11 +1108,8 @@ TEST_F(TransportClientSocketPoolTest, factory.AddSocketDataProvider(&socket_data); // Create a pool without backup jobs. ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(false); - TransportClientSocketPool pool(kMaxSockets, - kMaxSocketsPerGroup, - host_resolver_.get(), - &factory, - NULL); + TransportClientSocketPool pool(kMaxSockets, kMaxSocketsPerGroup, + host_resolver_.get(), &factory, NULL, NULL); // Resolve an AddressList with a IPv6 address first and then a IPv4 address. host_resolver_->rules() diff --git a/net/socket/transport_client_socket_unittest.cc b/net/socket/transport_client_socket_unittest.cc index f9b095ca9255c2..c1e9c78ef0ad30 100644 --- a/net/socket/transport_client_socket_unittest.cc +++ b/net/socket/transport_client_socket_unittest.cc @@ -117,7 +117,7 @@ void TransportClientSocketTest::SetUp() { CHECK_EQ(ERR_IO_PENDING, rv); rv = callback.WaitForResult(); CHECK_EQ(rv, OK); - sock_ = socket_factory_->CreateTransportClientSocket(addr, &net_log_, + sock_ = socket_factory_->CreateTransportClientSocket(addr, NULL, &net_log_, NetLog::Source()); } diff --git a/net/socket/websocket_transport_client_socket_pool.cc b/net/socket/websocket_transport_client_socket_pool.cc index e4f0883acce7c4..6ca72b39a9da2e 100644 --- a/net/socket/websocket_transport_client_socket_pool.cc +++ b/net/socket/websocket_transport_client_socket_pool.cc @@ -241,6 +241,7 @@ WebSocketTransportClientSocketPool::WebSocketTransportClientSocketPool( max_sockets_per_group, host_resolver, client_socket_factory, + NULL, net_log), connect_job_delegate_(this), pool_net_log_(net_log), diff --git a/net/socket/websocket_transport_connect_sub_job.cc b/net/socket/websocket_transport_connect_sub_job.cc index 25c0744cfac75a..636e3daa07086c 100644 --- a/net/socket/websocket_transport_connect_sub_job.cc +++ b/net/socket/websocket_transport_connect_sub_job.cc @@ -137,7 +137,7 @@ int WebSocketTransportConnectSubJob::DoTransportConnect() { next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; AddressList one_address(CurrentAddress()); transport_socket_ = client_socket_factory()->CreateTransportClientSocket( - one_address, net_log().net_log(), net_log().source()); + one_address, nullptr, 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::Bind( diff --git a/net/test/embedded_test_server/embedded_test_server_unittest.cc b/net/test/embedded_test_server/embedded_test_server_unittest.cc index bdd4a826d04bfc..0e3f56a6da091e 100644 --- a/net/test/embedded_test_server/embedded_test_server_unittest.cc +++ b/net/test/embedded_test_server/embedded_test_server_unittest.cc @@ -298,7 +298,7 @@ TEST_P(EmbeddedTestServerTest, ConnectionListenerAccept) { scoped_ptr socket = ClientSocketFactory::GetDefaultFactory()->CreateTransportClientSocket( - address_list, &net_log, NetLog::Source()); + address_list, NULL, &net_log, NetLog::Source()); TestCompletionCallback callback; ASSERT_EQ(OK, callback.GetResult(socket->Connect(callback.callback())));