diff options
author | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 15:22:28 +0000 |
---|---|---|
committer | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 15:22:28 +0000 |
commit | ab73904ffa1b236905a4f1253dd03e02dd9e8695 (patch) | |
tree | 280c13fdd850ed27e964df6f25cc7b6f16072a3b | |
parent | 53900d0715c882d9b8ae8281a17272143fd77143 (diff) | |
download | chromium_src-ab73904ffa1b236905a4f1253dd03e02dd9e8695.zip chromium_src-ab73904ffa1b236905a4f1253dd03e02dd9e8695.tar.gz chromium_src-ab73904ffa1b236905a4f1253dd03e02dd9e8695.tar.bz2 |
Rename a number of classes previously labeled "TCP" to "Transport" in
preparation for non-TCP transports. This helps because the alternative
is to either use non-TCP protocols (like SCTP) in classes which are called
"TCPClientSocketPool", or to clone the code as "SCTPClientSocketPool", both
of which are less than ideal.
For now, we're just testing transports, so the TransportSocketPool classes
will determine a single type of transport and just use them. In the future
we'll likely need to figure out how to deal with runtime selection of
transports, and probably support use of multiple transports either within
the same pools or within subpools. But that is for the future.
Note that the histograms have some "tcp" references to them. I didn't change
these to "transport" yet, because it will effect existing histograms.
Renames include:
classes:
TCPClientSocketPool -> TransportClientSocketPool
MockTCPClientSocketPool -> MockTransportClientSocketPool
TCPSocketParams -> TransportSocketParams
methods (not the exhaustive list):
CreateTCPClientSocket() -> CreateTransportClientSocket()
DoTCPConnect() -> DoTransportConnect()
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6804028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80781 0039d316-1c4b-4281-b951-d872f2087c98
42 files changed, 669 insertions, 574 deletions
diff --git a/jingle/notifier/base/chrome_async_socket.cc b/jingle/notifier/base/chrome_async_socket.cc index f3a5a77..61adadd 100644 --- a/jingle/notifier/base/chrome_async_socket.cc +++ b/jingle/notifier/base/chrome_async_socket.cc @@ -147,9 +147,8 @@ bool ChromeAsyncSocket::Connect(const talk_base::SocketAddress& address) { net::AddressList address_list = SocketAddressToAddressList(address); transport_socket_.reset( - client_socket_factory_->CreateTCPClientSocket(address_list, - bound_net_log_.net_log(), - net::NetLog::Source())); + client_socket_factory_->CreateTransportClientSocket( + address_list, bound_net_log_.net_log(), net::NetLog::Source())); int status = transport_socket_->Connect(&connect_callback_); if (status != net::ERR_IO_PENDING) { // We defer execution of ProcessConnectDone instead of calling it diff --git a/jingle/notifier/base/fake_ssl_client_socket_unittest.cc b/jingle/notifier/base/fake_ssl_client_socket_unittest.cc index 032f69f..72e9db6 100644 --- a/jingle/notifier/base/fake_ssl_client_socket_unittest.cc +++ b/jingle/notifier/base/fake_ssl_client_socket_unittest.cc @@ -87,7 +87,7 @@ class FakeSSLClientSocketTest : public testing::Test { virtual ~FakeSSLClientSocketTest() {} net::ClientSocket* MakeClientSocket() { - return mock_client_socket_factory_.CreateTCPClientSocket( + return mock_client_socket_factory_.CreateTransportClientSocket( net::AddressList(), &capturing_net_log_, net::NetLog::Source()); } diff --git a/jingle/notifier/base/xmpp_client_socket_factory.cc b/jingle/notifier/base/xmpp_client_socket_factory.cc index 8515f80..a4c4835 100644 --- a/jingle/notifier/base/xmpp_client_socket_factory.cc +++ b/jingle/notifier/base/xmpp_client_socket_factory.cc @@ -19,12 +19,12 @@ XmppClientSocketFactory::XmppClientSocketFactory( XmppClientSocketFactory::~XmppClientSocketFactory() {} -net::ClientSocket* XmppClientSocketFactory::CreateTCPClientSocket( +net::ClientSocket* XmppClientSocketFactory::CreateTransportClientSocket( const net::AddressList& addresses, net::NetLog* net_log, const net::NetLog::Source& source) { net::ClientSocket* transport_socket = - client_socket_factory_->CreateTCPClientSocket( + client_socket_factory_->CreateTransportClientSocket( addresses, net_log, source); return (use_fake_ssl_client_socket_ ? new FakeSSLClientSocket(transport_socket) : transport_socket); diff --git a/jingle/notifier/base/xmpp_client_socket_factory.h b/jingle/notifier/base/xmpp_client_socket_factory.h index 48c683d..291cadf 100644 --- a/jingle/notifier/base/xmpp_client_socket_factory.h +++ b/jingle/notifier/base/xmpp_client_socket_factory.h @@ -27,7 +27,7 @@ class XmppClientSocketFactory : public net::ClientSocketFactory { virtual ~XmppClientSocketFactory(); // net::ClientSocketFactory implementation. - virtual net::ClientSocket* CreateTCPClientSocket( + virtual net::ClientSocket* CreateTransportClientSocket( const net::AddressList& addresses, net::NetLog* net_log, const net::NetLog::Source& source); virtual net::SSLClientSocket* CreateSSLClientSocket( diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index 3f35c83..885fd8f 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -615,7 +615,7 @@ int FtpNetworkTransaction::DoCtrlResolveHostComplete(int result) { int FtpNetworkTransaction::DoCtrlConnect() { next_state_ = STATE_CTRL_CONNECT_COMPLETE; - ctrl_socket_.reset(socket_factory_->CreateTCPClientSocket( + ctrl_socket_.reset(socket_factory_->CreateTransportClientSocket( addresses_, net_log_.net_log(), net_log_.source())); return ctrl_socket_->Connect(&io_callback_); } @@ -1160,7 +1160,7 @@ int FtpNetworkTransaction::DoDataConnect() { if (rv != OK) return Stop(rv); data_address.SetPort(data_connection_port_); - data_socket_.reset(socket_factory_->CreateTCPClientSocket( + data_socket_.reset(socket_factory_->CreateTransportClientSocket( data_address, net_log_.net_log(), net_log_.source())); return data_socket_->Connect(&io_callback_); } diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index f25227b4..14b85ae 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -87,8 +87,8 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession>, return &alternate_protocols_; } - TCPClientSocketPool* tcp_socket_pool() { - return socket_pool_manager_.tcp_socket_pool(); + TransportClientSocketPool* transport_socket_pool() { + return socket_pool_manager_.transport_socket_pool(); } SSLClientSocketPool* ssl_socket_pool() { diff --git a/net/http/http_network_session_peer.cc b/net/http/http_network_session_peer.cc index 2ed3e76..921322a 100644 --- a/net/http/http_network_session_peer.cc +++ b/net/http/http_network_session_peer.cc @@ -9,7 +9,7 @@ #include "net/proxy/proxy_service.h" #include "net/socket/socks_client_socket_pool.h" #include "net/socket/ssl_client_socket_pool.h" -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" namespace net { @@ -19,8 +19,9 @@ HttpNetworkSessionPeer::HttpNetworkSessionPeer( HttpNetworkSessionPeer::~HttpNetworkSessionPeer() {} -void HttpNetworkSessionPeer::SetTCPSocketPool(TCPClientSocketPool* pool) { - session_->socket_pool_manager_.tcp_socket_pool_.reset(pool); +void HttpNetworkSessionPeer::SetTransportSocketPool( + TransportClientSocketPool* pool) { + session_->socket_pool_manager_.transport_socket_pool_.reset(pool); } void HttpNetworkSessionPeer::SetSocketPoolForSOCKSProxy( diff --git a/net/http/http_network_session_peer.h b/net/http/http_network_session_peer.h index e380302..51b1f81 100644 --- a/net/http/http_network_session_peer.h +++ b/net/http/http_network_session_peer.h @@ -17,7 +17,7 @@ class HttpStreamFactory; class ProxyService; class SOCKSClientSocketPool; class SSLClientSocketPool; -class TCPClientSocketPool; +class TransportClientSocketPool; class HttpNetworkSessionPeer { public: @@ -25,7 +25,7 @@ class HttpNetworkSessionPeer { const scoped_refptr<HttpNetworkSession>& session); ~HttpNetworkSessionPeer(); - void SetTCPSocketPool(TCPClientSocketPool* pool); + void SetTransportSocketPool(TransportClientSocketPool* pool); void SetSocketPoolForSOCKSProxy( const HostPortPair& socks_proxy, diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 9271b33..0bfad34 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -50,7 +50,7 @@ #include "net/socket/socks_client_socket_pool.h" #include "net/socket/ssl_client_socket.h" #include "net/socket/ssl_client_socket_pool.h" -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" #include "net/spdy/spdy_http_stream.h" #include "net/spdy/spdy_session.h" #include "net/spdy/spdy_session_pool.h" diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 90cb0c4..f21a1a2 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -295,8 +295,8 @@ class CaptureGroupNameSocketPool : public ParentPool { std::string last_group_name_; }; -typedef CaptureGroupNameSocketPool<TCPClientSocketPool> -CaptureGroupNameTCPSocketPool; +typedef CaptureGroupNameSocketPool<TransportClientSocketPool> +CaptureGroupNameTransportSocketPool; typedef CaptureGroupNameSocketPool<HttpProxyClientSocketPool> CaptureGroupNameHttpProxySocketPool; typedef CaptureGroupNameSocketPool<SOCKSClientSocketPool> @@ -3120,7 +3120,7 @@ TEST_F(HttpNetworkTransactionTest, LargeHeadersNoBody) { // Make sure that we don't try to reuse a TCPClientSocket when failing to // establish tunnel. // http://code.google.com/p/chromium/issues/detail?id=3772 -TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) { +TEST_F(HttpNetworkTransactionTest, DontRecycleTransportSocketForSSLTunnel) { HttpRequestInfo request; request.method = "GET"; request.url = GURL("https://www.google.com/"); @@ -3170,11 +3170,11 @@ TEST_F(HttpNetworkTransactionTest, DontRecycleTCPSocketForSSLTunnel) { // We now check to make sure the TCPClientSocket was not added back to // the pool. - EXPECT_EQ(0, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); trans.reset(); MessageLoop::current()->RunAllPending(); // Make sure that the socket didn't get recycled after calling the destructor. - EXPECT_EQ(0, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); } // Make sure that we recycle a socket after reading all of the response body. @@ -3217,7 +3217,7 @@ TEST_F(HttpNetworkTransactionTest, RecycleSocket) { std::string status_line = response->headers->GetStatusLine(); EXPECT_EQ("HTTP/1.1 200 OK", status_line); - EXPECT_EQ(0, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); std::string response_data; rv = ReadTransaction(trans.get(), &response_data); @@ -3229,7 +3229,7 @@ TEST_F(HttpNetworkTransactionTest, RecycleSocket) { MessageLoop::current()->RunAllPending(); // We now check to make sure the socket was added back to the pool. - EXPECT_EQ(1, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(1, session->transport_socket_pool()->IdleSocketCount()); } // Make sure that we recycle a SSL socket after reading all of the response @@ -3276,7 +3276,7 @@ TEST_F(HttpNetworkTransactionTest, RecycleSSLSocket) { ASSERT_TRUE(response->headers != NULL); EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); - EXPECT_EQ(0, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); std::string response_data; rv = ReadTransaction(trans.get(), &response_data); @@ -3344,7 +3344,7 @@ TEST_F(HttpNetworkTransactionTest, RecycleDeadSSLSocket) { ASSERT_TRUE(response->headers != NULL); EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); - EXPECT_EQ(0, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); std::string response_data; rv = ReadTransaction(trans.get(), &response_data); @@ -3372,7 +3372,7 @@ TEST_F(HttpNetworkTransactionTest, RecycleDeadSSLSocket) { ASSERT_TRUE(response->headers != NULL); EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); - EXPECT_EQ(0, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); rv = ReadTransaction(trans.get(), &response_data); EXPECT_EQ(OK, rv); @@ -3428,7 +3428,7 @@ TEST_F(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) { std::string status_line = response->headers->GetStatusLine(); EXPECT_EQ("HTTP/1.1 204 No Content", status_line); - EXPECT_EQ(0, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(0, session->transport_socket_pool()->IdleSocketCount()); std::string response_data; rv = ReadTransaction(trans.get(), &response_data); @@ -3440,7 +3440,7 @@ TEST_F(HttpNetworkTransactionTest, RecycleSocketAfterZeroContentLength) { MessageLoop::current()->RunAllPending(); // We now check to make sure the socket was added back to the pool. - EXPECT_EQ(1, session->tcp_socket_pool()->IdleSocketCount()); + EXPECT_EQ(1, session->transport_socket_pool()->IdleSocketCount()); } TEST_F(HttpNetworkTransactionTest, ResendRequestOnWriteBodyError) { @@ -5512,9 +5512,9 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForDirectConnections) { SetupSessionForGroupNameTests(&session_deps)); HttpNetworkSessionPeer peer(session); - CaptureGroupNameTCPSocketPool* tcp_conn_pool = - new CaptureGroupNameTCPSocketPool(NULL, NULL); - peer.SetTCPSocketPool(tcp_conn_pool); + CaptureGroupNameTransportSocketPool* transport_conn_pool = + new CaptureGroupNameTransportSocketPool(NULL, NULL); + peer.SetTransportSocketPool(transport_conn_pool); CaptureGroupNameSSLSocketPool* ssl_conn_pool = new CaptureGroupNameSSLSocketPool(NULL, NULL); peer.SetSSLSocketPool(ssl_conn_pool); @@ -5526,7 +5526,7 @@ TEST_F(HttpNetworkTransactionTest, GroupNameForDirectConnections) { ssl_conn_pool->last_group_name_received()); else EXPECT_EQ(tests[i].expected_group_name, - tcp_conn_pool->last_group_name_received()); + transport_conn_pool->last_group_name_received()); } HttpStreamFactory::set_use_alternate_protocols(false); @@ -7046,13 +7046,16 @@ TEST_F(HttpNetworkTransactionTest, HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); scoped_refptr<SpdySession> spdy_session = session->spdy_session_pool()->Get(pair, BoundNetLog()); - scoped_refptr<TCPSocketParams> tcp_params( - new TCPSocketParams(host_port_pair, MEDIUM, GURL(), false, false)); + scoped_refptr<TransportSocketParams> transport_params( + new TransportSocketParams(host_port_pair, MEDIUM, GURL(), false, false)); scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(ERR_IO_PENDING, - connection->Init(host_port_pair.ToString(),tcp_params, LOWEST, - &callback, session->tcp_socket_pool(), + connection->Init(host_port_pair.ToString(), + transport_params, + LOWEST, + &callback, + session->transport_socket_pool(), BoundNetLog())); EXPECT_EQ(OK, callback.WaitForResult()); @@ -7533,15 +7536,15 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { // to validate that the TCP socket is not released to the pool between // each round of multi-round authentication. HttpNetworkSessionPeer session_peer(session); - ClientSocketPoolHistograms tcp_pool_histograms("SmallTCP"); - TCPClientSocketPool* tcp_pool = new TCPClientSocketPool( + ClientSocketPoolHistograms transport_pool_histograms("SmallTCP"); + TransportClientSocketPool* transport_pool = new TransportClientSocketPool( 50, // Max sockets for pool 1, // Max sockets per group - &tcp_pool_histograms, + &transport_pool_histograms, session_deps.host_resolver.get(), &session_deps.socket_factory, session_deps.net_log); - session_peer.SetTCPSocketPool(tcp_pool); + session_peer.SetTransportSocketPool(transport_pool); scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); TestCompletionCallback callback; @@ -7607,7 +7610,7 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { response = trans->GetResponseInfo(); ASSERT_FALSE(response == NULL); EXPECT_FALSE(response->auth_challenge.get() == NULL); - EXPECT_EQ(0, tcp_pool->IdleSocketCountInGroup(kSocketGroup)); + EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); // In between rounds, another request comes in for the same domain. // It should not be able to grab the TCP socket that trans has already @@ -7630,7 +7633,7 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { response = trans->GetResponseInfo(); ASSERT_FALSE(response == NULL); EXPECT_TRUE(response->auth_challenge.get() == NULL); - EXPECT_EQ(0, tcp_pool->IdleSocketCountInGroup(kSocketGroup)); + EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); // Third round of authentication. auth_handler->SetGenerateExpectation(false, OK); @@ -7641,7 +7644,7 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { response = trans->GetResponseInfo(); ASSERT_FALSE(response == NULL); EXPECT_TRUE(response->auth_challenge.get() == NULL); - EXPECT_EQ(0, tcp_pool->IdleSocketCountInGroup(kSocketGroup)); + EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); // Fourth round of authentication, which completes successfully. auth_handler->SetGenerateExpectation(false, OK); @@ -7652,7 +7655,7 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { response = trans->GetResponseInfo(); ASSERT_FALSE(response == NULL); EXPECT_TRUE(response->auth_challenge.get() == NULL); - EXPECT_EQ(0, tcp_pool->IdleSocketCountInGroup(kSocketGroup)); + EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); // Read the body since the fourth round was successful. This will also // release the socket back to the pool. @@ -7665,7 +7668,7 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { EXPECT_EQ(0, rv); // There are still 0 idle sockets, since the trans_compete transaction // will be handed it immediately after trans releases it to the group. - EXPECT_EQ(0, tcp_pool->IdleSocketCountInGroup(kSocketGroup)); + EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); // The competing request can now finish. Wait for the headers and then // read the body. @@ -7679,7 +7682,7 @@ TEST_F(HttpNetworkTransactionTest, MultiRoundAuth) { EXPECT_EQ(0, rv); // Finally, the socket is released to the group. - EXPECT_EQ(1, tcp_pool->IdleSocketCountInGroup(kSocketGroup)); + EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); } class TLSDecompressionFailureSocketDataProvider : public SocketDataProvider { @@ -8295,15 +8298,15 @@ TEST_F(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); scoped_refptr<SpdySession> spdy_session = session->spdy_session_pool()->Get(pair, BoundNetLog()); - scoped_refptr<TCPSocketParams> tcp_params( - new TCPSocketParams(host_port_pair, MEDIUM, GURL(), false, false)); + scoped_refptr<TransportSocketParams> transport_params( + new TransportSocketParams(host_port_pair, MEDIUM, GURL(), false, false)); TestCompletionCallback callback; scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(ERR_IO_PENDING, - connection->Init(host_port_pair.ToString(), tcp_params, LOWEST, - &callback, session->tcp_socket_pool(), - BoundNetLog())); + connection->Init(host_port_pair.ToString(), transport_params, + LOWEST, &callback, + session->transport_socket_pool(), BoundNetLog())); EXPECT_EQ(OK, callback.WaitForResult()); spdy_session->InitializeWithSocket(connection.release(), false, OK); diff --git a/net/http/http_proxy_client_socket_pool.cc b/net/http/http_proxy_client_socket_pool.cc index 39e899c..e991f55 100644 --- a/net/http/http_proxy_client_socket_pool.cc +++ b/net/http/http_proxy_client_socket_pool.cc @@ -18,7 +18,7 @@ #include "net/socket/client_socket_pool_base.h" #include "net/socket/ssl_client_socket.h" #include "net/socket/ssl_client_socket_pool.h" -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" #include "net/spdy/spdy_proxy_client_socket.h" #include "net/spdy/spdy_session.h" #include "net/spdy/spdy_session_pool.h" @@ -28,7 +28,7 @@ namespace net { HttpProxySocketParams::HttpProxySocketParams( - const scoped_refptr<TCPSocketParams>& tcp_params, + const scoped_refptr<TransportSocketParams>& transport_params, const scoped_refptr<SSLSocketParams>& ssl_params, const GURL& request_url, const std::string& user_agent, @@ -37,7 +37,7 @@ HttpProxySocketParams::HttpProxySocketParams( HttpAuthHandlerFactory* http_auth_handler_factory, SpdySessionPool* spdy_session_pool, bool tunnel) - : tcp_params_(tcp_params), + : transport_params_(transport_params), ssl_params_(ssl_params), spdy_session_pool_(spdy_session_pool), request_url_(request_url), @@ -46,19 +46,19 @@ HttpProxySocketParams::HttpProxySocketParams( http_auth_cache_(tunnel ? http_auth_cache : NULL), http_auth_handler_factory_(tunnel ? http_auth_handler_factory : NULL), tunnel_(tunnel) { - DCHECK((tcp_params == NULL && ssl_params != NULL) || - (tcp_params != NULL && ssl_params == NULL)); - if (tcp_params_) - ignore_limits_ = tcp_params->ignore_limits(); + DCHECK((transport_params == NULL && ssl_params != NULL) || + (transport_params != NULL && ssl_params == NULL)); + if (transport_params_) + ignore_limits_ = transport_params->ignore_limits(); else ignore_limits_ = ssl_params->ignore_limits(); } const HostResolver::RequestInfo& HttpProxySocketParams::destination() const { - if (tcp_params_ == NULL) - return ssl_params_->tcp_params()->destination(); + if (transport_params_ == NULL) + return ssl_params_->transport_params()->destination(); else - return tcp_params_->destination(); + return transport_params_->destination(); } HttpProxySocketParams::~HttpProxySocketParams() {} @@ -71,7 +71,7 @@ HttpProxyConnectJob::HttpProxyConnectJob( const std::string& group_name, const scoped_refptr<HttpProxySocketParams>& params, const base::TimeDelta& timeout_duration, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SSLClientSocketPool* ssl_pool, HostResolver* host_resolver, Delegate* delegate, @@ -79,7 +79,7 @@ HttpProxyConnectJob::HttpProxyConnectJob( : ConnectJob(group_name, timeout_duration, delegate, BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), params_(params), - tcp_pool_(tcp_pool), + transport_pool_(transport_pool), ssl_pool_(ssl_pool), resolver_(host_resolver), ALLOW_THIS_IN_INITIALIZER_LIST( @@ -130,10 +130,10 @@ int HttpProxyConnectJob::DoLoop(int result) { switch (state) { case STATE_TCP_CONNECT: DCHECK_EQ(OK, rv); - rv = DoTCPConnect(); + rv = DoTransportConnect(); break; case STATE_TCP_CONNECT_COMPLETE: - rv = DoTCPConnectComplete(rv); + rv = DoTransportConnectComplete(rv); break; case STATE_SSL_CONNECT: DCHECK_EQ(OK, rv); @@ -166,16 +166,19 @@ int HttpProxyConnectJob::DoLoop(int result) { return rv; } -int HttpProxyConnectJob::DoTCPConnect() { +int HttpProxyConnectJob::DoTransportConnect() { next_state_ = STATE_TCP_CONNECT_COMPLETE; transport_socket_handle_.reset(new ClientSocketHandle()); return transport_socket_handle_->Init( - group_name(), params_->tcp_params(), - params_->tcp_params()->destination().priority(), &callback_, tcp_pool_, + group_name(), + params_->transport_params(), + params_->transport_params()->destination().priority(), + &callback_, + transport_pool_, net_log()); } -int HttpProxyConnectJob::DoTCPConnectComplete(int result) { +int HttpProxyConnectJob::DoTransportConnectComplete(int result) { if (result != OK) return ERR_PROXY_CONNECTION_FAILED; @@ -203,7 +206,7 @@ int HttpProxyConnectJob::DoSSLConnect() { transport_socket_handle_.reset(new ClientSocketHandle()); return transport_socket_handle_->Init( group_name(), params_->ssl_params(), - params_->ssl_params()->tcp_params()->destination().priority(), + params_->ssl_params()->transport_params()->destination().priority(), &callback_, ssl_pool_, net_log()); } @@ -327,7 +330,7 @@ int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { } int HttpProxyConnectJob::ConnectInternal() { - if (params_->tcp_params()) + if (params_->transport_params()) next_state_ = STATE_TCP_CONNECT; else next_state_ = STATE_SSL_CONNECT; @@ -336,17 +339,17 @@ int HttpProxyConnectJob::ConnectInternal() { HttpProxyClientSocketPool:: HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SSLClientSocketPool* ssl_pool, HostResolver* host_resolver, NetLog* net_log) - : tcp_pool_(tcp_pool), + : transport_pool_(transport_pool), ssl_pool_(ssl_pool), host_resolver_(host_resolver), net_log_(net_log) { base::TimeDelta max_pool_timeout = base::TimeDelta(); - if (tcp_pool_) - max_pool_timeout = tcp_pool_->ConnectionTimeout(); + if (transport_pool_) + max_pool_timeout = transport_pool_->ConnectionTimeout(); if (ssl_pool_) max_pool_timeout = std::max(max_pool_timeout, ssl_pool_->ConnectionTimeout()); @@ -360,9 +363,14 @@ HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( const std::string& group_name, const PoolBase::Request& request, ConnectJob::Delegate* delegate) const { - return new HttpProxyConnectJob(group_name, request.params(), - ConnectionTimeout(), tcp_pool_, ssl_pool_, - host_resolver_, delegate, net_log_); + return new HttpProxyConnectJob(group_name, + request.params(), + ConnectionTimeout(), + transport_pool_, + ssl_pool_, + host_resolver_, + delegate, + net_log_); } HttpProxyClientSocketPool::HttpProxyClientSocketPool( @@ -370,16 +378,18 @@ HttpProxyClientSocketPool::HttpProxyClientSocketPool( int max_sockets_per_group, ClientSocketPoolHistograms* histograms, HostResolver* host_resolver, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SSLClientSocketPool* ssl_pool, NetLog* net_log) - : tcp_pool_(tcp_pool), + : transport_pool_(transport_pool), ssl_pool_(ssl_pool), base_(max_sockets, max_sockets_per_group, histograms, base::TimeDelta::FromSeconds( ClientSocketPool::unused_idle_socket_timeout()), base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout), - new HttpProxyConnectJobFactory(tcp_pool, ssl_pool, host_resolver, + new HttpProxyConnectJobFactory(transport_pool, + ssl_pool, + host_resolver, net_log)) {} HttpProxyClientSocketPool::~HttpProxyClientSocketPool() {} @@ -448,10 +458,10 @@ DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( DictionaryValue* dict = base_.GetInfoAsValue(name, type); if (include_nested_pools) { ListValue* list = new ListValue(); - if (tcp_pool_) { - list->Append(tcp_pool_->GetInfoAsValue("tcp_socket_pool", - "tcp_socket_pool", - true)); + if (transport_pool_) { + list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", + "transport_socket_pool", + true)); } if (ssl_pool_) { list->Append(ssl_pool_->GetInfoAsValue("ssl_socket_pool", diff --git a/net/http/http_proxy_client_socket_pool.h b/net/http/http_proxy_client_socket_pool.h index 3efbf3c..14bd9bea 100644 --- a/net/http/http_proxy_client_socket_pool.h +++ b/net/http/http_proxy_client_socket_pool.h @@ -29,27 +29,28 @@ class SSLClientSocketPool; class SSLSocketParams; class SpdySessionPool; class SpdyStream; -class TCPClientSocketPool; -class TCPSocketParams; +class TransportClientSocketPool; +class TransportSocketParams; // HttpProxySocketParams only needs the socket params for one of the proxy // types. The other param must be NULL. When using an HTTP Proxy, -// |tcp_params| must be set. When using an HTTPS Proxy, |ssl_params| +// |transport_params| must be set. When using an HTTPS Proxy, |ssl_params| // must be set. class HttpProxySocketParams : public base::RefCounted<HttpProxySocketParams> { public: - HttpProxySocketParams(const scoped_refptr<TCPSocketParams>& tcp_params, - const scoped_refptr<SSLSocketParams>& ssl_params, - const GURL& request_url, - const std::string& user_agent, - HostPortPair endpoint, - HttpAuthCache* http_auth_cache, - HttpAuthHandlerFactory* http_auth_handler_factory, - SpdySessionPool* spdy_session_pool, - bool tunnel); - - const scoped_refptr<TCPSocketParams>& tcp_params() const { - return tcp_params_; + HttpProxySocketParams( + const scoped_refptr<TransportSocketParams>& transport_params, + const scoped_refptr<SSLSocketParams>& ssl_params, + const GURL& request_url, + const std::string& user_agent, + HostPortPair endpoint, + HttpAuthCache* http_auth_cache, + HttpAuthHandlerFactory* http_auth_handler_factory, + SpdySessionPool* spdy_session_pool, + bool tunnel); + + const scoped_refptr<TransportSocketParams>& transport_params() const { + return transport_params_; } const scoped_refptr<SSLSocketParams>& ssl_params() const { return ssl_params_; @@ -72,7 +73,7 @@ class HttpProxySocketParams : public base::RefCounted<HttpProxySocketParams> { friend class base::RefCounted<HttpProxySocketParams>; ~HttpProxySocketParams(); - const scoped_refptr<TCPSocketParams> tcp_params_; + const scoped_refptr<TransportSocketParams> transport_params_; const scoped_refptr<SSLSocketParams> ssl_params_; SpdySessionPool* spdy_session_pool_; const GURL request_url_; @@ -93,7 +94,7 @@ class HttpProxyConnectJob : public ConnectJob { HttpProxyConnectJob(const std::string& group_name, const scoped_refptr<HttpProxySocketParams>& params, const base::TimeDelta& timeout_duration, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SSLClientSocketPool* ssl_pool, HostResolver* host_resolver, Delegate* delegate, @@ -125,8 +126,8 @@ class HttpProxyConnectJob : public ConnectJob { int DoLoop(int result); // Connecting to HTTP Proxy - int DoTCPConnect(); - int DoTCPConnectComplete(int result); + int DoTransportConnect(); + int DoTransportConnectComplete(int result); // Connecting to HTTPS Proxy int DoSSLConnect(); int DoSSLConnectComplete(int result); @@ -147,7 +148,7 @@ class HttpProxyConnectJob : public ConnectJob { virtual int ConnectInternal(); scoped_refptr<HttpProxySocketParams> params_; - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; SSLClientSocketPool* const ssl_pool_; HostResolver* const resolver_; @@ -171,7 +172,7 @@ class HttpProxyClientSocketPool : public ClientSocketPool { int max_sockets_per_group, ClientSocketPoolHistograms* histograms, HostResolver* host_resolver, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SSLClientSocketPool* ssl_pool, NetLog* net_log); @@ -222,7 +223,7 @@ class HttpProxyClientSocketPool : public ClientSocketPool { class HttpProxyConnectJobFactory : public PoolBase::ConnectJobFactory { public: HttpProxyConnectJobFactory( - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SSLClientSocketPool* ssl_pool, HostResolver* host_resolver, NetLog* net_log); @@ -235,7 +236,7 @@ class HttpProxyClientSocketPool : public ClientSocketPool { virtual base::TimeDelta ConnectionTimeout() const { return timeout_; } private: - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; SSLClientSocketPool* const ssl_pool_; HostResolver* const host_resolver_; NetLog* net_log_; @@ -244,7 +245,7 @@ class HttpProxyClientSocketPool : public ClientSocketPool { DISALLOW_COPY_AND_ASSIGN(HttpProxyConnectJobFactory); }; - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; SSLClientSocketPool* const ssl_pool_; PoolBase base_; diff --git a/net/http/http_proxy_client_socket_pool_unittest.cc b/net/http/http_proxy_client_socket_pool_unittest.cc index 63bb94a..fb6bef0 100644 --- a/net/http/http_proxy_client_socket_pool_unittest.cc +++ b/net/http/http_proxy_client_socket_pool_unittest.cc @@ -48,13 +48,14 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam { protected: HttpProxyClientSocketPoolTest() : ssl_config_(), - ignored_tcp_socket_params_(new TCPSocketParams( + ignored_transport_socket_params_(new TransportSocketParams( HostPortPair("proxy", 80), LOWEST, GURL(), false, false)), ignored_ssl_socket_params_(new SSLSocketParams( - ignored_tcp_socket_params_, NULL, NULL, ProxyServer::SCHEME_DIRECT, - HostPortPair("www.google.com", 443), ssl_config_, 0, false, false)), + ignored_transport_socket_params_, NULL, NULL, + ProxyServer::SCHEME_DIRECT, HostPortPair("www.google.com", 443), + ssl_config_, 0, false, false)), tcp_histograms_("MockTCP"), - tcp_socket_pool_( + transport_socket_pool_( kMaxSockets, kMaxSocketsPerGroup, &tcp_histograms_, &socket_factory_), @@ -69,7 +70,7 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam { NULL /* dns_cert_checker */, NULL /* ssl_host_info_factory */, &socket_factory_, - &tcp_socket_pool_, + &transport_socket_pool_, NULL, NULL, ssl_config_service_.get(), @@ -83,7 +84,7 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam { pool_(kMaxSockets, kMaxSocketsPerGroup, &http_proxy_histograms_, NULL, - &tcp_socket_pool_, + &transport_socket_pool_, &ssl_socket_pool_, NULL) { } @@ -103,10 +104,10 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam { "/"); } - scoped_refptr<TCPSocketParams> GetTcpParams() { + scoped_refptr<TransportSocketParams> GetTcpParams() { if (GetParam() != HTTP) - return scoped_refptr<TCPSocketParams>(); - return ignored_tcp_socket_params_; + return scoped_refptr<TransportSocketParams>(); + return ignored_transport_socket_params_; } scoped_refptr<SSLSocketParams> GetSslParams() { @@ -189,11 +190,11 @@ class HttpProxyClientSocketPoolTest : public TestWithHttpParam { private: SSLConfig ssl_config_; - scoped_refptr<TCPSocketParams> ignored_tcp_socket_params_; + scoped_refptr<TransportSocketParams> ignored_transport_socket_params_; scoped_refptr<SSLSocketParams> ignored_ssl_socket_params_; ClientSocketPoolHistograms tcp_histograms_; DeterministicMockClientSocketFactory socket_factory_; - MockTCPClientSocketPool tcp_socket_pool_; + MockTransportClientSocketPool transport_socket_pool_; ClientSocketPoolHistograms ssl_histograms_; MockHostResolver host_resolver_; CertVerifier cert_verifier_; diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc index 09c17ea..401ba7d 100644 --- a/net/http/http_stream_factory_impl_job.cc +++ b/net/http/http_stream_factory_impl_job.cc @@ -24,7 +24,6 @@ #include "net/socket/socks_client_socket_pool.h" #include "net/socket/ssl_client_socket.h" #include "net/socket/ssl_client_socket_pool.h" -#include "net/socket/tcp_client_socket_pool.h" #include "net/spdy/spdy_http_stream.h" #include "net/spdy/spdy_session.h" #include "net/spdy/spdy_session_pool.h" diff --git a/net/http/http_stream_factory_impl_job.h b/net/http/http_stream_factory_impl_job.h index d4335c8..a12d108 100644 --- a/net/http/http_stream_factory_impl_job.h +++ b/net/http/http_stream_factory_impl_job.h @@ -28,7 +28,7 @@ class HttpProxySocketParams; class HttpStream; class SOCKSSocketParams; class SSLSocketParams; -class TCPSocketParams; +class TransportSocketParams; // An HttpStreamRequestImpl exists for each stream which is in progress of being // created for the StreamFactory. diff --git a/net/http/http_stream_factory_impl_unittest.cc b/net/http/http_stream_factory_impl_unittest.cc index f316251..4246059 100644 --- a/net/http/http_stream_factory_impl_unittest.cc +++ b/net/http/http_stream_factory_impl_unittest.cc @@ -183,8 +183,8 @@ class CapturePreconnectsSocketPool : public ParentPool { int last_num_streams_; }; -typedef CapturePreconnectsSocketPool<TCPClientSocketPool> -CapturePreconnectsTCPSocketPool; +typedef CapturePreconnectsSocketPool<TransportClientSocketPool> +CapturePreconnectsTransportSocketPool; typedef CapturePreconnectsSocketPool<HttpProxyClientSocketPool> CapturePreconnectsHttpProxySocketPool; typedef CapturePreconnectsSocketPool<SOCKSClientSocketPool> @@ -216,11 +216,11 @@ TEST(HttpStreamFactoryTest, PreconnectDirect) { SessionDependencies session_deps(ProxyService::CreateDirect()); scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); HttpNetworkSessionPeer peer(session); - CapturePreconnectsTCPSocketPool* tcp_conn_pool = - new CapturePreconnectsTCPSocketPool( + CapturePreconnectsTransportSocketPool* transport_conn_pool = + new CapturePreconnectsTransportSocketPool( session_deps.host_resolver.get(), session_deps.cert_verifier.get()); - peer.SetTCPSocketPool(tcp_conn_pool); + peer.SetTransportSocketPool(transport_conn_pool); CapturePreconnectsSSLSocketPool* ssl_conn_pool = new CapturePreconnectsSSLSocketPool( session_deps.host_resolver.get(), @@ -230,7 +230,7 @@ TEST(HttpStreamFactoryTest, PreconnectDirect) { if (kTests[i].ssl) EXPECT_EQ(kTests[i].num_streams, ssl_conn_pool->last_num_streams()); else - EXPECT_EQ(kTests[i].num_streams, tcp_conn_pool->last_num_streams()); + EXPECT_EQ(kTests[i].num_streams, transport_conn_pool->last_num_streams()); } } @@ -295,11 +295,11 @@ TEST(HttpStreamFactoryTest, PreconnectDirectWithExistingSpdySession) { scoped_refptr<SpdySession> spdy_session = session->spdy_session_pool()->Get(pair, BoundNetLog()); - CapturePreconnectsTCPSocketPool* tcp_conn_pool = - new CapturePreconnectsTCPSocketPool( + CapturePreconnectsTransportSocketPool* transport_conn_pool = + new CapturePreconnectsTransportSocketPool( session_deps.host_resolver.get(), session_deps.cert_verifier.get()); - peer.SetTCPSocketPool(tcp_conn_pool); + peer.SetTransportSocketPool(transport_conn_pool); CapturePreconnectsSSLSocketPool* ssl_conn_pool = new CapturePreconnectsSSLSocketPool( session_deps.host_resolver.get(), @@ -311,7 +311,7 @@ TEST(HttpStreamFactoryTest, PreconnectDirectWithExistingSpdySession) { if (kTests[i].ssl) EXPECT_EQ(-1, ssl_conn_pool->last_num_streams()); else - EXPECT_EQ(kTests[i].num_streams, tcp_conn_pool->last_num_streams()); + EXPECT_EQ(kTests[i].num_streams, transport_conn_pool->last_num_streams()); } } diff --git a/net/net.gyp b/net/net.gyp index c2e68c5..50616f6 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -645,10 +645,10 @@ 'socket/tcp_client_socket.h', 'socket/tcp_client_socket_libevent.cc', 'socket/tcp_client_socket_libevent.h', - 'socket/tcp_client_socket_pool.cc', - 'socket/tcp_client_socket_pool.h', 'socket/tcp_client_socket_win.cc', 'socket/tcp_client_socket_win.h', + 'socket/transport_client_socket_pool.cc', + 'socket/transport_client_socket_pool.h', 'socket_stream/socket_stream.cc', 'socket_stream/socket_stream.h', 'socket_stream/socket_stream_job.cc', @@ -991,8 +991,8 @@ 'socket/ssl_client_socket_unittest.cc', 'socket/ssl_client_socket_pool_unittest.cc', 'socket/ssl_server_socket_unittest.cc', - 'socket/tcp_client_socket_pool_unittest.cc', 'socket/tcp_client_socket_unittest.cc', + 'socket/transport_client_socket_pool_unittest.cc', 'socket_stream/socket_stream_metrics_unittest.cc', 'socket_stream/socket_stream_unittest.cc', 'spdy/spdy_framer_test.cc', diff --git a/net/socket/client_socket_factory.cc b/net/socket/client_socket_factory.cc index e8e6f2f..1f8a76c 100644 --- a/net/socket/client_socket_factory.cc +++ b/net/socket/client_socket_factory.cc @@ -45,7 +45,7 @@ class DefaultClientSocketFactory : public ClientSocketFactory, ClearSSLSessionCache(); } - virtual ClientSocket* CreateTCPClientSocket( + virtual ClientSocket* CreateTransportClientSocket( const AddressList& addresses, NetLog* net_log, const NetLog::Source& source) { diff --git a/net/socket/client_socket_factory.h b/net/socket/client_socket_factory.h index df43cdd..ef40ed3 100644 --- a/net/socket/client_socket_factory.h +++ b/net/socket/client_socket_factory.h @@ -31,7 +31,7 @@ class ClientSocketFactory { // |source| is the NetLog::Source for the entity trying to create the socket, // if it has one. - virtual ClientSocket* CreateTCPClientSocket( + virtual ClientSocket* CreateTransportClientSocket( const AddressList& addresses, NetLog* net_log, const NetLog::Source& source) = 0; diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h index fba365820..467831b 100644 --- a/net/socket/client_socket_pool_base.h +++ b/net/socket/client_socket_pool_base.h @@ -539,7 +539,7 @@ class ClientSocketPoolBaseHelper const scoped_ptr<ConnectJobFactory> connect_job_factory_; - // TODO(vandebo) Remove when backup jobs move to TCPClientSocketPool + // TODO(vandebo) Remove when backup jobs move to TransportClientSocketPool bool connect_backup_jobs_enabled_; // A unique id for the pool. It gets incremented every time we Flush() the diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index d22b6dc..209d7a7 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -99,7 +99,7 @@ class MockClientSocketFactory : public ClientSocketFactory { public: MockClientSocketFactory() : allocation_count_(0) {} - virtual ClientSocket* CreateTCPClientSocket( + virtual ClientSocket* CreateTransportClientSocket( const AddressList& addresses, NetLog* /* net_log */, const NetLog::Source& /*source*/) { @@ -188,7 +188,7 @@ class TestConnectJob : public ConnectJob { virtual int ConnectInternal() { AddressList ignored; - client_socket_factory_->CreateTCPClientSocket( + client_socket_factory_->CreateTransportClientSocket( ignored, NULL, net::NetLog::Source()); set_socket(new MockClientSocket()); switch (job_type_) { diff --git a/net/socket/client_socket_pool_manager.cc b/net/socket/client_socket_pool_manager.cc index 8539d72..d9a2225 100644 --- a/net/socket/client_socket_pool_manager.cc +++ b/net/socket/client_socket_pool_manager.cc @@ -23,7 +23,7 @@ #include "net/socket/client_socket_pool_histograms.h" #include "net/socket/socks_client_socket_pool.h" #include "net/socket/ssl_client_socket_pool.h" -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" namespace net { @@ -69,7 +69,7 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info, int num_preconnect_streams, ClientSocketHandle* socket_handle, CompletionCallback* callback) { - scoped_refptr<TCPSocketParams> tcp_params; + scoped_refptr<TransportSocketParams> tcp_params; scoped_refptr<HttpProxySocketParams> http_proxy_params; scoped_refptr<SOCKSSocketParams> socks_params; scoped_ptr<HostPortPair> proxy_host_port; @@ -98,7 +98,7 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info, bool ignore_limits = (request_info.load_flags & LOAD_IGNORE_LIMITS) != 0; if (proxy_info.is_direct()) { - tcp_params = new TCPSocketParams(origin_host_port, + tcp_params = new TransportSocketParams(origin_host_port, request_info.priority, request_info.referrer, disable_resolver_cache, @@ -106,8 +106,8 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info, } else { ProxyServer proxy_server = proxy_info.proxy_server(); proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair())); - scoped_refptr<TCPSocketParams> proxy_tcp_params( - new TCPSocketParams(*proxy_host_port, + scoped_refptr<TransportSocketParams> proxy_tcp_params( + new TransportSocketParams(*proxy_host_port, request_info.priority, request_info.referrer, disable_resolver_cache, @@ -220,7 +220,7 @@ int InitSocketPoolHelper(const HttpRequestInfo& request_info, DCHECK(proxy_info.is_direct()); - TCPClientSocketPool* pool = session->tcp_socket_pool(); + TransportClientSocketPool* pool = session->transport_socket_pool(); if (num_preconnect_streams) { RequestSocketsForPool(pool, connection_group, tcp_params, num_preconnect_streams, net_log); @@ -253,10 +253,10 @@ ClientSocketPoolManager::ClientSocketPoolManager( ssl_host_info_factory_(ssl_host_info_factory), proxy_service_(proxy_service), ssl_config_service_(ssl_config_service), - tcp_pool_histograms_("TCP"), - tcp_socket_pool_(new TCPClientSocketPool( + transport_pool_histograms_("TCP"), + transport_socket_pool_(new TransportClientSocketPool( g_max_sockets, g_max_sockets_per_group, - &tcp_pool_histograms_, + &transport_pool_histograms_, host_resolver, socket_factory_, net_log)), @@ -270,15 +270,15 @@ ClientSocketPoolManager::ClientSocketPoolManager( dns_cert_checker, ssl_host_info_factory, socket_factory, - tcp_socket_pool_.get(), + transport_socket_pool_.get(), NULL /* no socks proxy */, NULL /* no http proxy */, ssl_config_service, net_log)), - tcp_for_socks_pool_histograms_("TCPforSOCKS"), + transport_for_socks_pool_histograms_("TCPforSOCKS"), socks_pool_histograms_("SOCK"), - tcp_for_http_proxy_pool_histograms_("TCPforHTTPProxy"), - tcp_for_https_proxy_pool_histograms_("TCPforHTTPSProxy"), + transport_for_http_proxy_pool_histograms_("TCPforHTTPProxy"), + transport_for_https_proxy_pool_histograms_("TCPforHTTPSProxy"), ssl_for_https_proxy_pool_histograms_("SSLforHTTPSProxy"), http_proxy_pool_histograms_("HTTPProxy"), ssl_socket_pool_for_proxies_histograms_("SSLForProxies") { @@ -311,15 +311,15 @@ void ClientSocketPoolManager::FlushSocketPools() { ++it) it->second->Flush(); - for (TCPSocketPoolMap::const_iterator it = - tcp_socket_pools_for_https_proxies_.begin(); - it != tcp_socket_pools_for_https_proxies_.end(); + for (TransportSocketPoolMap::const_iterator it = + transport_socket_pools_for_https_proxies_.begin(); + it != transport_socket_pools_for_https_proxies_.end(); ++it) it->second->Flush(); - for (TCPSocketPoolMap::const_iterator it = - tcp_socket_pools_for_http_proxies_.begin(); - it != tcp_socket_pools_for_http_proxies_.end(); + for (TransportSocketPoolMap::const_iterator it = + transport_socket_pools_for_http_proxies_.begin(); + it != transport_socket_pools_for_http_proxies_.end(); ++it) it->second->Flush(); @@ -329,14 +329,14 @@ void ClientSocketPoolManager::FlushSocketPools() { ++it) it->second->Flush(); - for (TCPSocketPoolMap::const_iterator it = - tcp_socket_pools_for_socks_proxies_.begin(); - it != tcp_socket_pools_for_socks_proxies_.end(); + for (TransportSocketPoolMap::const_iterator it = + transport_socket_pools_for_socks_proxies_.begin(); + it != transport_socket_pools_for_socks_proxies_.end(); ++it) it->second->Flush(); ssl_socket_pool_->Flush(); - tcp_socket_pool_->Flush(); + transport_socket_pool_->Flush(); } void ClientSocketPoolManager::CloseIdleSockets() { @@ -360,15 +360,15 @@ void ClientSocketPoolManager::CloseIdleSockets() { ++it) it->second->CloseIdleSockets(); - for (TCPSocketPoolMap::const_iterator it = - tcp_socket_pools_for_https_proxies_.begin(); - it != tcp_socket_pools_for_https_proxies_.end(); + for (TransportSocketPoolMap::const_iterator it = + transport_socket_pools_for_https_proxies_.begin(); + it != transport_socket_pools_for_https_proxies_.end(); ++it) it->second->CloseIdleSockets(); - for (TCPSocketPoolMap::const_iterator it = - tcp_socket_pools_for_http_proxies_.begin(); - it != tcp_socket_pools_for_http_proxies_.end(); + for (TransportSocketPoolMap::const_iterator it = + transport_socket_pools_for_http_proxies_.begin(); + it != transport_socket_pools_for_http_proxies_.end(); ++it) it->second->CloseIdleSockets(); @@ -378,33 +378,33 @@ void ClientSocketPoolManager::CloseIdleSockets() { ++it) it->second->CloseIdleSockets(); - for (TCPSocketPoolMap::const_iterator it = - tcp_socket_pools_for_socks_proxies_.begin(); - it != tcp_socket_pools_for_socks_proxies_.end(); + for (TransportSocketPoolMap::const_iterator it = + transport_socket_pools_for_socks_proxies_.begin(); + it != transport_socket_pools_for_socks_proxies_.end(); ++it) it->second->CloseIdleSockets(); ssl_socket_pool_->CloseIdleSockets(); - tcp_socket_pool_->CloseIdleSockets(); + transport_socket_pool_->CloseIdleSockets(); } SOCKSClientSocketPool* ClientSocketPoolManager::GetSocketPoolForSOCKSProxy( const HostPortPair& socks_proxy) { SOCKSSocketPoolMap::const_iterator it = socks_socket_pools_.find(socks_proxy); if (it != socks_socket_pools_.end()) { - DCHECK(ContainsKey(tcp_socket_pools_for_socks_proxies_, socks_proxy)); + DCHECK(ContainsKey(transport_socket_pools_for_socks_proxies_, socks_proxy)); return it->second; } - DCHECK(!ContainsKey(tcp_socket_pools_for_socks_proxies_, socks_proxy)); + DCHECK(!ContainsKey(transport_socket_pools_for_socks_proxies_, socks_proxy)); - std::pair<TCPSocketPoolMap::iterator, bool> tcp_ret = - tcp_socket_pools_for_socks_proxies_.insert( + std::pair<TransportSocketPoolMap::iterator, bool> tcp_ret = + transport_socket_pools_for_socks_proxies_.insert( std::make_pair( socks_proxy, - new TCPClientSocketPool( + new TransportClientSocketPool( g_max_sockets_per_proxy_server, g_max_sockets_per_group, - &tcp_for_socks_pool_histograms_, + &transport_for_socks_pool_histograms_, host_resolver_, socket_factory_, net_log_))); @@ -427,35 +427,35 @@ HttpProxyClientSocketPool* ClientSocketPoolManager::GetSocketPoolForHTTPProxy( HTTPProxySocketPoolMap::const_iterator it = http_proxy_socket_pools_.find(http_proxy); if (it != http_proxy_socket_pools_.end()) { - DCHECK(ContainsKey(tcp_socket_pools_for_http_proxies_, http_proxy)); - DCHECK(ContainsKey(tcp_socket_pools_for_https_proxies_, http_proxy)); + DCHECK(ContainsKey(transport_socket_pools_for_http_proxies_, http_proxy)); + DCHECK(ContainsKey(transport_socket_pools_for_https_proxies_, http_proxy)); DCHECK(ContainsKey(ssl_socket_pools_for_https_proxies_, http_proxy)); return it->second; } - DCHECK(!ContainsKey(tcp_socket_pools_for_http_proxies_, http_proxy)); - DCHECK(!ContainsKey(tcp_socket_pools_for_https_proxies_, http_proxy)); + DCHECK(!ContainsKey(transport_socket_pools_for_http_proxies_, http_proxy)); + DCHECK(!ContainsKey(transport_socket_pools_for_https_proxies_, http_proxy)); DCHECK(!ContainsKey(ssl_socket_pools_for_https_proxies_, http_proxy)); - std::pair<TCPSocketPoolMap::iterator, bool> tcp_http_ret = - tcp_socket_pools_for_http_proxies_.insert( + std::pair<TransportSocketPoolMap::iterator, bool> tcp_http_ret = + transport_socket_pools_for_http_proxies_.insert( std::make_pair( http_proxy, - new TCPClientSocketPool( + new TransportClientSocketPool( g_max_sockets_per_proxy_server, g_max_sockets_per_group, - &tcp_for_http_proxy_pool_histograms_, + &transport_for_http_proxy_pool_histograms_, host_resolver_, socket_factory_, net_log_))); DCHECK(tcp_http_ret.second); - std::pair<TCPSocketPoolMap::iterator, bool> tcp_https_ret = - tcp_socket_pools_for_https_proxies_.insert( + std::pair<TransportSocketPoolMap::iterator, bool> tcp_https_ret = + transport_socket_pools_for_https_proxies_.insert( std::make_pair( http_proxy, - new TCPClientSocketPool( + new TransportClientSocketPool( g_max_sockets_per_proxy_server, g_max_sockets_per_group, - &tcp_for_https_proxy_pool_histograms_, + &transport_for_https_proxy_pool_histograms_, host_resolver_, socket_factory_, net_log_))); @@ -553,11 +553,12 @@ void ClientSocketPoolManager::set_max_sockets_per_proxy_server( Value* ClientSocketPoolManager::SocketPoolInfoToValue() const { ListValue* list = new ListValue(); - list->Append(tcp_socket_pool_->GetInfoAsValue("tcp_socket_pool", - "tcp_socket_pool", + list->Append(transport_socket_pool_->GetInfoAsValue("transport_socket_pool", + "transport_socket_pool", false)); - // Third parameter is false because |ssl_socket_pool_| uses |tcp_socket_pool_| - // internally, and do not want to add it a second time. + // Third parameter is false because |ssl_socket_pool_| uses + // |transport_socket_pool_| internally, and do not want to add it a second + // time. list->Append(ssl_socket_pool_->GetInfoAsValue("ssl_socket_pool", "ssl_socket_pool", false)); diff --git a/net/socket/client_socket_pool_manager.h b/net/socket/client_socket_pool_manager.h index f10b012..ca580e4 100644 --- a/net/socket/client_socket_pool_manager.h +++ b/net/socket/client_socket_pool_manager.h @@ -43,7 +43,7 @@ class SOCKSClientSocketPool; class SSLClientSocketPool; class SSLConfigService; class SSLHostInfoFactory; -class TCPClientSocketPool; +class TransportClientSocketPool; struct HttpRequestInfo; struct SSLConfig; @@ -83,7 +83,9 @@ class ClientSocketPoolManager : public base::NonThreadSafe, void FlushSocketPools(); void CloseIdleSockets(); - TCPClientSocketPool* tcp_socket_pool() { return tcp_socket_pool_.get(); } + TransportClientSocketPool* transport_socket_pool() { + return transport_socket_pool_.get(); + } SSLClientSocketPool* ssl_socket_pool() { return ssl_socket_pool_.get(); } @@ -153,8 +155,8 @@ class ClientSocketPoolManager : public base::NonThreadSafe, private: friend class HttpNetworkSessionPeer; - typedef internal::OwnedPoolMap<HostPortPair, TCPClientSocketPool*> - TCPSocketPoolMap; + typedef internal::OwnedPoolMap<HostPortPair, TransportClientSocketPool*> + TransportSocketPoolMap; typedef internal::OwnedPoolMap<HostPortPair, SOCKSClientSocketPool*> SOCKSSocketPoolMap; typedef internal::OwnedPoolMap<HostPortPair, HttpProxyClientSocketPool*> @@ -174,23 +176,23 @@ class ClientSocketPoolManager : public base::NonThreadSafe, // Note: this ordering is important. - ClientSocketPoolHistograms tcp_pool_histograms_; - scoped_ptr<TCPClientSocketPool> tcp_socket_pool_; + ClientSocketPoolHistograms transport_pool_histograms_; + scoped_ptr<TransportClientSocketPool> transport_socket_pool_; ClientSocketPoolHistograms ssl_pool_histograms_; scoped_ptr<SSLClientSocketPool> ssl_socket_pool_; - ClientSocketPoolHistograms tcp_for_socks_pool_histograms_; - TCPSocketPoolMap tcp_socket_pools_for_socks_proxies_; + ClientSocketPoolHistograms transport_for_socks_pool_histograms_; + TransportSocketPoolMap transport_socket_pools_for_socks_proxies_; ClientSocketPoolHistograms socks_pool_histograms_; SOCKSSocketPoolMap socks_socket_pools_; - ClientSocketPoolHistograms tcp_for_http_proxy_pool_histograms_; - TCPSocketPoolMap tcp_socket_pools_for_http_proxies_; + ClientSocketPoolHistograms transport_for_http_proxy_pool_histograms_; + TransportSocketPoolMap transport_socket_pools_for_http_proxies_; - ClientSocketPoolHistograms tcp_for_https_proxy_pool_histograms_; - TCPSocketPoolMap tcp_socket_pools_for_https_proxies_; + ClientSocketPoolHistograms transport_for_https_proxy_pool_histograms_; + TransportSocketPoolMap transport_socket_pools_for_https_proxies_; ClientSocketPoolHistograms ssl_for_https_proxy_pool_histograms_; SSLSocketPoolMap ssl_socket_pools_for_https_proxies_; diff --git a/net/socket/deterministic_socket_data_unittest.cc b/net/socket/deterministic_socket_data_unittest.cc index 8482a96..af1a63d 100644 --- a/net/socket/deterministic_socket_data_unittest.cc +++ b/net/socket/deterministic_socket_data_unittest.cc @@ -52,10 +52,10 @@ class DeterministicSocketDataTest : public PlatformTest { GURL url_; HostPortPair endpoint_; - scoped_refptr<TCPSocketParams> tcp_params_; + scoped_refptr<TransportSocketParams> tcp_params_; ClientSocketPoolHistograms histograms_; DeterministicMockClientSocketFactory socket_factory_; - MockTCPClientSocketPool socket_pool_; + MockTransportClientSocketPool socket_pool_; ClientSocketHandle connection_; DISALLOW_COPY_AND_ASSIGN(DeterministicSocketDataTest); @@ -70,7 +70,11 @@ DeterministicSocketDataTest::DeterministicSocketDataTest() connect_data_(false, OK), url_("https://www.google.com"), endpoint_("www.google.com", 443), - tcp_params_(new TCPSocketParams(endpoint_, LOWEST, url_, false, false)), + tcp_params_(new TransportSocketParams(endpoint_, + LOWEST, + url_, + false, + false)), histograms_(""), socket_pool_(10, 10, &histograms_, &socket_factory_) { } @@ -91,9 +95,12 @@ void DeterministicSocketDataTest::Initialize(MockRead* reads, // Perform the TCP connect EXPECT_EQ(OK, - connection_.Init(endpoint_.ToString(), tcp_params_, - LOWEST, NULL, (TCPClientSocketPool*)&socket_pool_, - BoundNetLog())); + connection_.Init(endpoint_.ToString(), + tcp_params_, + LOWEST, + NULL, + reinterpret_cast<TransportClientSocketPool*>(&socket_pool_), + BoundNetLog())); sock_ = connection_.socket(); } diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index fb4c7ae..43cdf03 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -588,7 +588,7 @@ MockSSLClientSocket* MockClientSocketFactory::GetMockSSLClientSocket( return ssl_client_sockets_[index]; } -ClientSocket* MockClientSocketFactory::CreateTCPClientSocket( +ClientSocket* MockClientSocketFactory::CreateTransportClientSocket( const AddressList& addresses, net::NetLog* net_log, const NetLog::Source& source) { @@ -1171,7 +1171,7 @@ void ClientSocketPoolTest::ReleaseAllConnections(KeepAlive keep_alive) { } while (released_one); } -MockTCPClientSocketPool::MockConnectJob::MockConnectJob( +MockTransportClientSocketPool::MockConnectJob::MockConnectJob( ClientSocket* socket, ClientSocketHandle* handle, CompletionCallback* callback) @@ -1182,9 +1182,9 @@ MockTCPClientSocketPool::MockConnectJob::MockConnectJob( connect_callback_(this, &MockConnectJob::OnConnect)) { } -MockTCPClientSocketPool::MockConnectJob::~MockConnectJob() {} +MockTransportClientSocketPool::MockConnectJob::~MockConnectJob() {} -int MockTCPClientSocketPool::MockConnectJob::Connect() { +int MockTransportClientSocketPool::MockConnectJob::Connect() { int rv = socket_->Connect(&connect_callback_); if (rv == OK) { user_callback_ = NULL; @@ -1193,7 +1193,7 @@ int MockTCPClientSocketPool::MockConnectJob::Connect() { return rv; } -bool MockTCPClientSocketPool::MockConnectJob::CancelHandle( +bool MockTransportClientSocketPool::MockConnectJob::CancelHandle( const ClientSocketHandle* handle) { if (handle != handle_) return false; @@ -1203,7 +1203,7 @@ bool MockTCPClientSocketPool::MockConnectJob::CancelHandle( return true; } -void MockTCPClientSocketPool::MockConnectJob::OnConnect(int rv) { +void MockTransportClientSocketPool::MockConnectJob::OnConnect(int rv) { if (!socket_.get()) return; if (rv == OK) { @@ -1221,27 +1221,27 @@ void MockTCPClientSocketPool::MockConnectJob::OnConnect(int rv) { } } -MockTCPClientSocketPool::MockTCPClientSocketPool( +MockTransportClientSocketPool::MockTransportClientSocketPool( int max_sockets, int max_sockets_per_group, ClientSocketPoolHistograms* histograms, ClientSocketFactory* socket_factory) - : TCPClientSocketPool(max_sockets, max_sockets_per_group, histograms, - NULL, NULL, NULL), + : TransportClientSocketPool(max_sockets, max_sockets_per_group, histograms, + NULL, NULL, NULL), client_socket_factory_(socket_factory), release_count_(0), cancel_count_(0) { } -MockTCPClientSocketPool::~MockTCPClientSocketPool() {} +MockTransportClientSocketPool::~MockTransportClientSocketPool() {} -int MockTCPClientSocketPool::RequestSocket(const std::string& group_name, +int MockTransportClientSocketPool::RequestSocket(const std::string& group_name, const void* socket_params, RequestPriority priority, ClientSocketHandle* handle, CompletionCallback* callback, const BoundNetLog& net_log) { - ClientSocket* socket = client_socket_factory_->CreateTCPClientSocket( + ClientSocket* socket = client_socket_factory_->CreateTransportClientSocket( AddressList(), net_log.net_log(), net::NetLog::Source()); MockConnectJob* job = new MockConnectJob(socket, handle, callback); job_list_.push_back(job); @@ -1249,7 +1249,7 @@ int MockTCPClientSocketPool::RequestSocket(const std::string& group_name, return job->Connect(); } -void MockTCPClientSocketPool::CancelRequest(const std::string& group_name, +void MockTransportClientSocketPool::CancelRequest(const std::string& group_name, ClientSocketHandle* handle) { std::vector<MockConnectJob*>::iterator i; for (i = job_list_.begin(); i != job_list_.end(); ++i) { @@ -1260,7 +1260,7 @@ void MockTCPClientSocketPool::CancelRequest(const std::string& group_name, } } -void MockTCPClientSocketPool::ReleaseSocket(const std::string& group_name, +void MockTransportClientSocketPool::ReleaseSocket(const std::string& group_name, ClientSocket* socket, int id) { EXPECT_EQ(1, id); release_count_++; @@ -1292,7 +1292,7 @@ MockSSLClientSocket* DeterministicMockClientSocketFactory:: return ssl_client_sockets_[index]; } -ClientSocket* DeterministicMockClientSocketFactory::CreateTCPClientSocket( +ClientSocket* DeterministicMockClientSocketFactory::CreateTransportClientSocket( const AddressList& addresses, net::NetLog* net_log, const net::NetLog::Source& source) { @@ -1325,10 +1325,10 @@ MockSOCKSClientSocketPool::MockSOCKSClientSocketPool( int max_sockets, int max_sockets_per_group, ClientSocketPoolHistograms* histograms, - TCPClientSocketPool* tcp_pool) + TransportClientSocketPool* transport_pool) : SOCKSClientSocketPool(max_sockets, max_sockets_per_group, histograms, - NULL, tcp_pool, NULL), - tcp_pool_(tcp_pool) { + NULL, transport_pool, NULL), + transport_pool_(transport_pool) { } MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} @@ -1339,19 +1339,23 @@ int MockSOCKSClientSocketPool::RequestSocket(const std::string& group_name, ClientSocketHandle* handle, CompletionCallback* callback, const BoundNetLog& net_log) { - return tcp_pool_->RequestSocket(group_name, socket_params, priority, handle, - callback, net_log); + return transport_pool_->RequestSocket(group_name, + socket_params, + priority, + handle, + callback, + net_log); } void MockSOCKSClientSocketPool::CancelRequest( const std::string& group_name, ClientSocketHandle* handle) { - return tcp_pool_->CancelRequest(group_name, handle); + return transport_pool_->CancelRequest(group_name, handle); } void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, ClientSocket* socket, int id) { - return tcp_pool_->ReleaseSocket(group_name, socket, id); + return transport_pool_->ReleaseSocket(group_name, socket, id); } const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h index 69daad9..21301f7 100644 --- a/net/socket/socket_test_util.h +++ b/net/socket/socket_test_util.h @@ -31,7 +31,7 @@ #include "net/socket/socks_client_socket_pool.h" #include "net/socket/ssl_client_socket.h" #include "net/socket/ssl_client_socket_pool.h" -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" #include "testing/gtest/include/gtest/gtest.h" namespace net { @@ -533,7 +533,7 @@ class MockClientSocketFactory : public ClientSocketFactory { } // ClientSocketFactory - virtual ClientSocket* CreateTCPClientSocket( + virtual ClientSocket* CreateTransportClientSocket( const AddressList& addresses, NetLog* net_log, const NetLog::Source& source); @@ -813,7 +813,7 @@ class ClientSocketPoolTest { size_t completion_count_; }; -class MockTCPClientSocketPool : public TCPClientSocketPool { +class MockTransportClientSocketPool : public TransportClientSocketPool { public: class MockConnectJob { public: @@ -835,18 +835,18 @@ class MockTCPClientSocketPool : public TCPClientSocketPool { DISALLOW_COPY_AND_ASSIGN(MockConnectJob); }; - MockTCPClientSocketPool( + MockTransportClientSocketPool( int max_sockets, int max_sockets_per_group, ClientSocketPoolHistograms* histograms, ClientSocketFactory* socket_factory); - virtual ~MockTCPClientSocketPool(); + virtual ~MockTransportClientSocketPool(); int release_count() const { return release_count_; } int cancel_count() const { return cancel_count_; } - // TCPClientSocketPool methods. + // TransportClientSocketPool methods. virtual int RequestSocket(const std::string& group_name, const void* socket_params, RequestPriority priority, @@ -865,7 +865,7 @@ class MockTCPClientSocketPool : public TCPClientSocketPool { int release_count_; int cancel_count_; - DISALLOW_COPY_AND_ASSIGN(MockTCPClientSocketPool); + DISALLOW_COPY_AND_ASSIGN(MockTransportClientSocketPool); }; class DeterministicMockClientSocketFactory : public ClientSocketFactory { @@ -889,9 +889,10 @@ class DeterministicMockClientSocketFactory : public ClientSocketFactory { } // ClientSocketFactory - virtual ClientSocket* CreateTCPClientSocket(const AddressList& addresses, - NetLog* net_log, - const NetLog::Source& source); + virtual ClientSocket* CreateTransportClientSocket( + const AddressList& addresses, + NetLog* net_log, + const NetLog::Source& source); virtual SSLClientSocket* CreateSSLClientSocket( ClientSocketHandle* transport_socket, const HostPortPair& host_and_port, @@ -916,7 +917,7 @@ class MockSOCKSClientSocketPool : public SOCKSClientSocketPool { int max_sockets, int max_sockets_per_group, ClientSocketPoolHistograms* histograms, - TCPClientSocketPool* tcp_pool); + TransportClientSocketPool* transport_pool); virtual ~MockSOCKSClientSocketPool(); @@ -934,7 +935,7 @@ class MockSOCKSClientSocketPool : public SOCKSClientSocketPool { ClientSocket* socket, int id); private: - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool); }; diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc index 97a797e..dca2523 100644 --- a/net/socket/socks_client_socket_pool.cc +++ b/net/socket/socks_client_socket_pool.cc @@ -13,21 +13,21 @@ #include "net/socket/client_socket_pool_base.h" #include "net/socket/socks5_client_socket.h" #include "net/socket/socks_client_socket.h" -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" namespace net { SOCKSSocketParams::SOCKSSocketParams( - const scoped_refptr<TCPSocketParams>& proxy_server, + const scoped_refptr<TransportSocketParams>& proxy_server, bool socks_v5, const HostPortPair& host_port_pair, RequestPriority priority, const GURL& referrer) - : tcp_params_(proxy_server), + : transport_params_(proxy_server), destination_(host_port_pair), socks_v5_(socks_v5) { - if (tcp_params_) - ignore_limits_ = tcp_params_->ignore_limits(); + if (transport_params_) + ignore_limits_ = transport_params_->ignore_limits(); else ignore_limits_ = false; // The referrer is used by the DNS prefetch system to correlate resolutions @@ -47,14 +47,14 @@ SOCKSConnectJob::SOCKSConnectJob( const std::string& group_name, const scoped_refptr<SOCKSSocketParams>& socks_params, const base::TimeDelta& timeout_duration, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, HostResolver* host_resolver, Delegate* delegate, NetLog* net_log) : ConnectJob(group_name, timeout_duration, delegate, BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), socks_params_(socks_params), - tcp_pool_(tcp_pool), + transport_pool_(transport_pool), resolver_(host_resolver), ALLOW_THIS_IN_INITIALIZER_LIST( callback_(this, &SOCKSConnectJob::OnIOComplete)) { @@ -62,14 +62,15 @@ SOCKSConnectJob::SOCKSConnectJob( SOCKSConnectJob::~SOCKSConnectJob() { // We don't worry about cancelling the tcp socket since the destructor in - // scoped_ptr<ClientSocketHandle> tcp_socket_handle_ will take care of it. + // scoped_ptr<ClientSocketHandle> transport_socket_handle_ will take care of + // it. } LoadState SOCKSConnectJob::GetLoadState() const { switch (next_state_) { - case STATE_TCP_CONNECT: - case STATE_TCP_CONNECT_COMPLETE: - return tcp_socket_handle_->GetLoadState(); + case STATE_TRANSPORT_CONNECT: + case STATE_TRANSPORT_CONNECT_COMPLETE: + return transport_socket_handle_->GetLoadState(); case STATE_SOCKS_CONNECT: case STATE_SOCKS_CONNECT_COMPLETE: return LOAD_STATE_CONNECTING; @@ -93,12 +94,12 @@ int SOCKSConnectJob::DoLoop(int result) { State state = next_state_; next_state_ = STATE_NONE; switch (state) { - case STATE_TCP_CONNECT: + case STATE_TRANSPORT_CONNECT: DCHECK_EQ(OK, rv); - rv = DoTCPConnect(); + rv = DoTransportConnect(); break; - case STATE_TCP_CONNECT_COMPLETE: - rv = DoTCPConnectComplete(rv); + case STATE_TRANSPORT_CONNECT_COMPLETE: + rv = DoTransportConnectComplete(rv); break; case STATE_SOCKS_CONNECT: DCHECK_EQ(OK, rv); @@ -117,15 +118,18 @@ int SOCKSConnectJob::DoLoop(int result) { return rv; } -int SOCKSConnectJob::DoTCPConnect() { - next_state_ = STATE_TCP_CONNECT_COMPLETE; - tcp_socket_handle_.reset(new ClientSocketHandle()); - return tcp_socket_handle_->Init(group_name(), socks_params_->tcp_params(), - socks_params_->destination().priority(), - &callback_, tcp_pool_, net_log()); +int SOCKSConnectJob::DoTransportConnect() { + next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; + transport_socket_handle_.reset(new ClientSocketHandle()); + return transport_socket_handle_->Init(group_name(), + socks_params_->transport_params(), + socks_params_->destination().priority(), + &callback_, + transport_pool_, + net_log()); } -int SOCKSConnectJob::DoTCPConnectComplete(int result) { +int SOCKSConnectJob::DoTransportConnectComplete(int result) { if (result != OK) return ERR_PROXY_CONNECTION_FAILED; @@ -142,10 +146,10 @@ int SOCKSConnectJob::DoSOCKSConnect() { // Add a SOCKS connection on top of the tcp socket. if (socks_params_->is_socks_v5()) { - socket_.reset(new SOCKS5ClientSocket(tcp_socket_handle_.release(), + socket_.reset(new SOCKS5ClientSocket(transport_socket_handle_.release(), socks_params_->destination())); } else { - socket_.reset(new SOCKSClientSocket(tcp_socket_handle_.release(), + socket_.reset(new SOCKSClientSocket(transport_socket_handle_.release(), socks_params_->destination(), resolver_)); } @@ -163,7 +167,7 @@ int SOCKSConnectJob::DoSOCKSConnectComplete(int result) { } int SOCKSConnectJob::ConnectInternal() { - next_state_ = STATE_TCP_CONNECT; + next_state_ = STATE_TRANSPORT_CONNECT; return DoLoop(OK); } @@ -171,13 +175,18 @@ ConnectJob* SOCKSClientSocketPool::SOCKSConnectJobFactory::NewConnectJob( const std::string& group_name, const PoolBase::Request& request, ConnectJob::Delegate* delegate) const { - return new SOCKSConnectJob(group_name, request.params(), ConnectionTimeout(), - tcp_pool_, host_resolver_, delegate, net_log_); + return new SOCKSConnectJob(group_name, + request.params(), + ConnectionTimeout(), + transport_pool_, + host_resolver_, + delegate, + net_log_); } base::TimeDelta SOCKSClientSocketPool::SOCKSConnectJobFactory::ConnectionTimeout() const { - return tcp_pool_->ConnectionTimeout() + + return transport_pool_->ConnectionTimeout() + base::TimeDelta::FromSeconds(kSOCKSConnectJobTimeoutInSeconds); } @@ -186,14 +195,16 @@ SOCKSClientSocketPool::SOCKSClientSocketPool( int max_sockets_per_group, ClientSocketPoolHistograms* histograms, HostResolver* host_resolver, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, NetLog* net_log) - : tcp_pool_(tcp_pool), + : transport_pool_(transport_pool), base_(max_sockets, max_sockets_per_group, histograms, base::TimeDelta::FromSeconds( ClientSocketPool::unused_idle_socket_timeout()), base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout), - new SOCKSConnectJobFactory(tcp_pool, host_resolver, net_log)) { + new SOCKSConnectJobFactory(transport_pool, + host_resolver, + net_log)) { } SOCKSClientSocketPool::~SOCKSClientSocketPool() {} @@ -261,9 +272,9 @@ DictionaryValue* SOCKSClientSocketPool::GetInfoAsValue( DictionaryValue* dict = base_.GetInfoAsValue(name, type); if (include_nested_pools) { ListValue* list = new ListValue(); - list->Append(tcp_pool_->GetInfoAsValue("tcp_socket_pool", - "tcp_socket_pool", - false)); + list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", + "transport_socket_pool", + false)); dict->Set("nested_pools", list); } return dict; diff --git a/net/socket/socks_client_socket_pool.h b/net/socket/socks_client_socket_pool.h index c25423f..b66caf2 100644 --- a/net/socket/socks_client_socket_pool.h +++ b/net/socket/socks_client_socket_pool.h @@ -22,17 +22,17 @@ namespace net { class ConnectJobFactory; -class TCPClientSocketPool; -class TCPSocketParams; +class TransportClientSocketPool; +class TransportSocketParams; class SOCKSSocketParams : public base::RefCounted<SOCKSSocketParams> { public: - SOCKSSocketParams(const scoped_refptr<TCPSocketParams>& proxy_server, + SOCKSSocketParams(const scoped_refptr<TransportSocketParams>& proxy_server, bool socks_v5, const HostPortPair& host_port_pair, RequestPriority priority, const GURL& referrer); - const scoped_refptr<TCPSocketParams>& tcp_params() const { - return tcp_params_; + const scoped_refptr<TransportSocketParams>& transport_params() const { + return transport_params_; } const HostResolver::RequestInfo& destination() const { return destination_; } bool is_socks_v5() const { return socks_v5_; } @@ -42,8 +42,8 @@ class SOCKSSocketParams : public base::RefCounted<SOCKSSocketParams> { friend class base::RefCounted<SOCKSSocketParams>; ~SOCKSSocketParams(); - // The tcp connection must point toward the proxy server. - const scoped_refptr<TCPSocketParams> tcp_params_; + // The transport (likely TCP) connection must point toward the proxy server. + const scoped_refptr<TransportSocketParams> transport_params_; // This is the HTTP destination. HostResolver::RequestInfo destination_; const bool socks_v5_; @@ -59,7 +59,7 @@ class SOCKSConnectJob : public ConnectJob { SOCKSConnectJob(const std::string& group_name, const scoped_refptr<SOCKSSocketParams>& params, const base::TimeDelta& timeout_duration, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, HostResolver* host_resolver, Delegate* delegate, NetLog* net_log); @@ -70,8 +70,8 @@ class SOCKSConnectJob : public ConnectJob { private: enum State { - STATE_TCP_CONNECT, - STATE_TCP_CONNECT_COMPLETE, + STATE_TRANSPORT_CONNECT, + STATE_TRANSPORT_CONNECT_COMPLETE, STATE_SOCKS_CONNECT, STATE_SOCKS_CONNECT_COMPLETE, STATE_NONE, @@ -82,23 +82,23 @@ class SOCKSConnectJob : public ConnectJob { // Runs the state transition loop. int DoLoop(int result); - int DoTCPConnect(); - int DoTCPConnectComplete(int result); + int DoTransportConnect(); + int DoTransportConnectComplete(int result); int DoSOCKSConnect(); int DoSOCKSConnectComplete(int result); - // Begins the tcp connection and the SOCKS handshake. Returns OK on success - // and ERR_IO_PENDING if it cannot immediately service the request. + // Begins the transport connection and the SOCKS handshake. Returns OK on + // success and ERR_IO_PENDING if it cannot immediately service the request. // Otherwise, it returns a net error code. virtual int ConnectInternal(); scoped_refptr<SOCKSSocketParams> socks_params_; - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; HostResolver* const resolver_; State next_state_; CompletionCallbackImpl<SOCKSConnectJob> callback_; - scoped_ptr<ClientSocketHandle> tcp_socket_handle_; + scoped_ptr<ClientSocketHandle> transport_socket_handle_; scoped_ptr<ClientSocket> socket_; DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJob); @@ -111,7 +111,7 @@ class SOCKSClientSocketPool : public ClientSocketPool { int max_sockets_per_group, ClientSocketPoolHistograms* histograms, HostResolver* host_resolver, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, NetLog* net_log); virtual ~SOCKSClientSocketPool(); @@ -160,10 +160,10 @@ class SOCKSClientSocketPool : public ClientSocketPool { class SOCKSConnectJobFactory : public PoolBase::ConnectJobFactory { public: - SOCKSConnectJobFactory(TCPClientSocketPool* tcp_pool, + SOCKSConnectJobFactory(TransportClientSocketPool* transport_pool, HostResolver* host_resolver, NetLog* net_log) - : tcp_pool_(tcp_pool), + : transport_pool_(transport_pool), host_resolver_(host_resolver), net_log_(net_log) {} @@ -178,14 +178,14 @@ class SOCKSClientSocketPool : public ClientSocketPool { virtual base::TimeDelta ConnectionTimeout() const; private: - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; HostResolver* const host_resolver_; NetLog* net_log_; DISALLOW_COPY_AND_ASSIGN(SOCKSConnectJobFactory); }; - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; PoolBase base_; DISALLOW_COPY_AND_ASSIGN(SOCKSClientSocketPool); diff --git a/net/socket/socks_client_socket_pool_unittest.cc b/net/socket/socks_client_socket_pool_unittest.cc index b8d44c4..431a009 100644 --- a/net/socket/socks_client_socket_pool_unittest.cc +++ b/net/socket/socks_client_socket_pool_unittest.cc @@ -53,21 +53,21 @@ class SOCKSClientSocketPoolTest : public testing::Test { }; SOCKSClientSocketPoolTest() - : ignored_tcp_socket_params_(new TCPSocketParams( + : ignored_transport_socket_params_(new TransportSocketParams( HostPortPair("proxy", 80), MEDIUM, GURL(), false, false)), - tcp_histograms_("MockTCP"), - tcp_socket_pool_( + transport_histograms_("MockTCP"), + transport_socket_pool_( kMaxSockets, kMaxSocketsPerGroup, - &tcp_histograms_, - &tcp_client_socket_factory_), + &transport_histograms_, + &transport_client_socket_factory_), ignored_socket_params_(new SOCKSSocketParams( - ignored_tcp_socket_params_, true, HostPortPair("host", 80), MEDIUM, - GURL())), + ignored_transport_socket_params_, true, HostPortPair("host", 80), + MEDIUM, GURL())), socks_histograms_("SOCKSUnitTest"), pool_(kMaxSockets, kMaxSocketsPerGroup, &socks_histograms_, NULL, - &tcp_socket_pool_, + &transport_socket_pool_, NULL) { } @@ -84,10 +84,10 @@ class SOCKSClientSocketPoolTest : public testing::Test { ScopedVector<TestSocketRequest>* requests() { return test_base_.requests(); } - scoped_refptr<TCPSocketParams> ignored_tcp_socket_params_; - ClientSocketPoolHistograms tcp_histograms_; - MockClientSocketFactory tcp_client_socket_factory_; - MockTCPClientSocketPool tcp_socket_pool_; + scoped_refptr<TransportSocketParams> ignored_transport_socket_params_; + ClientSocketPoolHistograms transport_histograms_; + MockClientSocketFactory transport_client_socket_factory_; + MockTransportClientSocketPool transport_socket_pool_; scoped_refptr<SOCKSSocketParams> ignored_socket_params_; ClientSocketPoolHistograms socks_histograms_; @@ -98,7 +98,7 @@ class SOCKSClientSocketPoolTest : public testing::Test { TEST_F(SOCKSClientSocketPoolTest, Simple) { SOCKS5MockData data(false); data.data_provider()->set_connect_data(MockConnect(false, 0)); - tcp_client_socket_factory_.AddSocketDataProvider(data.data_provider()); + transport_client_socket_factory_.AddSocketDataProvider(data.data_provider()); ClientSocketHandle handle; int rv = handle.Init("a", ignored_socket_params_, LOW, NULL, &pool_, @@ -110,7 +110,7 @@ TEST_F(SOCKSClientSocketPoolTest, Simple) { TEST_F(SOCKSClientSocketPoolTest, Async) { SOCKS5MockData data(true); - tcp_client_socket_factory_.AddSocketDataProvider(data.data_provider()); + transport_client_socket_factory_.AddSocketDataProvider(data.data_provider()); TestCompletionCallback callback; ClientSocketHandle handle; @@ -125,10 +125,10 @@ TEST_F(SOCKSClientSocketPoolTest, Async) { EXPECT_TRUE(handle.socket()); } -TEST_F(SOCKSClientSocketPoolTest, TCPConnectError) { +TEST_F(SOCKSClientSocketPoolTest, TransportConnectError) { scoped_ptr<SocketDataProvider> socket_data(new StaticSocketDataProvider()); socket_data->set_connect_data(MockConnect(false, ERR_CONNECTION_REFUSED)); - tcp_client_socket_factory_.AddSocketDataProvider(socket_data.get()); + transport_client_socket_factory_.AddSocketDataProvider(socket_data.get()); ClientSocketHandle handle; int rv = handle.Init("a", ignored_socket_params_, LOW, NULL, &pool_, @@ -138,10 +138,10 @@ TEST_F(SOCKSClientSocketPoolTest, TCPConnectError) { EXPECT_FALSE(handle.socket()); } -TEST_F(SOCKSClientSocketPoolTest, AsyncTCPConnectError) { +TEST_F(SOCKSClientSocketPoolTest, AsyncTransportConnectError) { scoped_ptr<SocketDataProvider> socket_data(new StaticSocketDataProvider()); socket_data->set_connect_data(MockConnect(true, ERR_CONNECTION_REFUSED)); - tcp_client_socket_factory_.AddSocketDataProvider(socket_data.get()); + transport_client_socket_factory_.AddSocketDataProvider(socket_data.get()); TestCompletionCallback callback; ClientSocketHandle handle; @@ -163,16 +163,16 @@ TEST_F(SOCKSClientSocketPoolTest, SOCKSConnectError) { scoped_ptr<SocketDataProvider> socket_data(new StaticSocketDataProvider( failed_read, arraysize(failed_read), NULL, 0)); socket_data->set_connect_data(MockConnect(false, 0)); - tcp_client_socket_factory_.AddSocketDataProvider(socket_data.get()); + transport_client_socket_factory_.AddSocketDataProvider(socket_data.get()); ClientSocketHandle handle; - EXPECT_EQ(0, tcp_socket_pool_.release_count()); + EXPECT_EQ(0, transport_socket_pool_.release_count()); int rv = handle.Init("a", ignored_socket_params_, LOW, NULL, &pool_, BoundNetLog()); EXPECT_EQ(ERR_SOCKS_CONNECTION_FAILED, rv); EXPECT_FALSE(handle.is_initialized()); EXPECT_FALSE(handle.socket()); - EXPECT_EQ(1, tcp_socket_pool_.release_count()); + EXPECT_EQ(1, transport_socket_pool_.release_count()); } TEST_F(SOCKSClientSocketPoolTest, AsyncSOCKSConnectError) { @@ -182,11 +182,11 @@ TEST_F(SOCKSClientSocketPoolTest, AsyncSOCKSConnectError) { scoped_ptr<SocketDataProvider> socket_data(new StaticSocketDataProvider( failed_read, arraysize(failed_read), NULL, 0)); socket_data->set_connect_data(MockConnect(false, 0)); - tcp_client_socket_factory_.AddSocketDataProvider(socket_data.get()); + transport_client_socket_factory_.AddSocketDataProvider(socket_data.get()); TestCompletionCallback callback; ClientSocketHandle handle; - EXPECT_EQ(0, tcp_socket_pool_.release_count()); + EXPECT_EQ(0, transport_socket_pool_.release_count()); int rv = handle.Init("a", ignored_socket_params_, LOW, &callback, &pool_, BoundNetLog()); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -196,18 +196,18 @@ TEST_F(SOCKSClientSocketPoolTest, AsyncSOCKSConnectError) { EXPECT_EQ(ERR_SOCKS_CONNECTION_FAILED, callback.WaitForResult()); EXPECT_FALSE(handle.is_initialized()); EXPECT_FALSE(handle.socket()); - EXPECT_EQ(1, tcp_socket_pool_.release_count()); + EXPECT_EQ(1, transport_socket_pool_.release_count()); } -TEST_F(SOCKSClientSocketPoolTest, CancelDuringTCPConnect) { +TEST_F(SOCKSClientSocketPoolTest, CancelDuringTransportConnect) { SOCKS5MockData data(false); - tcp_client_socket_factory_.AddSocketDataProvider(data.data_provider()); + transport_client_socket_factory_.AddSocketDataProvider(data.data_provider()); // We need two connections because the pool base lets one cancelled // connect job proceed for potential future use. SOCKS5MockData data2(false); - tcp_client_socket_factory_.AddSocketDataProvider(data2.data_provider()); + transport_client_socket_factory_.AddSocketDataProvider(data2.data_provider()); - EXPECT_EQ(0, tcp_socket_pool_.cancel_count()); + EXPECT_EQ(0, transport_socket_pool_.cancel_count()); int rv = StartRequest("a", LOW); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -217,14 +217,14 @@ TEST_F(SOCKSClientSocketPoolTest, CancelDuringTCPConnect) { pool_.CancelRequest("a", (*requests())[0]->handle()); pool_.CancelRequest("a", (*requests())[1]->handle()); // Requests in the connect phase don't actually get cancelled. - EXPECT_EQ(0, tcp_socket_pool_.cancel_count()); + EXPECT_EQ(0, transport_socket_pool_.cancel_count()); // Now wait for the TCP sockets to connect. MessageLoop::current()->RunAllPending(); EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(1)); EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(2)); - EXPECT_EQ(0, tcp_socket_pool_.cancel_count()); + EXPECT_EQ(0, transport_socket_pool_.cancel_count()); EXPECT_EQ(2, pool_.IdleSocketCount()); (*requests())[0]->handle()->Reset(); @@ -234,15 +234,15 @@ TEST_F(SOCKSClientSocketPoolTest, CancelDuringTCPConnect) { TEST_F(SOCKSClientSocketPoolTest, CancelDuringSOCKSConnect) { SOCKS5MockData data(true); data.data_provider()->set_connect_data(MockConnect(false, 0)); - tcp_client_socket_factory_.AddSocketDataProvider(data.data_provider()); + transport_client_socket_factory_.AddSocketDataProvider(data.data_provider()); // We need two connections because the pool base lets one cancelled // connect job proceed for potential future use. SOCKS5MockData data2(true); data2.data_provider()->set_connect_data(MockConnect(false, 0)); - tcp_client_socket_factory_.AddSocketDataProvider(data2.data_provider()); + transport_client_socket_factory_.AddSocketDataProvider(data2.data_provider()); - EXPECT_EQ(0, tcp_socket_pool_.cancel_count()); - EXPECT_EQ(0, tcp_socket_pool_.release_count()); + EXPECT_EQ(0, transport_socket_pool_.cancel_count()); + EXPECT_EQ(0, transport_socket_pool_.release_count()); int rv = StartRequest("a", LOW); EXPECT_EQ(ERR_IO_PENDING, rv); @@ -251,17 +251,17 @@ TEST_F(SOCKSClientSocketPoolTest, CancelDuringSOCKSConnect) { pool_.CancelRequest("a", (*requests())[0]->handle()); pool_.CancelRequest("a", (*requests())[1]->handle()); - EXPECT_EQ(0, tcp_socket_pool_.cancel_count()); + EXPECT_EQ(0, transport_socket_pool_.cancel_count()); // Requests in the connect phase don't actually get cancelled. - EXPECT_EQ(0, tcp_socket_pool_.release_count()); + EXPECT_EQ(0, transport_socket_pool_.release_count()); // Now wait for the async data to reach the SOCKS connect jobs. MessageLoop::current()->RunAllPending(); EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(1)); EXPECT_EQ(ClientSocketPoolTest::kRequestNotFound, GetOrderOfRequest(2)); - EXPECT_EQ(0, tcp_socket_pool_.cancel_count()); - EXPECT_EQ(0, tcp_socket_pool_.release_count()); + EXPECT_EQ(0, transport_socket_pool_.cancel_count()); + EXPECT_EQ(0, transport_socket_pool_.release_count()); EXPECT_EQ(2, pool_.IdleSocketCount()); (*requests())[0]->handle()->Reset(); diff --git a/net/socket/ssl_client_socket_pool.cc b/net/socket/ssl_client_socket_pool.cc index 2004286..41eb885 100644 --- a/net/socket/ssl_client_socket_pool.cc +++ b/net/socket/ssl_client_socket_pool.cc @@ -17,12 +17,12 @@ #include "net/socket/socks_client_socket_pool.h" #include "net/socket/ssl_client_socket.h" #include "net/socket/ssl_host_info.h" -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" namespace net { SSLSocketParams::SSLSocketParams( - const scoped_refptr<TCPSocketParams>& tcp_params, + const scoped_refptr<TransportSocketParams>& transport_params, const scoped_refptr<SOCKSSocketParams>& socks_params, const scoped_refptr<HttpProxySocketParams>& http_proxy_params, ProxyServer::Scheme proxy, @@ -31,7 +31,7 @@ SSLSocketParams::SSLSocketParams( int load_flags, bool force_spdy_over_ssl, bool want_spdy_over_npn) - : tcp_params_(tcp_params), + : transport_params_(transport_params), http_proxy_params_(http_proxy_params), socks_params_(socks_params), proxy_(proxy), @@ -42,21 +42,21 @@ SSLSocketParams::SSLSocketParams( want_spdy_over_npn_(want_spdy_over_npn) { switch (proxy_) { case ProxyServer::SCHEME_DIRECT: - DCHECK(tcp_params_.get() != NULL); + DCHECK(transport_params_.get() != NULL); DCHECK(http_proxy_params_.get() == NULL); DCHECK(socks_params_.get() == NULL); - ignore_limits_ = tcp_params_->ignore_limits(); + ignore_limits_ = transport_params_->ignore_limits(); break; case ProxyServer::SCHEME_HTTP: case ProxyServer::SCHEME_HTTPS: - DCHECK(tcp_params_.get() == NULL); + DCHECK(transport_params_.get() == NULL); DCHECK(http_proxy_params_.get() != NULL); DCHECK(socks_params_.get() == NULL); ignore_limits_ = http_proxy_params_->ignore_limits(); break; case ProxyServer::SCHEME_SOCKS4: case ProxyServer::SCHEME_SOCKS5: - DCHECK(tcp_params_.get() == NULL); + DCHECK(transport_params_.get() == NULL); DCHECK(http_proxy_params_.get() == NULL); DCHECK(socks_params_.get() != NULL); ignore_limits_ = socks_params_->ignore_limits(); @@ -76,7 +76,7 @@ SSLConnectJob::SSLConnectJob( const std::string& group_name, const scoped_refptr<SSLSocketParams>& params, const base::TimeDelta& timeout_duration, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SOCKSClientSocketPool* socks_pool, HttpProxyClientSocketPool* http_proxy_pool, ClientSocketFactory* client_socket_factory, @@ -90,7 +90,7 @@ SSLConnectJob::SSLConnectJob( : ConnectJob(group_name, timeout_duration, delegate, BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), params_(params), - tcp_pool_(tcp_pool), + transport_pool_(transport_pool), socks_pool_(socks_pool), http_proxy_pool_(http_proxy_pool), client_socket_factory_(client_socket_factory), @@ -110,8 +110,8 @@ LoadState SSLConnectJob::GetLoadState() const { if (transport_socket_handle_->socket()) return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL; // else, fall through. - case STATE_TCP_CONNECT: - case STATE_TCP_CONNECT_COMPLETE: + case STATE_TRANSPORT_CONNECT: + case STATE_TRANSPORT_CONNECT_COMPLETE: case STATE_SOCKS_CONNECT: case STATE_SOCKS_CONNECT_COMPLETE: case STATE_TUNNEL_CONNECT: @@ -151,12 +151,12 @@ int SSLConnectJob::DoLoop(int result) { State state = next_state_; next_state_ = STATE_NONE; switch (state) { - case STATE_TCP_CONNECT: + case STATE_TRANSPORT_CONNECT: DCHECK_EQ(OK, rv); - rv = DoTCPConnect(); + rv = DoTransportConnect(); break; - case STATE_TCP_CONNECT_COMPLETE: - rv = DoTCPConnectComplete(rv); + case STATE_TRANSPORT_CONNECT_COMPLETE: + rv = DoTransportConnectComplete(rv); break; case STATE_SOCKS_CONNECT: DCHECK_EQ(OK, rv); @@ -189,8 +189,8 @@ int SSLConnectJob::DoLoop(int result) { return rv; } -int SSLConnectJob::DoTCPConnect() { - DCHECK(tcp_pool_); +int SSLConnectJob::DoTransportConnect() { + DCHECK(transport_pool_); if (ssl_host_info_factory_) { ssl_host_info_.reset( @@ -207,15 +207,18 @@ int SSLConnectJob::DoTCPConnect() { ssl_host_info_->Start(); } - next_state_ = STATE_TCP_CONNECT_COMPLETE; + next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; transport_socket_handle_.reset(new ClientSocketHandle()); - scoped_refptr<TCPSocketParams> tcp_params = params_->tcp_params(); - return transport_socket_handle_->Init(group_name(), tcp_params, - tcp_params->destination().priority(), - &callback_, tcp_pool_, net_log()); + scoped_refptr<TransportSocketParams> transport_params = + params_->transport_params(); + return transport_socket_handle_->Init( + group_name(), + transport_params, + transport_params->destination().priority(), + &callback_, transport_pool_, net_log()); } -int SSLConnectJob::DoTCPConnectComplete(int result) { +int SSLConnectJob::DoTransportConnectComplete(int result) { if (result == OK) next_state_ = STATE_SSL_CONNECT; @@ -372,7 +375,7 @@ int SSLConnectJob::DoSSLConnectComplete(int result) { int SSLConnectJob::ConnectInternal() { switch (params_->proxy()) { case ProxyServer::SCHEME_DIRECT: - next_state_ = STATE_TCP_CONNECT; + next_state_ = STATE_TRANSPORT_CONNECT; break; case ProxyServer::SCHEME_HTTP: case ProxyServer::SCHEME_HTTPS: @@ -390,7 +393,7 @@ int SSLConnectJob::ConnectInternal() { } SSLClientSocketPool::SSLConnectJobFactory::SSLConnectJobFactory( - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SOCKSClientSocketPool* socks_pool, HttpProxyClientSocketPool* http_proxy_pool, ClientSocketFactory* client_socket_factory, @@ -400,7 +403,7 @@ SSLClientSocketPool::SSLConnectJobFactory::SSLConnectJobFactory( DnsCertProvenanceChecker* dns_cert_checker, SSLHostInfoFactory* ssl_host_info_factory, NetLog* net_log) - : tcp_pool_(tcp_pool), + : transport_pool_(transport_pool), socks_pool_(socks_pool), http_proxy_pool_(http_proxy_pool), client_socket_factory_(client_socket_factory), @@ -412,8 +415,8 @@ SSLClientSocketPool::SSLConnectJobFactory::SSLConnectJobFactory( net_log_(net_log) { base::TimeDelta max_transport_timeout = base::TimeDelta(); base::TimeDelta pool_timeout; - if (tcp_pool_) - max_transport_timeout = tcp_pool_->ConnectionTimeout(); + if (transport_pool_) + max_transport_timeout = transport_pool_->ConnectionTimeout(); if (socks_pool_) { pool_timeout = socks_pool_->ConnectionTimeout(); if (pool_timeout > max_transport_timeout) @@ -438,22 +441,27 @@ SSLClientSocketPool::SSLClientSocketPool( DnsCertProvenanceChecker* dns_cert_checker, SSLHostInfoFactory* ssl_host_info_factory, ClientSocketFactory* client_socket_factory, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SOCKSClientSocketPool* socks_pool, HttpProxyClientSocketPool* http_proxy_pool, SSLConfigService* ssl_config_service, NetLog* net_log) - : tcp_pool_(tcp_pool), + : transport_pool_(transport_pool), socks_pool_(socks_pool), http_proxy_pool_(http_proxy_pool), base_(max_sockets, max_sockets_per_group, histograms, base::TimeDelta::FromSeconds( ClientSocketPool::unused_idle_socket_timeout()), base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout), - new SSLConnectJobFactory(tcp_pool, socks_pool, http_proxy_pool, - client_socket_factory, host_resolver, - cert_verifier, dnsrr_resolver, - dns_cert_checker, ssl_host_info_factory, + new SSLConnectJobFactory(transport_pool, + socks_pool, + http_proxy_pool, + client_socket_factory, + host_resolver, + cert_verifier, + dnsrr_resolver, + dns_cert_checker, + ssl_host_info_factory, net_log)), ssl_config_service_(ssl_config_service) { if (ssl_config_service_) @@ -470,7 +478,7 @@ ConnectJob* SSLClientSocketPool::SSLConnectJobFactory::NewConnectJob( const PoolBase::Request& request, ConnectJob::Delegate* delegate) const { return new SSLConnectJob(group_name, request.params(), ConnectionTimeout(), - tcp_pool_, socks_pool_, http_proxy_pool_, + transport_pool_, socks_pool_, http_proxy_pool_, client_socket_factory_, host_resolver_, cert_verifier_, dnsrr_resolver_, dns_cert_checker_, ssl_host_info_factory_, delegate, net_log_); @@ -539,10 +547,10 @@ DictionaryValue* SSLClientSocketPool::GetInfoAsValue( DictionaryValue* dict = base_.GetInfoAsValue(name, type); if (include_nested_pools) { ListValue* list = new ListValue(); - if (tcp_pool_) { - list->Append(tcp_pool_->GetInfoAsValue("tcp_socket_pool", - "tcp_socket_pool", - false)); + if (transport_pool_) { + list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", + "transport_socket_pool", + false)); } if (socks_pool_) { list->Append(socks_pool_->GetInfoAsValue("socks_pool", diff --git a/net/socket/ssl_client_socket_pool.h b/net/socket/ssl_client_socket_pool.h index c0fbd589..5c0ecb4 100644 --- a/net/socket/ssl_client_socket_pool.h +++ b/net/socket/ssl_client_socket_pool.h @@ -34,15 +34,15 @@ class SOCKSClientSocketPool; class SOCKSSocketParams; class SSLClientSocket; class SSLHostInfoFactory; -class TCPClientSocketPool; -class TCPSocketParams; +class TransportSocketParams; +class TransportClientSocketPool; struct RRResponse; // SSLSocketParams only needs the socket params for the transport socket // that will be used (denoted by |proxy|). class SSLSocketParams : public base::RefCounted<SSLSocketParams> { public: - SSLSocketParams(const scoped_refptr<TCPSocketParams>& tcp_params, + SSLSocketParams(const scoped_refptr<TransportSocketParams>& transport_params, const scoped_refptr<SOCKSSocketParams>& socks_params, const scoped_refptr<HttpProxySocketParams>& http_proxy_params, ProxyServer::Scheme proxy, @@ -52,7 +52,9 @@ class SSLSocketParams : public base::RefCounted<SSLSocketParams> { bool force_spdy_over_ssl, bool want_spdy_over_npn); - const scoped_refptr<TCPSocketParams>& tcp_params() { return tcp_params_; } + const scoped_refptr<TransportSocketParams>& transport_params() { + return transport_params_; + } const scoped_refptr<HttpProxySocketParams>& http_proxy_params() { return http_proxy_params_; } @@ -71,7 +73,7 @@ class SSLSocketParams : public base::RefCounted<SSLSocketParams> { friend class base::RefCounted<SSLSocketParams>; ~SSLSocketParams(); - const scoped_refptr<TCPSocketParams> tcp_params_; + const scoped_refptr<TransportSocketParams> transport_params_; const scoped_refptr<HttpProxySocketParams> http_proxy_params_; const scoped_refptr<SOCKSSocketParams> socks_params_; const ProxyServer::Scheme proxy_; @@ -93,7 +95,7 @@ class SSLConnectJob : public ConnectJob { const std::string& group_name, const scoped_refptr<SSLSocketParams>& params, const base::TimeDelta& timeout_duration, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SOCKSClientSocketPool* socks_pool, HttpProxyClientSocketPool* http_proxy_pool, ClientSocketFactory* client_socket_factory, @@ -113,8 +115,8 @@ class SSLConnectJob : public ConnectJob { private: enum State { - STATE_TCP_CONNECT, - STATE_TCP_CONNECT_COMPLETE, + STATE_TRANSPORT_CONNECT, + STATE_TRANSPORT_CONNECT_COMPLETE, STATE_SOCKS_CONNECT, STATE_SOCKS_CONNECT_COMPLETE, STATE_TUNNEL_CONNECT, @@ -129,8 +131,8 @@ class SSLConnectJob : public ConnectJob { // Runs the state transition loop. int DoLoop(int result); - int DoTCPConnect(); - int DoTCPConnectComplete(int result); + int DoTransportConnect(); + int DoTransportConnectComplete(int result); int DoSOCKSConnect(); int DoSOCKSConnectComplete(int result); int DoTunnelConnect(); @@ -144,7 +146,7 @@ class SSLConnectJob : public ConnectJob { virtual int ConnectInternal(); scoped_refptr<SSLSocketParams> params_; - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; SOCKSClientSocketPool* const socks_pool_; HttpProxyClientSocketPool* const http_proxy_pool_; ClientSocketFactory* const client_socket_factory_; @@ -183,7 +185,7 @@ class SSLClientSocketPool : public ClientSocketPool, DnsCertProvenanceChecker* dns_cert_checker, SSLHostInfoFactory* ssl_host_info_factory, ClientSocketFactory* client_socket_factory, - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SOCKSClientSocketPool* socks_pool, HttpProxyClientSocketPool* http_proxy_pool, SSLConfigService* ssl_config_service, @@ -242,7 +244,7 @@ class SSLClientSocketPool : public ClientSocketPool, class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { public: SSLConnectJobFactory( - TCPClientSocketPool* tcp_pool, + TransportClientSocketPool* transport_pool, SOCKSClientSocketPool* socks_pool, HttpProxyClientSocketPool* http_proxy_pool, ClientSocketFactory* client_socket_factory, @@ -264,7 +266,7 @@ class SSLClientSocketPool : public ClientSocketPool, virtual base::TimeDelta ConnectionTimeout() const { return timeout_; } private: - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; SOCKSClientSocketPool* const socks_pool_; HttpProxyClientSocketPool* const http_proxy_pool_; ClientSocketFactory* const client_socket_factory_; @@ -279,7 +281,7 @@ class SSLClientSocketPool : public ClientSocketPool, DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); }; - TCPClientSocketPool* const tcp_pool_; + TransportClientSocketPool* const transport_pool_; SOCKSClientSocketPool* const socks_pool_; HttpProxyClientSocketPool* const http_proxy_pool_; PoolBase base_; diff --git a/net/socket/ssl_client_socket_pool_unittest.cc b/net/socket/ssl_client_socket_pool_unittest.cc index e5dc2d5..b416274 100644 --- a/net/socket/ssl_client_socket_pool_unittest.cc +++ b/net/socket/ssl_client_socket_pool_unittest.cc @@ -43,27 +43,27 @@ class SSLClientSocketPoolTest : public testing::Test { http_auth_handler_factory_(HttpAuthHandlerFactory::CreateDefault( &host_resolver_)), session_(CreateNetworkSession()), - direct_tcp_socket_params_(new TCPSocketParams( + direct_transport_socket_params_(new TransportSocketParams( HostPortPair("host", 443), MEDIUM, GURL(), false, false)), - tcp_histograms_("MockTCP"), - tcp_socket_pool_( + transport_histograms_("MockTCP"), + transport_socket_pool_( kMaxSockets, kMaxSocketsPerGroup, - &tcp_histograms_, + &transport_histograms_, &socket_factory_), - proxy_tcp_socket_params_(new TCPSocketParams( + proxy_transport_socket_params_(new TransportSocketParams( HostPortPair("proxy", 443), MEDIUM, GURL(), false, false)), socks_socket_params_(new SOCKSSocketParams( - proxy_tcp_socket_params_, true, HostPortPair("sockshost", 443), - MEDIUM, GURL())), + proxy_transport_socket_params_, true, + HostPortPair("sockshost", 443), MEDIUM, GURL())), socks_histograms_("MockSOCKS"), socks_socket_pool_( kMaxSockets, kMaxSocketsPerGroup, &socks_histograms_, - &tcp_socket_pool_), + &transport_socket_pool_), http_proxy_socket_params_(new HttpProxySocketParams( - proxy_tcp_socket_params_, NULL, GURL("http://host"), "", + proxy_transport_socket_params_, NULL, GURL("http://host"), "", HostPortPair("host", 80), session_->http_auth_cache(), session_->http_auth_handler_factory(), @@ -75,7 +75,7 @@ class SSLClientSocketPoolTest : public testing::Test { kMaxSocketsPerGroup, &http_proxy_histograms_, &host_resolver_, - &tcp_socket_pool_, + &transport_socket_pool_, NULL, NULL) { scoped_refptr<SSLConfigService> ssl_config_service( @@ -83,7 +83,7 @@ class SSLClientSocketPoolTest : public testing::Test { ssl_config_service->GetSSLConfig(&ssl_config_); } - void CreatePool(bool tcp_pool, bool http_proxy_pool, bool socks_pool) { + void CreatePool(bool transport_pool, bool http_proxy_pool, bool socks_pool) { ssl_histograms_.reset(new ClientSocketPoolHistograms("SSLUnitTest")); pool_.reset(new SSLClientSocketPool( kMaxSockets, @@ -95,7 +95,7 @@ class SSLClientSocketPoolTest : public testing::Test { NULL /* dns_cert_checker */, NULL /* ssl_host_info_factory */, &socket_factory_, - tcp_pool ? &tcp_socket_pool_ : NULL, + transport_pool ? &transport_socket_pool_ : NULL, socks_pool ? &socks_socket_pool_ : NULL, http_proxy_pool ? &http_proxy_socket_pool_ : NULL, NULL, @@ -105,7 +105,8 @@ class SSLClientSocketPoolTest : public testing::Test { scoped_refptr<SSLSocketParams> SSLParams(ProxyServer::Scheme proxy, bool want_spdy_over_npn) { return make_scoped_refptr(new SSLSocketParams( - proxy == ProxyServer::SCHEME_DIRECT ? direct_tcp_socket_params_ : NULL, + proxy == ProxyServer::SCHEME_DIRECT ? + direct_transport_socket_params_ : NULL, proxy == ProxyServer::SCHEME_SOCKS5 ? socks_socket_params_ : NULL, proxy == ProxyServer::SCHEME_HTTP ? http_proxy_socket_params_ : NULL, proxy, @@ -147,11 +148,11 @@ class SSLClientSocketPoolTest : public testing::Test { const scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; const scoped_refptr<HttpNetworkSession> session_; - scoped_refptr<TCPSocketParams> direct_tcp_socket_params_; - ClientSocketPoolHistograms tcp_histograms_; - MockTCPClientSocketPool tcp_socket_pool_; + scoped_refptr<TransportSocketParams> direct_transport_socket_params_; + ClientSocketPoolHistograms transport_histograms_; + MockTransportClientSocketPool transport_socket_pool_; - scoped_refptr<TCPSocketParams> proxy_tcp_socket_params_; + scoped_refptr<TransportSocketParams> proxy_transport_socket_params_; scoped_refptr<SOCKSSocketParams> socks_socket_params_; ClientSocketPoolHistograms socks_histograms_; diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc index fa6e2ef..54a817d 100644 --- a/net/socket/tcp_client_socket_pool.cc +++ b/net/socket/transport_client_socket_pool.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" #include "base/compiler_specific.h" #include "base/logging.h" @@ -21,7 +21,7 @@ using base::TimeDelta; namespace net { -TCPSocketParams::TCPSocketParams(const HostPortPair& host_port_pair, +TransportSocketParams::TransportSocketParams(const HostPortPair& host_port_pair, RequestPriority priority, const GURL& referrer, bool disable_resolver_cache, bool ignore_limits) @@ -29,9 +29,9 @@ TCPSocketParams::TCPSocketParams(const HostPortPair& host_port_pair, Initialize(priority, referrer, disable_resolver_cache); } -TCPSocketParams::~TCPSocketParams() {} +TransportSocketParams::~TransportSocketParams() {} -void TCPSocketParams::Initialize(RequestPriority priority, +void TransportSocketParams::Initialize(RequestPriority priority, const GURL& referrer, bool disable_resolver_cache) { // The referrer is used by the DNS prefetch system to correlate resolutions @@ -43,8 +43,8 @@ void TCPSocketParams::Initialize(RequestPriority priority, destination_.set_allow_cached_response(false); } -// TCPConnectJobs will time out after this many seconds. Note this is the total -// time, including both host resolution and TCP connect() times. +// TransportConnectJobs will time out after this many seconds. Note this is +// the total time, including both host resolution and TCP connect() times. // // TODO(eroman): The use of this constant needs to be re-evaluated. The time // needed for TCPClientSocketXXX::Connect() can be arbitrarily long, since @@ -52,11 +52,11 @@ void TCPSocketParams::Initialize(RequestPriority priority, // timeout. Even worse, the per-connect timeout threshold varies greatly // between systems (anywhere from 20 seconds to 190 seconds). // See comment #12 at http://crbug.com/23364 for specifics. -static const int kTCPConnectJobTimeoutInSeconds = 240; // 4 minutes. +static const int kTransportConnectJobTimeoutInSeconds = 240; // 4 minutes. -TCPConnectJob::TCPConnectJob( +TransportConnectJob::TransportConnectJob( const std::string& group_name, - const scoped_refptr<TCPSocketParams>& params, + const scoped_refptr<TransportSocketParams>& params, base::TimeDelta timeout_duration, ClientSocketFactory* client_socket_factory, HostResolver* host_resolver, @@ -68,21 +68,21 @@ TCPConnectJob::TCPConnectJob( client_socket_factory_(client_socket_factory), ALLOW_THIS_IN_INITIALIZER_LIST( callback_(this, - &TCPConnectJob::OnIOComplete)), + &TransportConnectJob::OnIOComplete)), resolver_(host_resolver) {} -TCPConnectJob::~TCPConnectJob() { +TransportConnectJob::~TransportConnectJob() { // We don't worry about cancelling the host resolution and TCP connect, since // ~SingleRequestHostResolver and ~ClientSocket will take care of it. } -LoadState TCPConnectJob::GetLoadState() const { +LoadState TransportConnectJob::GetLoadState() const { switch (next_state_) { case STATE_RESOLVE_HOST: case STATE_RESOLVE_HOST_COMPLETE: return LOAD_STATE_RESOLVING_HOST; - case STATE_TCP_CONNECT: - case STATE_TCP_CONNECT_COMPLETE: + case STATE_TRANSPORT_CONNECT: + case STATE_TRANSPORT_CONNECT_COMPLETE: return LOAD_STATE_CONNECTING; default: NOTREACHED(); @@ -90,13 +90,13 @@ LoadState TCPConnectJob::GetLoadState() const { } } -void TCPConnectJob::OnIOComplete(int result) { +void TransportConnectJob::OnIOComplete(int result) { int rv = DoLoop(result); if (rv != ERR_IO_PENDING) NotifyDelegateOfCompletion(rv); // Deletes |this| } -int TCPConnectJob::DoLoop(int result) { +int TransportConnectJob::DoLoop(int result) { DCHECK_NE(next_state_, STATE_NONE); int rv = result; @@ -111,12 +111,12 @@ int TCPConnectJob::DoLoop(int result) { case STATE_RESOLVE_HOST_COMPLETE: rv = DoResolveHostComplete(rv); break; - case STATE_TCP_CONNECT: + case STATE_TRANSPORT_CONNECT: DCHECK_EQ(OK, rv); - rv = DoTCPConnect(); + rv = DoTransportConnect(); break; - case STATE_TCP_CONNECT_COMPLETE: - rv = DoTCPConnectComplete(rv); + case STATE_TRANSPORT_CONNECT_COMPLETE: + rv = DoTransportConnectComplete(rv); break; default: NOTREACHED(); @@ -128,27 +128,27 @@ int TCPConnectJob::DoLoop(int result) { return rv; } -int TCPConnectJob::DoResolveHost() { +int TransportConnectJob::DoResolveHost() { next_state_ = STATE_RESOLVE_HOST_COMPLETE; return resolver_.Resolve(params_->destination(), &addresses_, &callback_, net_log()); } -int TCPConnectJob::DoResolveHostComplete(int result) { +int TransportConnectJob::DoResolveHostComplete(int result) { if (result == OK) - next_state_ = STATE_TCP_CONNECT; + next_state_ = STATE_TRANSPORT_CONNECT; return result; } -int TCPConnectJob::DoTCPConnect() { - next_state_ = STATE_TCP_CONNECT_COMPLETE; - set_socket(client_socket_factory_->CreateTCPClientSocket( +int TransportConnectJob::DoTransportConnect() { + next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; + set_socket(client_socket_factory_->CreateTransportClientSocket( addresses_, net_log().net_log(), net_log().source())); connect_start_time_ = base::TimeTicks::Now(); return socket()->Connect(&callback_); } -int TCPConnectJob::DoTCPConnectComplete(int result) { +int TransportConnectJob::DoTransportConnectComplete(int result) { if (result == OK) { DCHECK(connect_start_time_ != base::TimeTicks()); DCHECK(start_time_ != base::TimeTicks()); @@ -175,27 +175,33 @@ int TCPConnectJob::DoTCPConnectComplete(int result) { return result; } -int TCPConnectJob::ConnectInternal() { +int TransportConnectJob::ConnectInternal() { next_state_ = STATE_RESOLVE_HOST; start_time_ = base::TimeTicks::Now(); return DoLoop(OK); } -ConnectJob* TCPClientSocketPool::TCPConnectJobFactory::NewConnectJob( +ConnectJob* + TransportClientSocketPool::TransportConnectJobFactory::NewConnectJob( const std::string& group_name, const PoolBase::Request& request, ConnectJob::Delegate* delegate) const { - return new TCPConnectJob(group_name, request.params(), ConnectionTimeout(), - client_socket_factory_, host_resolver_, delegate, - net_log_); + return new TransportConnectJob(group_name, + request.params(), + ConnectionTimeout(), + client_socket_factory_, + host_resolver_, + delegate, + net_log_); } base::TimeDelta - TCPClientSocketPool::TCPConnectJobFactory::ConnectionTimeout() const { - return base::TimeDelta::FromSeconds(kTCPConnectJobTimeoutInSeconds); + TransportClientSocketPool::TransportConnectJobFactory::ConnectionTimeout() + const { + return base::TimeDelta::FromSeconds(kTransportConnectJobTimeoutInSeconds); } -TCPClientSocketPool::TCPClientSocketPool( +TransportClientSocketPool::TransportClientSocketPool( int max_sockets, int max_sockets_per_group, ClientSocketPoolHistograms* histograms, @@ -206,22 +212,22 @@ TCPClientSocketPool::TCPClientSocketPool( base::TimeDelta::FromSeconds( ClientSocketPool::unused_idle_socket_timeout()), base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout), - new TCPConnectJobFactory(client_socket_factory, + new TransportConnectJobFactory(client_socket_factory, host_resolver, net_log)) { base_.EnableConnectBackupJobs(); } -TCPClientSocketPool::~TCPClientSocketPool() {} +TransportClientSocketPool::~TransportClientSocketPool() {} -int TCPClientSocketPool::RequestSocket( +int TransportClientSocketPool::RequestSocket( const std::string& group_name, const void* params, RequestPriority priority, ClientSocketHandle* handle, CompletionCallback* callback, const BoundNetLog& net_log) { - const scoped_refptr<TCPSocketParams>* casted_params = - static_cast<const scoped_refptr<TCPSocketParams>*>(params); + const scoped_refptr<TransportSocketParams>* casted_params = + static_cast<const scoped_refptr<TransportSocketParams>*>(params); if (net_log.IsLoggingAllEvents()) { // TODO(eroman): Split out the host and port parameters. @@ -236,13 +242,13 @@ int TCPClientSocketPool::RequestSocket( callback, net_log); } -void TCPClientSocketPool::RequestSockets( +void TransportClientSocketPool::RequestSockets( const std::string& group_name, const void* params, int num_sockets, const BoundNetLog& net_log) { - const scoped_refptr<TCPSocketParams>* casted_params = - static_cast<const scoped_refptr<TCPSocketParams>*>(params); + const scoped_refptr<TransportSocketParams>* casted_params = + static_cast<const scoped_refptr<TransportSocketParams>*>(params); if (net_log.IsLoggingAllEvents()) { // TODO(eroman): Split out the host and port parameters. @@ -256,53 +262,53 @@ void TCPClientSocketPool::RequestSockets( base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); } -void TCPClientSocketPool::CancelRequest( +void TransportClientSocketPool::CancelRequest( const std::string& group_name, ClientSocketHandle* handle) { base_.CancelRequest(group_name, handle); } -void TCPClientSocketPool::ReleaseSocket( +void TransportClientSocketPool::ReleaseSocket( const std::string& group_name, ClientSocket* socket, int id) { base_.ReleaseSocket(group_name, socket, id); } -void TCPClientSocketPool::Flush() { +void TransportClientSocketPool::Flush() { base_.Flush(); } -void TCPClientSocketPool::CloseIdleSockets() { +void TransportClientSocketPool::CloseIdleSockets() { base_.CloseIdleSockets(); } -int TCPClientSocketPool::IdleSocketCount() const { +int TransportClientSocketPool::IdleSocketCount() const { return base_.idle_socket_count(); } -int TCPClientSocketPool::IdleSocketCountInGroup( +int TransportClientSocketPool::IdleSocketCountInGroup( const std::string& group_name) const { return base_.IdleSocketCountInGroup(group_name); } -LoadState TCPClientSocketPool::GetLoadState( +LoadState TransportClientSocketPool::GetLoadState( const std::string& group_name, const ClientSocketHandle* handle) const { return base_.GetLoadState(group_name, handle); } -DictionaryValue* TCPClientSocketPool::GetInfoAsValue( +DictionaryValue* TransportClientSocketPool::GetInfoAsValue( const std::string& name, const std::string& type, bool include_nested_pools) const { return base_.GetInfoAsValue(name, type); } -base::TimeDelta TCPClientSocketPool::ConnectionTimeout() const { +base::TimeDelta TransportClientSocketPool::ConnectionTimeout() const { return base_.ConnectionTimeout(); } -ClientSocketPoolHistograms* TCPClientSocketPool::histograms() const { +ClientSocketPoolHistograms* TransportClientSocketPool::histograms() const { return base_.histograms(); } diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/transport_client_socket_pool.h index d07ea60..1661ed6 100644 --- a/net/socket/tcp_client_socket_pool.h +++ b/net/socket/transport_client_socket_pool.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ -#define NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ +#ifndef NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ +#define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ #pragma once #include <string> @@ -23,18 +23,20 @@ namespace net { class ClientSocketFactory; -class TCPSocketParams : public base::RefCounted<TCPSocketParams> { +class TransportSocketParams : public base::RefCounted<TransportSocketParams> { public: - TCPSocketParams(const HostPortPair& host_port_pair, RequestPriority priority, - const GURL& referrer, bool disable_resolver_cache, - bool ignore_limits); + TransportSocketParams(const HostPortPair& host_port_pair, + RequestPriority priority, + const GURL& referrer, + bool disable_resolver_cache, + bool ignore_limits); const HostResolver::RequestInfo& destination() const { return destination_; } bool ignore_limits() const { return ignore_limits_; } private: - friend class base::RefCounted<TCPSocketParams>; - ~TCPSocketParams(); + friend class base::RefCounted<TransportSocketParams>; + ~TransportSocketParams(); void Initialize(RequestPriority priority, const GURL& referrer, bool disable_resolver_cache); @@ -42,21 +44,21 @@ class TCPSocketParams : public base::RefCounted<TCPSocketParams> { HostResolver::RequestInfo destination_; bool ignore_limits_; - DISALLOW_COPY_AND_ASSIGN(TCPSocketParams); + DISALLOW_COPY_AND_ASSIGN(TransportSocketParams); }; -// TCPConnectJob handles the host resolution necessary for socket creation -// and the tcp connect. -class TCPConnectJob : public ConnectJob { +// TransportConnectJob handles the host resolution necessary for socket creation +// and the transport (likely TCP) connect. +class TransportConnectJob : public ConnectJob { public: - TCPConnectJob(const std::string& group_name, - const scoped_refptr<TCPSocketParams>& params, + TransportConnectJob(const std::string& group_name, + const scoped_refptr<TransportSocketParams>& params, base::TimeDelta timeout_duration, ClientSocketFactory* client_socket_factory, HostResolver* host_resolver, Delegate* delegate, NetLog* net_log); - virtual ~TCPConnectJob(); + virtual ~TransportConnectJob(); // ConnectJob methods. virtual LoadState GetLoadState() const; @@ -65,8 +67,8 @@ class TCPConnectJob : public ConnectJob { enum State { STATE_RESOLVE_HOST, STATE_RESOLVE_HOST_COMPLETE, - STATE_TCP_CONNECT, - STATE_TCP_CONNECT_COMPLETE, + STATE_TRANSPORT_CONNECT, + STATE_TRANSPORT_CONNECT_COMPLETE, STATE_NONE, }; @@ -77,17 +79,17 @@ class TCPConnectJob : public ConnectJob { int DoResolveHost(); int DoResolveHostComplete(int result); - int DoTCPConnect(); - int DoTCPConnectComplete(int result); + int DoTransportConnect(); + int DoTransportConnectComplete(int result); // Begins the host resolution and the TCP connect. Returns OK on success // and ERR_IO_PENDING if it cannot immediately service the request. // Otherwise, it returns a net error code. virtual int ConnectInternal(); - scoped_refptr<TCPSocketParams> params_; + scoped_refptr<TransportSocketParams> params_; ClientSocketFactory* const client_socket_factory_; - CompletionCallbackImpl<TCPConnectJob> callback_; + CompletionCallbackImpl<TransportConnectJob> callback_; SingleRequestHostResolver resolver_; AddressList addresses_; State next_state_; @@ -98,12 +100,12 @@ class TCPConnectJob : public ConnectJob { // The time the connect was started (after DNS finished). base::TimeTicks connect_start_time_; - DISALLOW_COPY_AND_ASSIGN(TCPConnectJob); + DISALLOW_COPY_AND_ASSIGN(TransportConnectJob); }; -class TCPClientSocketPool : public ClientSocketPool { +class TransportClientSocketPool : public ClientSocketPool { public: - TCPClientSocketPool( + TransportClientSocketPool( int max_sockets, int max_sockets_per_group, ClientSocketPoolHistograms* histograms, @@ -111,7 +113,7 @@ class TCPClientSocketPool : public ClientSocketPool { ClientSocketFactory* client_socket_factory, NetLog* net_log); - virtual ~TCPClientSocketPool(); + virtual ~TransportClientSocketPool(); // ClientSocketPool methods: @@ -154,19 +156,19 @@ class TCPClientSocketPool : public ClientSocketPool { virtual ClientSocketPoolHistograms* histograms() const; private: - typedef ClientSocketPoolBase<TCPSocketParams> PoolBase; + typedef ClientSocketPoolBase<TransportSocketParams> PoolBase; - class TCPConnectJobFactory + class TransportConnectJobFactory : public PoolBase::ConnectJobFactory { public: - TCPConnectJobFactory(ClientSocketFactory* client_socket_factory, + TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, HostResolver* host_resolver, NetLog* net_log) : client_socket_factory_(client_socket_factory), host_resolver_(host_resolver), net_log_(net_log) {} - virtual ~TCPConnectJobFactory() {} + virtual ~TransportConnectJobFactory() {} // ClientSocketPoolBase::ConnectJobFactory methods. @@ -182,16 +184,17 @@ class TCPClientSocketPool : public ClientSocketPool { HostResolver* const host_resolver_; NetLog* net_log_; - DISALLOW_COPY_AND_ASSIGN(TCPConnectJobFactory); + DISALLOW_COPY_AND_ASSIGN(TransportConnectJobFactory); }; PoolBase base_; - DISALLOW_COPY_AND_ASSIGN(TCPClientSocketPool); + DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool); }; -REGISTER_SOCKET_PARAMS_FOR_POOL(TCPClientSocketPool, TCPSocketParams); +REGISTER_SOCKET_PARAMS_FOR_POOL(TransportClientSocketPool, + TransportSocketParams); } // namespace net -#endif // NET_SOCKET_TCP_CLIENT_SOCKET_POOL_H_ +#endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc index 18314e3..37dae93 100644 --- a/net/socket/tcp_client_socket_pool_unittest.cc +++ b/net/socket/transport_client_socket_pool_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "net/socket/tcp_client_socket_pool.h" +#include "net/socket/transport_client_socket_pool.h" #include "base/callback.h" #include "base/compiler_specific.h" @@ -215,7 +215,7 @@ class MockClientSocketFactory : public ClientSocketFactory { client_socket_types_(NULL), client_socket_index_(0), client_socket_index_max_(0) {} - virtual ClientSocket* CreateTCPClientSocket( + virtual ClientSocket* CreateTransportClientSocket( const AddressList& addresses, NetLog* /* net_log */, const NetLog::Source& /* source */) { @@ -286,13 +286,15 @@ class MockClientSocketFactory : public ClientSocketFactory { int client_socket_index_max_; }; -class TCPClientSocketPoolTest : public testing::Test { +class TransportClientSocketPoolTest : public testing::Test { protected: - TCPClientSocketPoolTest() - : params_(new TCPSocketParams(HostPortPair("www.google.com", 80), - kDefaultPriority, GURL(), false, false)), - low_params_(new TCPSocketParams(HostPortPair("www.google.com", 80), - LOW, GURL(), false, false)), + TransportClientSocketPoolTest() + : params_( + new TransportSocketParams(HostPortPair("www.google.com", 80), + kDefaultPriority, GURL(), false, false)), + low_params_( + new TransportSocketParams(HostPortPair("www.google.com", 80), + LOW, GURL(), false, false)), histograms_(new ClientSocketPoolHistograms("TCPUnitTest")), host_resolver_(new MockHostResolver), pool_(kMaxSockets, @@ -304,7 +306,7 @@ class TCPClientSocketPoolTest : public testing::Test { } int StartRequest(const std::string& group_name, RequestPriority priority) { - scoped_refptr<TCPSocketParams> params(new TCPSocketParams( + scoped_refptr<TransportSocketParams> params(new TransportSocketParams( HostPortPair("www.google.com", 80), MEDIUM, GURL(), false, false)); return test_base_.StartRequestUsingPool( &pool_, group_name, priority, params); @@ -325,16 +327,16 @@ class TCPClientSocketPoolTest : public testing::Test { ScopedVector<TestSocketRequest>* requests() { return test_base_.requests(); } size_t completion_count() const { return test_base_.completion_count(); } - scoped_refptr<TCPSocketParams> params_; - scoped_refptr<TCPSocketParams> low_params_; + scoped_refptr<TransportSocketParams> params_; + scoped_refptr<TransportSocketParams> low_params_; scoped_ptr<ClientSocketPoolHistograms> histograms_; scoped_ptr<MockHostResolver> host_resolver_; MockClientSocketFactory client_socket_factory_; - TCPClientSocketPool pool_; + TransportClientSocketPool pool_; ClientSocketPoolTest test_base_; }; -TEST_F(TCPClientSocketPoolTest, Basic) { +TEST_F(TransportClientSocketPoolTest, Basic) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = handle.Init("a", low_params_, LOW, &callback, &pool_, BoundNetLog()); @@ -349,12 +351,12 @@ TEST_F(TCPClientSocketPoolTest, Basic) { handle.Reset(); } -TEST_F(TCPClientSocketPoolTest, InitHostResolutionFailure) { +TEST_F(TransportClientSocketPoolTest, InitHostResolutionFailure) { host_resolver_->rules()->AddSimulatedFailure("unresolvable.host.name"); TestCompletionCallback callback; ClientSocketHandle handle; HostPortPair host_port_pair("unresolvable.host.name", 80); - scoped_refptr<TCPSocketParams> dest(new TCPSocketParams( + scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( host_port_pair, kDefaultPriority, GURL(), false, false)); EXPECT_EQ(ERR_IO_PENDING, handle.Init("a", dest, kDefaultPriority, &callback, &pool_, @@ -362,7 +364,7 @@ TEST_F(TCPClientSocketPoolTest, InitHostResolutionFailure) { EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback.WaitForResult()); } -TEST_F(TCPClientSocketPoolTest, InitConnectionFailure) { +TEST_F(TransportClientSocketPoolTest, InitConnectionFailure) { client_socket_factory_.set_client_socket_type( MockClientSocketFactory::MOCK_FAILING_CLIENT_SOCKET); TestCompletionCallback callback; @@ -378,7 +380,7 @@ TEST_F(TCPClientSocketPoolTest, InitConnectionFailure) { &pool_, BoundNetLog())); } -TEST_F(TCPClientSocketPoolTest, PendingRequests) { +TEST_F(TransportClientSocketPoolTest, PendingRequests) { // First request finishes asynchronously. EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); EXPECT_EQ(OK, (*requests())[0]->WaitForResult()); @@ -436,7 +438,7 @@ TEST_F(TCPClientSocketPoolTest, PendingRequests) { EXPECT_EQ(ClientSocketPoolTest::kIndexOutOfBounds, GetOrderOfRequest(17)); } -TEST_F(TCPClientSocketPoolTest, PendingRequests_NoKeepAlive) { +TEST_F(TransportClientSocketPoolTest, PendingRequests_NoKeepAlive) { // First request finishes asynchronously. EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); EXPECT_EQ(OK, (*requests())[0]->WaitForResult()); @@ -477,7 +479,7 @@ TEST_F(TCPClientSocketPoolTest, PendingRequests_NoKeepAlive) { // This test will start up a RequestSocket() and then immediately Cancel() it. // The pending host resolution will eventually complete, and destroy the // ClientSocketPool which will crash if the group was not cleared properly. -TEST_F(TCPClientSocketPoolTest, CancelRequestClearGroup) { +TEST_F(TransportClientSocketPoolTest, CancelRequestClearGroup) { TestCompletionCallback callback; ClientSocketHandle handle; EXPECT_EQ(ERR_IO_PENDING, handle.Init("a", params_, kDefaultPriority, @@ -485,7 +487,7 @@ TEST_F(TCPClientSocketPoolTest, CancelRequestClearGroup) { handle.Reset(); } -TEST_F(TCPClientSocketPoolTest, TwoRequestsCancelOne) { +TEST_F(TransportClientSocketPoolTest, TwoRequestsCancelOne) { ClientSocketHandle handle; TestCompletionCallback callback; ClientSocketHandle handle2; @@ -502,7 +504,7 @@ TEST_F(TCPClientSocketPoolTest, TwoRequestsCancelOne) { handle2.Reset(); } -TEST_F(TCPClientSocketPoolTest, ConnectCancelConnect) { +TEST_F(TransportClientSocketPoolTest, ConnectCancelConnect) { client_socket_factory_.set_client_socket_type( MockClientSocketFactory::MOCK_PENDING_CLIENT_SOCKET); ClientSocketHandle handle; @@ -532,7 +534,7 @@ TEST_F(TCPClientSocketPoolTest, ConnectCancelConnect) { handle.Reset(); } -TEST_F(TCPClientSocketPoolTest, CancelRequest) { +TEST_F(TransportClientSocketPoolTest, CancelRequest) { // First request finishes asynchronously. EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", kDefaultPriority)); EXPECT_EQ(OK, (*requests())[0]->WaitForResult()); @@ -593,7 +595,8 @@ TEST_F(TCPClientSocketPoolTest, CancelRequest) { class RequestSocketCallback : public CallbackRunner< Tuple1<int> > { public: - RequestSocketCallback(ClientSocketHandle* handle, TCPClientSocketPool* pool) + RequestSocketCallback(ClientSocketHandle* handle, + TransportClientSocketPool* pool) : handle_(handle), pool_(pool), within_callback_(false) {} @@ -613,7 +616,7 @@ class RequestSocketCallback : public CallbackRunner< Tuple1<int> > { MessageLoop::current()->RunAllPending(); } within_callback_ = true; - scoped_refptr<TCPSocketParams> dest(new TCPSocketParams( + scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( HostPortPair("www.google.com", 80), LOWEST, GURL(), false, false)); int rv = handle_->Init("a", dest, LOWEST, this, pool_, BoundNetLog()); EXPECT_EQ(OK, rv); @@ -626,15 +629,15 @@ class RequestSocketCallback : public CallbackRunner< Tuple1<int> > { private: ClientSocketHandle* const handle_; - TCPClientSocketPool* const pool_; + TransportClientSocketPool* const pool_; bool within_callback_; TestCompletionCallback callback_; }; -TEST_F(TCPClientSocketPoolTest, RequestTwice) { +TEST_F(TransportClientSocketPoolTest, RequestTwice) { ClientSocketHandle handle; RequestSocketCallback callback(&handle, &pool_); - scoped_refptr<TCPSocketParams> dest(new TCPSocketParams( + scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( HostPortPair("www.google.com", 80), LOWEST, GURL(), false, false)); int rv = handle.Init("a", dest, LOWEST, &callback, &pool_, BoundNetLog()); @@ -651,7 +654,7 @@ TEST_F(TCPClientSocketPoolTest, RequestTwice) { // Make sure that pending requests get serviced after active requests get // cancelled. -TEST_F(TCPClientSocketPoolTest, CancelActiveRequestWithPendingRequests) { +TEST_F(TransportClientSocketPoolTest, CancelActiveRequestWithPendingRequests) { client_socket_factory_.set_client_socket_type( MockClientSocketFactory::MOCK_PENDING_CLIENT_SOCKET); @@ -681,7 +684,7 @@ TEST_F(TCPClientSocketPoolTest, CancelActiveRequestWithPendingRequests) { } // Make sure that pending requests get serviced after active requests fail. -TEST_F(TCPClientSocketPoolTest, FailingActiveRequestWithPendingRequests) { +TEST_F(TransportClientSocketPoolTest, FailingActiveRequestWithPendingRequests) { client_socket_factory_.set_client_socket_type( MockClientSocketFactory::MOCK_PENDING_FAILING_CLIENT_SOCKET); @@ -696,7 +699,7 @@ TEST_F(TCPClientSocketPoolTest, FailingActiveRequestWithPendingRequests) { EXPECT_EQ(ERR_CONNECTION_FAILED, (*requests())[i]->WaitForResult()); } -TEST_F(TCPClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) { +TEST_F(TransportClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = handle.Init("a", low_params_, LOW, &callback, &pool_, BoundNetLog()); @@ -723,7 +726,7 @@ TEST_F(TCPClientSocketPoolTest, ResetIdleSocketsOnIPAddressChange) { EXPECT_EQ(0, pool_.IdleSocketCount()); } -TEST_F(TCPClientSocketPoolTest, BackupSocketConnect) { +TEST_F(TransportClientSocketPoolTest, BackupSocketConnect) { // Case 1 tests the first socket stalling, and the backup connecting. MockClientSocketFactory::ClientSocketType case1_types[] = { // The first socket will not connect. @@ -785,7 +788,7 @@ TEST_F(TCPClientSocketPoolTest, BackupSocketConnect) { // Test the case where a socket took long enough to start the creation // of the backup socket, but then we cancelled the request after that. -TEST_F(TCPClientSocketPoolTest, BackupSocketCancel) { +TEST_F(TransportClientSocketPoolTest, BackupSocketCancel) { client_socket_factory_.set_client_socket_type( MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET); @@ -827,7 +830,7 @@ TEST_F(TCPClientSocketPoolTest, BackupSocketCancel) { // Test the case where a socket took long enough to start the creation // of the backup socket and never completes, and then the backup // connection fails. -TEST_F(TCPClientSocketPoolTest, BackupSocketFailAfterStall) { +TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterStall) { MockClientSocketFactory::ClientSocketType case_types[] = { // The first socket will not connect. MockClientSocketFactory::MOCK_STALLED_CLIENT_SOCKET, @@ -872,7 +875,7 @@ TEST_F(TCPClientSocketPoolTest, BackupSocketFailAfterStall) { // Test the case where a socket took long enough to start the creation // of the backup socket and eventually completes, but the backup socket // fails. -TEST_F(TCPClientSocketPoolTest, BackupSocketFailAfterDelay) { +TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterDelay) { MockClientSocketFactory::ClientSocketType case_types[] = { // The first socket will connect, although delayed. MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET, diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc index 0a36525..f1f05b0 100644 --- a/net/socket_stream/socket_stream.cc +++ b/net/socket_stream/socket_stream.cc @@ -555,9 +555,9 @@ int SocketStream::DoTcpConnect(int result) { } next_state_ = STATE_TCP_CONNECT_COMPLETE; DCHECK(factory_); - socket_.reset(factory_->CreateTCPClientSocket(addresses_, - net_log_.net_log(), - net_log_.source())); + socket_.reset(factory_->CreateTransportClientSocket(addresses_, + net_log_.net_log(), + net_log_.source())); metrics_->OnStartConnection(); return socket_->Connect(&io_callback_); } diff --git a/net/spdy/spdy_http_stream_unittest.cc b/net/spdy/spdy_http_stream_unittest.cc index 48360fe..9054e2b 100644 --- a/net/spdy/spdy_http_stream_unittest.cc +++ b/net/spdy/spdy_http_stream_unittest.cc @@ -30,13 +30,16 @@ class SpdyHttpStreamTest : public testing::Test { session_deps_.socket_factory->AddSocketDataProvider(data_.get()); http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); - tcp_params_ = new TCPSocketParams(host_port_pair, + transport_params_ = new TransportSocketParams(host_port_pair, MEDIUM, GURL(), false, false); TestCompletionCallback callback; scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(ERR_IO_PENDING, - connection->Init(host_port_pair.ToString(), tcp_params_, MEDIUM, - &callback, http_session_->tcp_socket_pool(), + connection->Init(host_port_pair.ToString(), + transport_params_, + MEDIUM, + &callback, + http_session_->transport_socket_pool(), BoundNetLog())); EXPECT_EQ(OK, callback.WaitForResult()); return session_->InitializeWithSocket(connection.release(), false, OK); @@ -45,7 +48,7 @@ class SpdyHttpStreamTest : public testing::Test { scoped_refptr<OrderedSocketData> data_; scoped_refptr<HttpNetworkSession> http_session_; scoped_refptr<SpdySession> session_; - scoped_refptr<TCPSocketParams> tcp_params_; + scoped_refptr<TransportSocketParams> transport_params_; }; TEST_F(SpdyHttpStreamTest, SendRequest) { diff --git a/net/spdy/spdy_proxy_client_socket_unittest.cc b/net/spdy/spdy_proxy_client_socket_unittest.cc index 33fc667..5b540a9 100644 --- a/net/spdy/spdy_proxy_client_socket_unittest.cc +++ b/net/spdy/spdy_proxy_client_socket_unittest.cc @@ -119,7 +119,7 @@ class SpdyProxyClientSocketTest : public PlatformTest { HostPortPair endpoint_host_port_pair_; ProxyServer proxy_; HostPortProxyPair endpoint_host_port_proxy_pair_; - scoped_refptr<TCPSocketParams> tcp_params_; + scoped_refptr<TransportSocketParams> transport_params_; DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocketTest); }; @@ -142,8 +142,11 @@ SpdyProxyClientSocketTest::SpdyProxyClientSocketTest() endpoint_host_port_pair_(kOriginHost, kOriginPort), proxy_(ProxyServer::SCHEME_HTTPS, proxy_host_port_), endpoint_host_port_proxy_pair_(endpoint_host_port_pair_, proxy_), - tcp_params_(new TCPSocketParams(proxy_host_port_, LOWEST, url_, false, - false)) { + transport_params_(new TransportSocketParams(proxy_host_port_, + LOWEST, + url_, + false, + false)) { } void SpdyProxyClientSocketTest::TearDown() { @@ -181,8 +184,9 @@ void SpdyProxyClientSocketTest::Initialize(MockRead* reads, // Perform the TCP connect scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(OK, - connection->Init(endpoint_host_port_pair_.ToString(), tcp_params_, - LOWEST, NULL, session_->tcp_socket_pool(), + connection->Init(endpoint_host_port_pair_.ToString(), + transport_params_, + LOWEST, NULL, session_->transport_socket_pool(), BoundNetLog())); spdy_session_->InitializeWithSocket(connection.release(), false, OK); diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index 81319b9..a4e1edc 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -25,7 +25,6 @@ #include "net/base/upload_data_stream.h" #include "net/socket/client_socket.h" #include "net/socket/client_socket_handle.h" -#include "net/socket/tcp_client_socket_pool.h" #include "net/spdy/spdy_framer.h" #include "net/spdy/spdy_io_buffer.h" #include "net/spdy/spdy_protocol.h" diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc index de83271..daa6e01 100644 --- a/net/spdy/spdy_session_pool.cc +++ b/net/spdy/spdy_session_pool.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/values.h" +#include "net/base/address_list.h" #include "net/base/sys_addrinfo.h" #include "net/http/http_network_session.h" #include "net/spdy/spdy_session.h" diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc index 6a74a0d..75f7885 100644 --- a/net/spdy/spdy_session_unittest.cc +++ b/net/spdy/spdy_session_unittest.cc @@ -91,13 +91,18 @@ TEST_F(SpdySessionTest, GoAway) { spdy_session_pool->Get(pair, BoundNetLog()); EXPECT_TRUE(spdy_session_pool->HasSession(pair)); - scoped_refptr<TCPSocketParams> tcp_params( - new TCPSocketParams(test_host_port_pair, MEDIUM, GURL(), false, false)); + scoped_refptr<TransportSocketParams> transport_params( + new TransportSocketParams(test_host_port_pair, + MEDIUM, + GURL(), + false, + false)); scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(OK, - connection->Init(test_host_port_pair.ToString(), tcp_params, MEDIUM, - NULL, http_session->tcp_socket_pool(), - BoundNetLog())); + connection->Init(test_host_port_pair.ToString(), + transport_params, MEDIUM, + NULL, http_session->transport_socket_pool(), + BoundNetLog())); EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); // Flush the SpdySession::OnReadComplete() task. @@ -198,13 +203,18 @@ TEST_F(SpdySessionTest, OnSettings) { spdy_session_pool->Get(pair, BoundNetLog()); ASSERT_TRUE(spdy_session_pool->HasSession(pair)); - scoped_refptr<TCPSocketParams> tcp_params( - new TCPSocketParams(test_host_port_pair, MEDIUM, GURL(), false, false)); + scoped_refptr<TransportSocketParams> transport_params( + new TransportSocketParams(test_host_port_pair, + MEDIUM, + GURL(), + false, + false)); scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(OK, - connection->Init(test_host_port_pair.ToString(), tcp_params, MEDIUM, - NULL, http_session->tcp_socket_pool(), - BoundNetLog())); + connection->Init(test_host_port_pair.ToString(), + transport_params, MEDIUM, + NULL, http_session->transport_socket_pool(), + BoundNetLog())); EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); // Create 2 streams. First will succeed. Second will be pending. @@ -279,13 +289,18 @@ TEST_F(SpdySessionTest, CancelPendingCreateStream) { spdy_session_pool->Get(pair, BoundNetLog()); ASSERT_TRUE(spdy_session_pool->HasSession(pair)); - scoped_refptr<TCPSocketParams> tcp_params( - new TCPSocketParams(test_host_port_pair, MEDIUM, GURL(), false, false)); + scoped_refptr<TransportSocketParams> transport_params( + new TransportSocketParams(test_host_port_pair, + MEDIUM, + GURL(), + false, + false)); scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(OK, - connection->Init(test_host_port_pair.ToString(), tcp_params, MEDIUM, - NULL, http_session->tcp_socket_pool(), - BoundNetLog())); + connection->Init(test_host_port_pair.ToString(), + transport_params, MEDIUM, + NULL, http_session->transport_socket_pool(), + BoundNetLog())); EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); // Use scoped_ptr to let us invalidate the memory when we want to, to trigger @@ -374,13 +389,18 @@ TEST_F(SpdySessionTest, SendSettingsOnNewSession) { spdy_session_pool->Get(pair, BoundNetLog()); EXPECT_TRUE(spdy_session_pool->HasSession(pair)); - scoped_refptr<TCPSocketParams> tcp_params( - new TCPSocketParams(test_host_port_pair, MEDIUM, GURL(), false, false)); + scoped_refptr<TransportSocketParams> transport_params( + new TransportSocketParams(test_host_port_pair, + MEDIUM, + GURL(), + false, + false)); scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(OK, - connection->Init(test_host_port_pair.ToString(), tcp_params, MEDIUM, - NULL, http_session->tcp_socket_pool(), - BoundNetLog())); + connection->Init(test_host_port_pair.ToString(), + transport_params, MEDIUM, + NULL, http_session->transport_socket_pool(), + BoundNetLog())); EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); MessageLoop::current()->RunAllPending(); EXPECT_TRUE(data.at_write_eof()); @@ -439,17 +459,18 @@ TEST_F(SpdySessionTest, IPPooling) { EXPECT_TRUE(spdy_session_pool->HasSession(test_hosts[0].pair)); HostPortPair test_host_port_pair(test_hosts[0].name, kTestPort); - scoped_refptr<TCPSocketParams> tcp_params( - new TCPSocketParams(test_host_port_pair, + scoped_refptr<TransportSocketParams> transport_params( + new TransportSocketParams(test_host_port_pair, MEDIUM, GURL(), false, false)); scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(OK, - connection->Init(test_host_port_pair.ToString(), tcp_params, MEDIUM, - NULL, http_session->tcp_socket_pool(), - BoundNetLog())); + connection->Init(test_host_port_pair.ToString(), + transport_params, MEDIUM, + NULL, http_session->transport_socket_pool(), + BoundNetLog())); EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); // Flush the SpdySession::OnReadComplete() task. diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc index e7e8c86..c867371 100644 --- a/net/spdy/spdy_stream_unittest.cc +++ b/net/spdy/spdy_stream_unittest.cc @@ -197,13 +197,17 @@ TEST_F(SpdyStreamTest, SendDataAfterOpen) { GURL url(kStreamUrl); HostPortPair host_port_pair("www.google.com", 80); - scoped_refptr<TCPSocketParams> tcp_params( - new TCPSocketParams(host_port_pair, LOWEST, GURL(), false, false)); + scoped_refptr<TransportSocketParams> transport_params( + new TransportSocketParams(host_port_pair, LOWEST, GURL(), false, false)); scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); EXPECT_EQ(OK, - connection->Init(host_port_pair.ToString(), tcp_params, LOWEST, - NULL, session_->tcp_socket_pool(), BoundNetLog())); + connection->Init(host_port_pair.ToString(), + transport_params, + LOWEST, + NULL, + session_->transport_socket_pool(), + BoundNetLog())); session->InitializeWithSocket(connection.release(), false, OK); scoped_refptr<SpdyStream> stream; |