| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/spdy/spdy_session_pool.h" | 5 #include "net/spdy/spdy_session_pool.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "net/dns/host_cache.h" | 12 #include "net/dns/host_cache.h" |
| 13 #include "net/http/http_network_session.h" | 13 #include "net/http/http_network_session.h" |
| 14 #include "net/socket/client_socket_handle.h" | 14 #include "net/socket/client_socket_handle.h" |
| 15 #include "net/socket/transport_client_socket_pool.h" | 15 #include "net/socket/transport_client_socket_pool.h" |
| 16 #include "net/spdy/spdy_session.h" | 16 #include "net/spdy/spdy_session.h" |
| 17 #include "net/spdy/spdy_stream_test_util.h" | 17 #include "net/spdy/spdy_stream_test_util.h" |
| 18 #include "net/spdy/spdy_test_util_common.h" | 18 #include "net/spdy/spdy_test_util_common.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 namespace { | |
| 24 | |
| 25 class SpdySessionPoolTest : public ::testing::Test, | 23 class SpdySessionPoolTest : public ::testing::Test, |
| 26 public ::testing::WithParamInterface<NextProto> { | 24 public ::testing::WithParamInterface<NextProto> { |
| 27 protected: | 25 protected: |
| 28 // Used by RunIPPoolingTest(). | 26 // Used by RunIPPoolingTest(). |
| 29 enum SpdyPoolCloseSessionsType { | 27 enum SpdyPoolCloseSessionsType { |
| 30 SPDY_POOL_CLOSE_SESSIONS_MANUALLY, | 28 SPDY_POOL_CLOSE_SESSIONS_MANUALLY, |
| 31 SPDY_POOL_CLOSE_CURRENT_SESSIONS, | 29 SPDY_POOL_CLOSE_CURRENT_SESSIONS, |
| 32 SPDY_POOL_CLOSE_IDLE_SESSIONS, | 30 SPDY_POOL_CLOSE_IDLE_SESSIONS, |
| 33 }; | 31 }; |
| 34 | 32 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 TEST_P(SpdySessionPoolTest, IPPoolingCloseIdleSessions) { | 501 TEST_P(SpdySessionPoolTest, IPPoolingCloseIdleSessions) { |
| 504 RunIPPoolingTest(SPDY_POOL_CLOSE_IDLE_SESSIONS); | 502 RunIPPoolingTest(SPDY_POOL_CLOSE_IDLE_SESSIONS); |
| 505 } | 503 } |
| 506 | 504 |
| 507 // Construct a Pool with SpdySessions in various availability states. Simulate | 505 // Construct a Pool with SpdySessions in various availability states. Simulate |
| 508 // an IP address change. Ensure sessions gracefully shut down. Regression test | 506 // an IP address change. Ensure sessions gracefully shut down. Regression test |
| 509 // for crbug.com/379469. | 507 // for crbug.com/379469. |
| 510 TEST_P(SpdySessionPoolTest, IPAddressChanged) { | 508 TEST_P(SpdySessionPoolTest, IPAddressChanged) { |
| 511 MockConnect connect_data(SYNCHRONOUS, OK); | 509 MockConnect connect_data(SYNCHRONOUS, OK); |
| 512 session_deps_.host_resolver->set_synchronous_mode(true); | 510 session_deps_.host_resolver->set_synchronous_mode(true); |
| 513 SpdyTestUtil spdy_util(GetParam()); | 511 |
| 512 // This isn't testing anything having to do with SPDY frames; we |
| 513 // can ignore issues of how dependencies are set. We default to |
| 514 // setting them (when doing the appropriate protocol) since that's |
| 515 // where we're eventually headed for all HTTP/2 connections. |
| 516 SpdyTestUtil spdy_util(GetParam(), true); |
| 517 SpdySession::SetPriorityDependencyDefaultForTesting(true); |
| 514 | 518 |
| 515 MockRead reads[] = { | 519 MockRead reads[] = { |
| 516 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. | 520 MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. |
| 517 }; | 521 }; |
| 518 scoped_ptr<SpdyFrame> req( | 522 scoped_ptr<SpdyFrame> req( |
| 519 spdy_util.ConstructSpdyGet("http://www.a.com", false, 1, MEDIUM)); | 523 spdy_util.ConstructSpdyGet("http://www.a.com", false, 1, MEDIUM)); |
| 520 MockWrite writes[] = {CreateMockWrite(*req, 1)}; | 524 MockWrite writes[] = {CreateMockWrite(*req, 1)}; |
| 521 | 525 |
| 522 StaticSocketDataProvider data(reads, arraysize(reads), writes, | 526 StaticSocketDataProvider data(reads, arraysize(reads), writes, |
| 523 arraysize(writes)); | 527 arraysize(writes)); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 EXPECT_TRUE(sessionA->IsDraining()); | 610 EXPECT_TRUE(sessionA->IsDraining()); |
| 607 EXPECT_TRUE(sessionB->IsDraining()); | 611 EXPECT_TRUE(sessionB->IsDraining()); |
| 608 EXPECT_TRUE(sessionC->IsDraining()); | 612 EXPECT_TRUE(sessionC->IsDraining()); |
| 609 | 613 |
| 610 // Both streams were closed with an error. | 614 // Both streams were closed with an error. |
| 611 EXPECT_TRUE(delegateA.StreamIsClosed()); | 615 EXPECT_TRUE(delegateA.StreamIsClosed()); |
| 612 EXPECT_EQ(ERR_NETWORK_CHANGED, delegateA.WaitForClose()); | 616 EXPECT_EQ(ERR_NETWORK_CHANGED, delegateA.WaitForClose()); |
| 613 EXPECT_TRUE(delegateB.StreamIsClosed()); | 617 EXPECT_TRUE(delegateB.StreamIsClosed()); |
| 614 EXPECT_EQ(ERR_NETWORK_CHANGED, delegateB.WaitForClose()); | 618 EXPECT_EQ(ERR_NETWORK_CHANGED, delegateB.WaitForClose()); |
| 615 #endif // defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_IOS) | 619 #endif // defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_IOS) |
| 620 SpdySession::SetPriorityDependencyDefaultForTesting(false); |
| 616 } | 621 } |
| 617 | 622 |
| 618 } // namespace | |
| 619 | |
| 620 } // namespace net | 623 } // namespace net |
| OLD | NEW |