| Index: net/spdy/spdy_session_spdy3_unittest.cc
|
| ===================================================================
|
| --- net/spdy/spdy_session_spdy3_unittest.cc (revision 195932)
|
| +++ net/spdy/spdy_session_spdy3_unittest.cc (working copy)
|
| @@ -486,6 +486,15 @@
|
| }
|
|
|
| TEST_F(SpdySessionSpdy3Test, CloseIdleSessions) {
|
| + MockConnect connect_data(SYNCHRONOUS, OK);
|
| + MockRead reads[] = {
|
| + MockRead(ASYNC, 0, 0) // EOF
|
| + };
|
| +
|
| + StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
|
| + data.set_connect_data(connect_data);
|
| + session_deps_.socket_factory->AddSocketDataProvider(&data);
|
| +
|
| CreateNetworkSession();
|
|
|
| // Set up session 1
|
| @@ -493,26 +502,40 @@
|
| HostPortPair test_host_port_pair1(kTestHost1, 80);
|
| HostPortProxyPair pair1(test_host_port_pair1, ProxyServer::Direct());
|
| scoped_refptr<SpdySession> session1 = GetSession(pair1);
|
| + EXPECT_EQ(
|
| + OK,
|
| + InitializeSession(
|
| + http_session_.get(), session1.get(), test_host_port_pair1));
|
| GURL url1(kTestHost1);
|
| scoped_refptr<SpdyStream> spdy_stream1 =
|
| CreateStreamSynchronously(session1, url1, MEDIUM, BoundNetLog());
|
| ASSERT_TRUE(spdy_stream1.get() != NULL);
|
|
|
| // Set up session 2
|
| + session_deps_.socket_factory->AddSocketDataProvider(&data);
|
| const std::string kTestHost2("http://www.b.com");
|
| HostPortPair test_host_port_pair2(kTestHost2, 80);
|
| HostPortProxyPair pair2(test_host_port_pair2, ProxyServer::Direct());
|
| scoped_refptr<SpdySession> session2 = GetSession(pair2);
|
| + EXPECT_EQ(
|
| + OK,
|
| + InitializeSession(
|
| + http_session_.get(), session2.get(), test_host_port_pair2));
|
| GURL url2(kTestHost2);
|
| scoped_refptr<SpdyStream> spdy_stream2 =
|
| CreateStreamSynchronously(session2, url2, MEDIUM, BoundNetLog());
|
| ASSERT_TRUE(spdy_stream2.get() != NULL);
|
|
|
| // Set up session 3
|
| + session_deps_.socket_factory->AddSocketDataProvider(&data);
|
| const std::string kTestHost3("http://www.c.com");
|
| HostPortPair test_host_port_pair3(kTestHost3, 80);
|
| HostPortProxyPair pair3(test_host_port_pair3, ProxyServer::Direct());
|
| scoped_refptr<SpdySession> session3 = GetSession(pair3);
|
| + EXPECT_EQ(
|
| + OK,
|
| + InitializeSession(
|
| + http_session_.get(), session3.get(), test_host_port_pair3));
|
| GURL url3(kTestHost3);
|
| scoped_refptr<SpdyStream> spdy_stream3 =
|
| CreateStreamSynchronously(session3, url3, MEDIUM, BoundNetLog());
|
| @@ -783,6 +806,21 @@
|
| SPDY_POOL_CLOSE_IDLE_SESSIONS,
|
| };
|
|
|
| +// Initialize the SpdySession with socket.
|
| +void IPPoolingInitializedSession(
|
| + const std::string& group_name,
|
| + const scoped_refptr<TransportSocketParams>& transport_params,
|
| + HttpNetworkSession* http_session,
|
| + SpdySession* session) {
|
| + scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
|
| + EXPECT_EQ(OK, connection->Init(group_name,
|
| + transport_params, MEDIUM, CompletionCallback(),
|
| + http_session->GetTransportSocketPool(
|
| + HttpNetworkSession::NORMAL_SOCKET_POOL),
|
| + BoundNetLog()));
|
| + EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
|
| +}
|
| +
|
| // This test has three variants, one for each style of closing the connection.
|
| // If |clean_via_close_current_sessions| is SPDY_POOL_CLOSE_SESSIONS_MANUALLY,
|
| // the sessions are closed manually, calling SpdySessionPool::Remove() directly.
|
| @@ -855,19 +893,15 @@
|
|
|
| HostPortPair test_host_port_pair(test_hosts[0].name, kTestPort);
|
|
|
| + // Initialize session for the first host.
|
| scoped_refptr<TransportSocketParams> transport_params(
|
| new TransportSocketParams(test_host_port_pair,
|
| MEDIUM,
|
| false,
|
| false,
|
| OnHostResolutionCallback()));
|
| - scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
|
| - EXPECT_EQ(OK, connection->Init(test_host_port_pair.ToString(),
|
| - transport_params, MEDIUM, CompletionCallback(),
|
| - http_session->GetTransportSocketPool(
|
| - HttpNetworkSession::NORMAL_SOCKET_POOL),
|
| - BoundNetLog()));
|
| - EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
|
| + IPPoolingInitializedSession(test_host_port_pair.ToString(),
|
| + transport_params, http_session, session);
|
|
|
| // TODO(rtenneti): MockClientSocket::GetPeerAddress return's 0 as the port
|
| // number. Fix it to return port 80 and then use GetPeerAddress to AddAlias.
|
| @@ -900,6 +934,11 @@
|
| EXPECT_TRUE(spdy_session_pool->HasSession(test_hosts[1].pair));
|
| EXPECT_TRUE(spdy_session_pool->HasSession(test_hosts[2].pair));
|
|
|
| + // Initialize session for host 2.
|
| + session_deps.socket_factory->AddSocketDataProvider(&data);
|
| + IPPoolingInitializedSession(test_hosts[2].pair.first.ToString(),
|
| + transport_params, http_session, session2);
|
| +
|
| // Grab the session to host 1 and verify that it is the same session
|
| // we got with host 0, and that is a different than host 2's session.
|
| scoped_refptr<SpdySession> session1 =
|
| @@ -907,6 +946,11 @@
|
| EXPECT_EQ(session.get(), session1.get());
|
| EXPECT_NE(session2.get(), session1.get());
|
|
|
| + // Initialize session for host 1.
|
| + session_deps.socket_factory->AddSocketDataProvider(&data);
|
| + IPPoolingInitializedSession(test_hosts[2].pair.first.ToString(),
|
| + transport_params, http_session, session2);
|
| +
|
| // Remove the aliases and observe that we still have a session for host1.
|
| pool_peer.RemoveAliases(test_hosts[0].pair);
|
| pool_peer.RemoveAliases(test_hosts[1].pair);
|
|
|