OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "net/base/test_data_directory.h" | 10 #include "net/base/test_data_directory.h" |
(...skipping 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2480 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 2480 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
2481 | 2481 |
2482 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2482 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
2483 EXPECT_TRUE(stream.get()); | 2483 EXPECT_TRUE(stream.get()); |
2484 HttpRequestInfo request_info; | 2484 HttpRequestInfo request_info; |
2485 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2485 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
2486 net_log_, CompletionCallback())); | 2486 net_log_, CompletionCallback())); |
2487 | 2487 |
2488 DVLOG(1) | 2488 DVLOG(1) |
2489 << "Created 1st session and initialized a stream. Now trigger timeout"; | 2489 << "Created 1st session and initialized a stream. Now trigger timeout"; |
2490 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2490 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, false); |
2491 // Need to spin the loop now to ensure that | 2491 // Need to spin the loop now to ensure that |
2492 // QuicStreamFactory::OnSessionClosed() runs. | 2492 // QuicStreamFactory::OnSessionClosed() runs. |
2493 base::RunLoop run_loop; | 2493 base::RunLoop run_loop; |
2494 run_loop.RunUntilIdle(); | 2494 run_loop.RunUntilIdle(); |
2495 | 2495 |
2496 EXPECT_EQ( | 2496 EXPECT_EQ( |
2497 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 2497 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
2498 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2498 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
2499 host_port_pair_.port())); | 2499 host_port_pair_.port())); |
2500 | 2500 |
2501 // Test two-in-a-row timeouts with open streams. | 2501 // Test two-in-a-row timeouts with open streams. |
2502 DVLOG(1) << "Create 2nd session and timeout with open stream"; | 2502 DVLOG(1) << "Create 2nd session and timeout with open stream"; |
2503 TestCompletionCallback callback2; | 2503 TestCompletionCallback callback2; |
2504 QuicStreamRequest request2(factory_.get()); | 2504 QuicStreamRequest request2(factory_.get()); |
2505 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 2505 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
2506 /*cert_verify_flags=*/0, server2.host(), "GET", | 2506 /*cert_verify_flags=*/0, server2.host(), "GET", |
2507 net_log_, callback2.callback())); | 2507 net_log_, callback2.callback())); |
2508 QuicChromiumClientSession* session2 = | 2508 QuicChromiumClientSession* session2 = |
2509 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); | 2509 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); |
2510 | 2510 |
2511 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 2511 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
2512 EXPECT_TRUE(stream2.get()); | 2512 EXPECT_TRUE(stream2.get()); |
2513 EXPECT_EQ(OK, stream2->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2513 EXPECT_EQ(OK, stream2->InitializeStream(&request_info, DEFAULT_PRIORITY, |
2514 net_log_, CompletionCallback())); | 2514 net_log_, CompletionCallback())); |
2515 | 2515 |
2516 session2->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2516 session2->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, false); |
2517 // Need to spin the loop now to ensure that | 2517 // Need to spin the loop now to ensure that |
2518 // QuicStreamFactory::OnSessionClosed() runs. | 2518 // QuicStreamFactory::OnSessionClosed() runs. |
2519 base::RunLoop run_loop2; | 2519 base::RunLoop run_loop2; |
2520 run_loop2.RunUntilIdle(); | 2520 run_loop2.RunUntilIdle(); |
2521 EXPECT_EQ( | 2521 EXPECT_EQ( |
2522 2, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 2522 2, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
2523 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2523 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
2524 host_port_pair_.port())); | 2524 host_port_pair_.port())); |
2525 EXPECT_EQ(QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS, | 2525 EXPECT_EQ(QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS, |
2526 factory_->QuicDisabledReason(host_port_pair_.port())); | 2526 factory_->QuicDisabledReason(host_port_pair_.port())); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2691 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 2691 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
2692 | 2692 |
2693 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2693 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
2694 EXPECT_TRUE(stream.get()); | 2694 EXPECT_TRUE(stream.get()); |
2695 HttpRequestInfo request_info; | 2695 HttpRequestInfo request_info; |
2696 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2696 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
2697 net_log_, CompletionCallback())); | 2697 net_log_, CompletionCallback())); |
2698 | 2698 |
2699 DVLOG(1) | 2699 DVLOG(1) |
2700 << "Created 1st session and initialized a stream. Now trigger timeout"; | 2700 << "Created 1st session and initialized a stream. Now trigger timeout"; |
2701 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2701 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, false); |
2702 // Need to spin the loop now to ensure that | 2702 // Need to spin the loop now to ensure that |
2703 // QuicStreamFactory::OnSessionClosed() runs. | 2703 // QuicStreamFactory::OnSessionClosed() runs. |
2704 base::RunLoop run_loop; | 2704 base::RunLoop run_loop; |
2705 run_loop.RunUntilIdle(); | 2705 run_loop.RunUntilIdle(); |
2706 | 2706 |
2707 EXPECT_EQ( | 2707 EXPECT_EQ( |
2708 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 2708 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
2709 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2709 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
2710 host_port_pair_.port())); | 2710 host_port_pair_.port())); |
2711 | 2711 |
(...skipping 25 matching lines...) Expand all Loading... |
2737 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, | 2737 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
2738 /*cert_verify_flags=*/0, server3.host(), "GET", | 2738 /*cert_verify_flags=*/0, server3.host(), "GET", |
2739 net_log_, callback3.callback())); | 2739 net_log_, callback3.callback())); |
2740 QuicChromiumClientSession* session3 = | 2740 QuicChromiumClientSession* session3 = |
2741 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); | 2741 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); |
2742 | 2742 |
2743 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 2743 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
2744 EXPECT_TRUE(stream3.get()); | 2744 EXPECT_TRUE(stream3.get()); |
2745 EXPECT_EQ(OK, stream3->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2745 EXPECT_EQ(OK, stream3->InitializeStream(&request_info, DEFAULT_PRIORITY, |
2746 net_log_, CompletionCallback())); | 2746 net_log_, CompletionCallback())); |
2747 session3->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2747 session3->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, false); |
2748 // Need to spin the loop now to ensure that | 2748 // Need to spin the loop now to ensure that |
2749 // QuicStreamFactory::OnSessionClosed() runs. | 2749 // QuicStreamFactory::OnSessionClosed() runs. |
2750 base::RunLoop run_loop3; | 2750 base::RunLoop run_loop3; |
2751 run_loop3.RunUntilIdle(); | 2751 run_loop3.RunUntilIdle(); |
2752 EXPECT_EQ( | 2752 EXPECT_EQ( |
2753 2, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 2753 2, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
2754 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2754 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
2755 host_port_pair_.port())); | 2755 host_port_pair_.port())); |
2756 EXPECT_EQ(QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS, | 2756 EXPECT_EQ(QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS, |
2757 factory_->QuicDisabledReason(host_port_pair_.port())); | 2757 factory_->QuicDisabledReason(host_port_pair_.port())); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 | 2800 |
2801 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2801 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
2802 EXPECT_TRUE(stream.get()); | 2802 EXPECT_TRUE(stream.get()); |
2803 HttpRequestInfo request_info; | 2803 HttpRequestInfo request_info; |
2804 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2804 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
2805 net_log_, CompletionCallback())); | 2805 net_log_, CompletionCallback())); |
2806 | 2806 |
2807 DVLOG(1) | 2807 DVLOG(1) |
2808 << "Created 1st session and initialized a stream. Now trigger timeout." | 2808 << "Created 1st session and initialized a stream. Now trigger timeout." |
2809 << "Will disable QUIC."; | 2809 << "Will disable QUIC."; |
2810 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2810 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, false); |
2811 // Need to spin the loop now to ensure that | 2811 // Need to spin the loop now to ensure that |
2812 // QuicStreamFactory::OnSessionClosed() runs. | 2812 // QuicStreamFactory::OnSessionClosed() runs. |
2813 base::RunLoop run_loop; | 2813 base::RunLoop run_loop; |
2814 run_loop.RunUntilIdle(); | 2814 run_loop.RunUntilIdle(); |
2815 | 2815 |
2816 EXPECT_EQ( | 2816 EXPECT_EQ( |
2817 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 2817 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
2818 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2818 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
2819 host_port_pair_.port())); | 2819 host_port_pair_.port())); |
2820 | 2820 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 3017 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
3018 | 3018 |
3019 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 3019 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
3020 EXPECT_TRUE(stream.get()); | 3020 EXPECT_TRUE(stream.get()); |
3021 HttpRequestInfo request_info; | 3021 HttpRequestInfo request_info; |
3022 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 3022 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
3023 net_log_, CompletionCallback())); | 3023 net_log_, CompletionCallback())); |
3024 | 3024 |
3025 DVLOG(1) | 3025 DVLOG(1) |
3026 << "Created 1st session and initialized a stream. Now trigger timeout"; | 3026 << "Created 1st session and initialized a stream. Now trigger timeout"; |
3027 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 3027 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, false); |
3028 // Need to spin the loop now to ensure that | 3028 // Need to spin the loop now to ensure that |
3029 // QuicStreamFactory::OnSessionClosed() runs. | 3029 // QuicStreamFactory::OnSessionClosed() runs. |
3030 base::RunLoop run_loop; | 3030 base::RunLoop run_loop; |
3031 run_loop.RunUntilIdle(); | 3031 run_loop.RunUntilIdle(); |
3032 | 3032 |
3033 EXPECT_EQ( | 3033 EXPECT_EQ( |
3034 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 3034 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
3035 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 3035 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
3036 host_port_pair_.port())); | 3036 host_port_pair_.port())); |
3037 | 3037 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3080 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, | 3080 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, |
3081 /*cert_verify_flags=*/0, server4.host(), "GET", | 3081 /*cert_verify_flags=*/0, server4.host(), "GET", |
3082 net_log_, callback4.callback())); | 3082 net_log_, callback4.callback())); |
3083 QuicChromiumClientSession* session4 = | 3083 QuicChromiumClientSession* session4 = |
3084 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server4); | 3084 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server4); |
3085 | 3085 |
3086 scoped_ptr<QuicHttpStream> stream4 = request4.ReleaseStream(); | 3086 scoped_ptr<QuicHttpStream> stream4 = request4.ReleaseStream(); |
3087 EXPECT_TRUE(stream4.get()); | 3087 EXPECT_TRUE(stream4.get()); |
3088 EXPECT_EQ(OK, stream4->InitializeStream(&request_info, DEFAULT_PRIORITY, | 3088 EXPECT_EQ(OK, stream4->InitializeStream(&request_info, DEFAULT_PRIORITY, |
3089 net_log_, CompletionCallback())); | 3089 net_log_, CompletionCallback())); |
3090 session4->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 3090 session4->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, false); |
3091 // Need to spin the loop now to ensure that | 3091 // Need to spin the loop now to ensure that |
3092 // QuicStreamFactory::OnSessionClosed() runs. | 3092 // QuicStreamFactory::OnSessionClosed() runs. |
3093 base::RunLoop run_loop4; | 3093 base::RunLoop run_loop4; |
3094 run_loop4.RunUntilIdle(); | 3094 run_loop4.RunUntilIdle(); |
3095 EXPECT_EQ( | 3095 EXPECT_EQ( |
3096 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 3096 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
3097 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 3097 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
3098 host_port_pair_.port())); | 3098 host_port_pair_.port())); |
3099 | 3099 |
3100 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 3100 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3349 EXPECT_EQ(1u, observer.executed_count()); | 3349 EXPECT_EQ(1u, observer.executed_count()); |
3350 | 3350 |
3351 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 3351 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
3352 EXPECT_TRUE(stream.get()); | 3352 EXPECT_TRUE(stream.get()); |
3353 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 3353 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
3354 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 3354 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
3355 } | 3355 } |
3356 | 3356 |
3357 } // namespace test | 3357 } // namespace test |
3358 } // namespace net | 3358 } // namespace net |
OLD | NEW |