summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-03 22:44:26 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-03 22:44:26 +0000
commit41d64e8ded3eec5ad56df98085bd205ad1164ee3 (patch)
tree970141ab3223adc0f729da84714d92a8d4499933 /net/socket
parent8ed2d35815bcf433555db5bea6d1e9eeec4b4ca7 (diff)
downloadchromium_src-41d64e8ded3eec5ad56df98085bd205ad1164ee3.zip
chromium_src-41d64e8ded3eec5ad56df98085bd205ad1164ee3.tar.gz
chromium_src-41d64e8ded3eec5ad56df98085bd205ad1164ee3.tar.bz2
[SPDY] Refactor and clean up SpdySessionPool
Replace the map of keys to lists of sessions to a map of keys to sessions, since we were already limiting the lists to be of size 1 anyway. Remove the functions from SpdySessionPool that were used mostly by tests. Replace them with functions in spdy_test_util_common.{h,cc}. Make a bunch of tests use these functions. Make the Close*Sessions() behave consistently. Make SpdySession::CloseSessionOnError() always remove the session from its pool. Move the SpdySessionPool tests for spdy_session_unittest.cc to a new file spdy_session_pool_unittest.cc. Add a few more for the Close*Sessions() tests. Remove --max-spdy-sessions-per-domain switch. Parametrize HttpStreamFactoryTest on NextProto. Misc. cleanup here and there. BUG=255701 TBR=rch@chromium.org Review URL: https://codereview.chromium.org/18226004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/next_proto.h2
-rw-r--r--net/socket/ssl_client_socket_pool_unittest.cc84
2 files changed, 16 insertions, 70 deletions
diff --git a/net/socket/next_proto.h b/net/socket/next_proto.h
index 04ecc0f..f9c1659 100644
--- a/net/socket/next_proto.h
+++ b/net/socket/next_proto.h
@@ -16,9 +16,11 @@ enum NextProto {
kProtoHTTP11 = 1,
kProtoMinimumVersion = kProtoHTTP11,
+ // TODO(akalin): Stop advertising SPDY/1 and remove this.
kProtoSPDY1 = 2,
kProtoSPDYMinimumVersion = kProtoSPDY1,
kProtoSPDY2 = 3,
+ // TODO(akalin): Stop adverising SPDY/2.1, too.
kProtoSPDY21 = 4,
kProtoSPDY3 = 5,
kProtoSPDY31 = 6,
diff --git a/net/socket/ssl_client_socket_pool_unittest.cc b/net/socket/ssl_client_socket_pool_unittest.cc
index 814010b..bd5e377 100644
--- a/net/socket/ssl_client_socket_pool_unittest.cc
+++ b/net/socket/ssl_client_socket_pool_unittest.cc
@@ -757,43 +757,15 @@ TEST_F(SSLClientSocketPoolTest, IPPooling) {
socket_factory_.AddSSLSocketDataProvider(&ssl);
CreatePool(true /* tcp pool */, false, false);
- scoped_refptr<SSLSocketParams> params = SSLParams(ProxyServer::SCHEME_DIRECT,
- true);
-
- scoped_ptr<ClientSocketHandle> handle(new ClientSocketHandle());
- TestCompletionCallback callback;
- int rv = handle->Init(
- "a", params, MEDIUM, callback.callback(), pool_.get(), BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_FALSE(handle->is_initialized());
- EXPECT_FALSE(handle->socket());
-
- EXPECT_EQ(OK, callback.WaitForResult());
- EXPECT_TRUE(handle->is_initialized());
- EXPECT_TRUE(handle->socket());
-
- SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket());
- EXPECT_TRUE(ssl_socket->WasNpnNegotiated());
- std::string proto;
- std::string server_protos;
- ssl_socket->GetNextProto(&proto, &server_protos);
- EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto),
- kProtoSPDY2);
-
- // TODO(rtenneti): MockClientSocket::GetPeerAddress returns 0 as the port
- // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias.
- SpdySessionPoolPeer pool_peer(session_->spdy_session_pool());
- pool_peer.AddAlias(test_hosts[0].addresses.front(), test_hosts[0].key);
-
- scoped_refptr<SpdySession> spdy_session;
- rv = session_->spdy_session_pool()->GetSpdySessionFromSocket(
- test_hosts[0].key, handle.release(), BoundNetLog(), 0,
- &spdy_session, true);
- EXPECT_EQ(0, rv);
+ scoped_refptr<SpdySession> spdy_session =
+ CreateSecureSpdySession(session_, test_hosts[0].key, BoundNetLog());
- EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[0].key));
- EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].key));
- EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[2].key));
+ EXPECT_TRUE(
+ HasSpdySession(session_->spdy_session_pool(), test_hosts[0].key));
+ EXPECT_FALSE(
+ HasSpdySession(session_->spdy_session_pool(), test_hosts[1].key));
+ EXPECT_TRUE(
+ HasSpdySession(session_->spdy_session_pool(), test_hosts[2].key));
session_->spdy_session_pool()->CloseAllSessions();
}
@@ -838,41 +810,13 @@ void SSLClientSocketPoolTest::TestIPPoolingDisabled(
socket_factory_.AddSSLSocketDataProvider(ssl);
CreatePool(true /* tcp pool */, false, false);
- scoped_refptr<SSLSocketParams> params = SSLParams(ProxyServer::SCHEME_DIRECT,
- true);
-
- scoped_ptr<ClientSocketHandle> handle(new ClientSocketHandle());
- rv = handle->Init(
- "a", params, MEDIUM, callback.callback(), pool_.get(), BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- EXPECT_FALSE(handle->is_initialized());
- EXPECT_FALSE(handle->socket());
-
- EXPECT_EQ(OK, callback.WaitForResult());
- EXPECT_TRUE(handle->is_initialized());
- EXPECT_TRUE(handle->socket());
-
- SSLClientSocket* ssl_socket = static_cast<SSLClientSocket*>(handle->socket());
- EXPECT_TRUE(ssl_socket->WasNpnNegotiated());
- std::string proto;
- std::string server_protos;
- ssl_socket->GetNextProto(&proto, &server_protos);
- EXPECT_EQ(SSLClientSocket::NextProtoFromString(proto),
- kProtoSPDY2);
-
- // TODO(rtenneti): MockClientSocket::GetPeerAddress returns 0 as the port
- // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias.
- SpdySessionPoolPeer pool_peer(session_->spdy_session_pool());
- pool_peer.AddAlias(test_hosts[0].addresses.front(), test_hosts[0].key);
-
- scoped_refptr<SpdySession> spdy_session;
- rv = session_->spdy_session_pool()->GetSpdySessionFromSocket(
- test_hosts[0].key, handle.release(), BoundNetLog(), 0,
- &spdy_session, true);
- EXPECT_EQ(0, rv);
+ scoped_refptr<SpdySession> spdy_session =
+ CreateSecureSpdySession(session_, test_hosts[0].key, BoundNetLog());
- EXPECT_TRUE(session_->spdy_session_pool()->HasSession(test_hosts[0].key));
- EXPECT_FALSE(session_->spdy_session_pool()->HasSession(test_hosts[1].key));
+ EXPECT_TRUE(
+ HasSpdySession(session_->spdy_session_pool(), test_hosts[0].key));
+ EXPECT_FALSE(
+ HasSpdySession(session_->spdy_session_pool(), test_hosts[1].key));
session_->spdy_session_pool()->CloseAllSessions();
}