| Index: net/spdy/spdy_session_pool_unittest.cc
|
| diff --git a/net/spdy/spdy_session_pool_unittest.cc b/net/spdy/spdy_session_pool_unittest.cc
|
| index 58002dcdea2f199779abe21ebe9ca6405051446d..ce999bc8da264098f604a499e193562bec7f0c00 100644
|
| --- a/net/spdy/spdy_session_pool_unittest.cc
|
| +++ b/net/spdy/spdy_session_pool_unittest.cc
|
| @@ -31,9 +31,7 @@ class SpdySessionPoolTest : public ::testing::Test,
|
| SPDY_POOL_CLOSE_IDLE_SESSIONS,
|
| };
|
|
|
| - SpdySessionPoolTest()
|
| - : session_deps_(GetParam()),
|
| - spdy_session_pool_(NULL) {}
|
| + SpdySessionPoolTest() : session_deps_(GetParam()), spdy_session_pool_(NULL) {}
|
|
|
| void CreateNetworkSession() {
|
| http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
|
| @@ -47,19 +45,19 @@ class SpdySessionPoolTest : public ::testing::Test,
|
| SpdySessionPool* spdy_session_pool_;
|
| };
|
|
|
| -INSTANTIATE_TEST_CASE_P(
|
| - NextProto,
|
| - SpdySessionPoolTest,
|
| - testing::Values(kProtoDeprecatedSPDY2,
|
| - kProtoSPDY3, kProtoSPDY31, kProtoSPDY4));
|
| +INSTANTIATE_TEST_CASE_P(NextProto,
|
| + SpdySessionPoolTest,
|
| + testing::Values(kProtoDeprecatedSPDY2,
|
| + kProtoSPDY3,
|
| + kProtoSPDY31,
|
| + kProtoSPDY4));
|
|
|
| // A delegate that opens a new session when it is closed.
|
| class SessionOpeningDelegate : public SpdyStream::Delegate {
|
| public:
|
| SessionOpeningDelegate(SpdySessionPool* spdy_session_pool,
|
| const SpdySessionKey& key)
|
| - : spdy_session_pool_(spdy_session_pool),
|
| - key_(key) {}
|
| + : spdy_session_pool_(spdy_session_pool), key_(key) {}
|
|
|
| virtual ~SessionOpeningDelegate() {}
|
|
|
| @@ -92,14 +90,12 @@ TEST_P(SpdySessionPoolTest, CloseCurrentSessions) {
|
| session_deps_.host_resolver->set_synchronous_mode(true);
|
|
|
| HostPortPair test_host_port_pair(kTestHost, kTestPort);
|
| - SpdySessionKey test_key =
|
| - SpdySessionKey(
|
| - test_host_port_pair, ProxyServer::Direct(),
|
| - PRIVACY_MODE_DISABLED);
|
| + SpdySessionKey test_key = SpdySessionKey(
|
| + test_host_port_pair, ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
|
|
|
| MockConnect connect_data(SYNCHRONOUS, OK);
|
| MockRead reads[] = {
|
| - MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
|
| + MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
|
| };
|
|
|
| StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
|
| @@ -124,8 +120,10 @@ TEST_P(SpdySessionPoolTest, CloseCurrentSessions) {
|
| // Set the stream to create a new session when it is closed.
|
| base::WeakPtr<SpdyStream> spdy_stream =
|
| CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
|
| - session, GURL("http://www.foo.com"),
|
| - MEDIUM, BoundNetLog());
|
| + session,
|
| + GURL("http://www.foo.com"),
|
| + MEDIUM,
|
| + BoundNetLog());
|
| SessionOpeningDelegate delegate(spdy_session_pool_, test_key);
|
| spdy_stream->SetDelegate(&delegate);
|
|
|
| @@ -138,7 +136,7 @@ TEST_P(SpdySessionPoolTest, CloseCurrentSessions) {
|
| TEST_P(SpdySessionPoolTest, CloseCurrentIdleSessions) {
|
| MockConnect connect_data(SYNCHRONOUS, OK);
|
| MockRead reads[] = {
|
| - MockRead(ASYNC, 0, 0) // EOF
|
| + MockRead(ASYNC, 0, 0) // EOF
|
| };
|
|
|
| session_deps_.host_resolver->set_synchronous_mode(true);
|
| @@ -155,42 +153,39 @@ TEST_P(SpdySessionPoolTest, CloseCurrentIdleSessions) {
|
| // Set up session 1
|
| const std::string kTestHost1("http://www.a.com");
|
| HostPortPair test_host_port_pair1(kTestHost1, 80);
|
| - SpdySessionKey key1(test_host_port_pair1, ProxyServer::Direct(),
|
| - PRIVACY_MODE_DISABLED);
|
| + SpdySessionKey key1(
|
| + test_host_port_pair1, ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
|
| base::WeakPtr<SpdySession> session1 =
|
| CreateInsecureSpdySession(http_session_, key1, BoundNetLog());
|
| GURL url1(kTestHost1);
|
| - base::WeakPtr<SpdyStream> spdy_stream1 =
|
| - CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
|
| - session1, url1, MEDIUM, BoundNetLog());
|
| + base::WeakPtr<SpdyStream> spdy_stream1 = CreateStreamSynchronously(
|
| + SPDY_BIDIRECTIONAL_STREAM, 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);
|
| - SpdySessionKey key2(test_host_port_pair2, ProxyServer::Direct(),
|
| - PRIVACY_MODE_DISABLED);
|
| + SpdySessionKey key2(
|
| + test_host_port_pair2, ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
|
| base::WeakPtr<SpdySession> session2 =
|
| CreateInsecureSpdySession(http_session_, key2, BoundNetLog());
|
| GURL url2(kTestHost2);
|
| - base::WeakPtr<SpdyStream> spdy_stream2 =
|
| - CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
|
| - session2, url2, MEDIUM, BoundNetLog());
|
| + base::WeakPtr<SpdyStream> spdy_stream2 = CreateStreamSynchronously(
|
| + SPDY_BIDIRECTIONAL_STREAM, 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);
|
| - SpdySessionKey key3(test_host_port_pair3, ProxyServer::Direct(),
|
| - PRIVACY_MODE_DISABLED);
|
| + SpdySessionKey key3(
|
| + test_host_port_pair3, ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
|
| base::WeakPtr<SpdySession> session3 =
|
| CreateInsecureSpdySession(http_session_, key3, BoundNetLog());
|
| GURL url3(kTestHost3);
|
| - base::WeakPtr<SpdyStream> spdy_stream3 =
|
| - CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
|
| - session3, url3, MEDIUM, BoundNetLog());
|
| + base::WeakPtr<SpdyStream> spdy_stream3 = CreateStreamSynchronously(
|
| + SPDY_BIDIRECTIONAL_STREAM, session3, url3, MEDIUM, BoundNetLog());
|
| ASSERT_TRUE(spdy_stream3.get() != NULL);
|
|
|
| // All sessions are active and not closed
|
| @@ -255,14 +250,12 @@ TEST_P(SpdySessionPoolTest, CloseAllSessions) {
|
| session_deps_.host_resolver->set_synchronous_mode(true);
|
|
|
| HostPortPair test_host_port_pair(kTestHost, kTestPort);
|
| - SpdySessionKey test_key =
|
| - SpdySessionKey(
|
| - test_host_port_pair, ProxyServer::Direct(),
|
| - PRIVACY_MODE_DISABLED);
|
| + SpdySessionKey test_key = SpdySessionKey(
|
| + test_host_port_pair, ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
|
|
|
| MockConnect connect_data(SYNCHRONOUS, OK);
|
| MockRead reads[] = {
|
| - MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
|
| + MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
|
| };
|
|
|
| StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
|
| @@ -287,8 +280,10 @@ TEST_P(SpdySessionPoolTest, CloseAllSessions) {
|
| // Set the stream to create a new session when it is closed.
|
| base::WeakPtr<SpdyStream> spdy_stream =
|
| CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
|
| - session, GURL("http://www.foo.com"),
|
| - MEDIUM, BoundNetLog());
|
| + session,
|
| + GURL("http://www.foo.com"),
|
| + MEDIUM,
|
| + BoundNetLog());
|
| SessionOpeningDelegate delegate(spdy_session_pool_, test_key);
|
| spdy_stream->SetDelegate(&delegate);
|
|
|
| @@ -315,19 +310,12 @@ void SpdySessionPoolTest::RunIPPoolingTest(
|
| SpdySessionKey key;
|
| AddressList addresses;
|
| } test_hosts[] = {
|
| - { "http:://www.foo.com",
|
| - "www.foo.com",
|
| - "192.0.2.33,192.168.0.1,192.168.0.5"
|
| - },
|
| - { "http://js.foo.com",
|
| - "js.foo.com",
|
| - "192.168.0.2,192.168.0.3,192.168.0.5,192.0.2.33"
|
| - },
|
| - { "http://images.foo.com",
|
| - "images.foo.com",
|
| - "192.168.0.4,192.168.0.3"
|
| - },
|
| - };
|
| + {"http:://www.foo.com", "www.foo.com",
|
| + "192.0.2.33,192.168.0.1,192.168.0.5"},
|
| + {"http://js.foo.com", "js.foo.com",
|
| + "192.168.0.2,192.168.0.3,192.168.0.5,192.0.2.33"},
|
| + {"http://images.foo.com", "images.foo.com", "192.168.0.4,192.168.0.3"},
|
| + };
|
|
|
| session_deps_.host_resolver->set_synchronous_mode(true);
|
| for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) {
|
| @@ -345,14 +333,15 @@ void SpdySessionPoolTest::RunIPPoolingTest(
|
| BoundNetLog());
|
|
|
| // Setup a SpdySessionKey
|
| - test_hosts[i].key = SpdySessionKey(
|
| - HostPortPair(test_hosts[i].name, kTestPort), ProxyServer::Direct(),
|
| - PRIVACY_MODE_DISABLED);
|
| + test_hosts[i].key =
|
| + SpdySessionKey(HostPortPair(test_hosts[i].name, kTestPort),
|
| + ProxyServer::Direct(),
|
| + PRIVACY_MODE_DISABLED);
|
| }
|
|
|
| MockConnect connect_data(SYNCHRONOUS, OK);
|
| MockRead reads[] = {
|
| - MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
|
| + MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever.
|
| };
|
|
|
| StaticSocketDataProvider data(reads, arraysize(reads), NULL, 0);
|
| @@ -365,9 +354,8 @@ void SpdySessionPoolTest::RunIPPoolingTest(
|
| CreateNetworkSession();
|
|
|
| // Setup the first session to the first host.
|
| - base::WeakPtr<SpdySession> session =
|
| - CreateInsecureSpdySession(
|
| - http_session_, test_hosts[0].key, BoundNetLog());
|
| + base::WeakPtr<SpdySession> session = CreateInsecureSpdySession(
|
| + http_session_, test_hosts[0].key, BoundNetLog());
|
|
|
| // Flush the SpdySession::OnReadComplete() task.
|
| base::MessageLoop::current()->RunUntilIdle();
|
| @@ -379,7 +367,8 @@ void SpdySessionPoolTest::RunIPPoolingTest(
|
| EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[1].key));
|
|
|
| // Verify that the second host, through a proxy, won't share the IP.
|
| - SpdySessionKey proxy_key(test_hosts[1].key.host_port_pair(),
|
| + SpdySessionKey proxy_key(
|
| + test_hosts[1].key.host_port_pair(),
|
| ProxyServer::FromPacString("HTTP http://proxy.foo.com/"),
|
| PRIVACY_MODE_DISABLED);
|
| EXPECT_FALSE(HasSpdySession(spdy_session_pool_, proxy_key));
|
| @@ -389,9 +378,8 @@ void SpdySessionPoolTest::RunIPPoolingTest(
|
|
|
| // Create a new session to host 2.
|
| session_deps_.socket_factory->AddSocketDataProvider(&data);
|
| - base::WeakPtr<SpdySession> session2 =
|
| - CreateInsecureSpdySession(
|
| - http_session_, test_hosts[2].key, BoundNetLog());
|
| + base::WeakPtr<SpdySession> session2 = CreateInsecureSpdySession(
|
| + http_session_, test_hosts[2].key, BoundNetLog());
|
|
|
| // Verify that we have sessions for everything.
|
| EXPECT_TRUE(HasSpdySession(spdy_session_pool_, test_hosts[0].key));
|
| @@ -401,8 +389,8 @@ void SpdySessionPoolTest::RunIPPoolingTest(
|
| // Grab the session to host 1 and verify that it is the same session
|
| // we got with host 0, and that is a different from host 2's session.
|
| base::WeakPtr<SpdySession> session1 =
|
| - spdy_session_pool_->FindAvailableSession(
|
| - test_hosts[1].key, BoundNetLog());
|
| + spdy_session_pool_->FindAvailableSession(test_hosts[1].key,
|
| + BoundNetLog());
|
| EXPECT_EQ(session.get(), session1.get());
|
| EXPECT_NE(session2.get(), session1.get());
|
|
|
| @@ -429,17 +417,14 @@ void SpdySessionPoolTest::RunIPPoolingTest(
|
| break;
|
| case SPDY_POOL_CLOSE_IDLE_SESSIONS:
|
| GURL url(test_hosts[0].url);
|
| - base::WeakPtr<SpdyStream> spdy_stream =
|
| - CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
|
| - session, url, MEDIUM, BoundNetLog());
|
| + base::WeakPtr<SpdyStream> spdy_stream = CreateStreamSynchronously(
|
| + SPDY_BIDIRECTIONAL_STREAM, session, url, MEDIUM, BoundNetLog());
|
| GURL url1(test_hosts[1].url);
|
| - base::WeakPtr<SpdyStream> spdy_stream1 =
|
| - CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
|
| - session1, url1, MEDIUM, BoundNetLog());
|
| + base::WeakPtr<SpdyStream> spdy_stream1 = CreateStreamSynchronously(
|
| + SPDY_BIDIRECTIONAL_STREAM, session1, url1, MEDIUM, BoundNetLog());
|
| GURL url2(test_hosts[2].url);
|
| - base::WeakPtr<SpdyStream> spdy_stream2 =
|
| - CreateStreamSynchronously(SPDY_BIDIRECTIONAL_STREAM,
|
| - session2, url2, MEDIUM, BoundNetLog());
|
| + base::WeakPtr<SpdyStream> spdy_stream2 = CreateStreamSynchronously(
|
| + SPDY_BIDIRECTIONAL_STREAM, session2, url2, MEDIUM, BoundNetLog());
|
|
|
| // Close streams to make spdy_session and spdy_session1 inactive.
|
| session->CloseCreatedStream(spdy_stream, OK);
|
|
|