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/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <ostream> | 8 #include <ostream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 4611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4622 | 4622 |
4623 DVLOG(1) | 4623 DVLOG(1) |
4624 << "Created 1st session and initialized a stream. Now trigger timeout." | 4624 << "Created 1st session and initialized a stream. Now trigger timeout." |
4625 << "Will disable QUIC."; | 4625 << "Will disable QUIC."; |
4626 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, "test", | 4626 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, "test", |
4627 ConnectionCloseBehavior::SILENT_CLOSE); | 4627 ConnectionCloseBehavior::SILENT_CLOSE); |
4628 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4628 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4629 | 4629 |
4630 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); | 4630 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); |
4631 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(5), | 4631 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(5), |
4632 runner_->GetPostedTasks()[0].GetTimeToRun()); | 4632 runner_->GetPostedTasks()[0].first.GetTimeToRun()); |
4633 runner_->RunNextTask(); | 4633 runner_->RunNextTask(); |
4634 | 4634 |
4635 // Need to spin the loop now to ensure that | 4635 // Need to spin the loop now to ensure that |
4636 // QuicStreamFactory::OnSessionClosed() runs. | 4636 // QuicStreamFactory::OnSessionClosed() runs. |
4637 base::RunLoop run_loop; | 4637 base::RunLoop run_loop; |
4638 run_loop.RunUntilIdle(); | 4638 run_loop.RunUntilIdle(); |
4639 | 4639 |
4640 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4640 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4641 | 4641 |
4642 ASSERT_TRUE(runner_->GetPostedTasks().empty()); | 4642 ASSERT_TRUE(runner_->GetPostedTasks().empty()); |
4643 | 4643 |
4644 // Create a new session which will cause a task to be posted to | 4644 // Create a new session which will cause a task to be posted to |
4645 // clear the exponential backoff. | 4645 // clear the exponential backoff. |
4646 QuicStreamRequest request2(factory_.get()); | 4646 QuicStreamRequest request2(factory_.get()); |
4647 EXPECT_EQ(OK, request2.Request(host_port_pair_, privacy_mode_, | 4647 EXPECT_EQ(OK, request2.Request(host_port_pair_, privacy_mode_, |
4648 /*cert_verify_flags=*/0, url_, "GET", net_log_, | 4648 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
4649 callback_.callback())); | 4649 callback_.callback())); |
4650 QuicChromiumClientSession* session2 = GetActiveSession(host_port_pair_); | 4650 QuicChromiumClientSession* session2 = GetActiveSession(host_port_pair_); |
4651 std::unique_ptr<QuicHttpStream> stream2 = request2.CreateStream(); | 4651 std::unique_ptr<QuicHttpStream> stream2 = request2.CreateStream(); |
4652 EXPECT_TRUE(stream2.get()); | 4652 EXPECT_TRUE(stream2.get()); |
4653 HttpRequestInfo request_info2; | 4653 HttpRequestInfo request_info2; |
4654 EXPECT_EQ(OK, stream2->InitializeStream(&request_info2, DEFAULT_PRIORITY, | 4654 EXPECT_EQ(OK, stream2->InitializeStream(&request_info2, DEFAULT_PRIORITY, |
4655 net_log_, CompletionCallback())); | 4655 net_log_, CompletionCallback())); |
4656 | 4656 |
4657 // Check that the clear task has been posted. | 4657 // Check that the clear task has been posted. |
4658 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); | 4658 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); |
4659 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(5), | 4659 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(5), |
4660 runner_->GetPostedTasks()[0].GetTimeToRun()); | 4660 runner_->GetPostedTasks()[0].first.GetTimeToRun()); |
4661 | 4661 |
4662 session2->connection()->CloseConnection( | 4662 session2->connection()->CloseConnection( |
4663 QUIC_NETWORK_IDLE_TIMEOUT, "test", ConnectionCloseBehavior::SILENT_CLOSE); | 4663 QUIC_NETWORK_IDLE_TIMEOUT, "test", ConnectionCloseBehavior::SILENT_CLOSE); |
4664 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4664 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4665 | 4665 |
4666 ASSERT_EQ(2u, runner_->GetPostedTasks().size()); | 4666 ASSERT_EQ(2u, runner_->GetPostedTasks().size()); |
4667 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(10), | 4667 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(10), |
4668 runner_->GetPostedTasks()[1].GetTimeToRun()); | 4668 runner_->GetPostedTasks()[1].first.GetTimeToRun()); |
4669 runner_->RunNextTask(); | 4669 runner_->RunNextTask(); |
4670 | 4670 |
4671 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4671 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4672 | 4672 |
4673 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 4673 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
4674 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 4674 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
4675 } | 4675 } |
4676 | 4676 |
4677 TEST_P(QuicStreamFactoryTest, | 4677 TEST_P(QuicStreamFactoryTest, |
4678 DisableQuicWhenTimeoutsWithOpenStreamsExponentialBackoffReset) { | 4678 DisableQuicWhenTimeoutsWithOpenStreamsExponentialBackoffReset) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4722 | 4722 |
4723 DVLOG(1) | 4723 DVLOG(1) |
4724 << "Created 1st session and initialized a stream. Now trigger timeout." | 4724 << "Created 1st session and initialized a stream. Now trigger timeout." |
4725 << "Will disable QUIC."; | 4725 << "Will disable QUIC."; |
4726 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, "test", | 4726 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, "test", |
4727 ConnectionCloseBehavior::SILENT_CLOSE); | 4727 ConnectionCloseBehavior::SILENT_CLOSE); |
4728 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4728 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4729 | 4729 |
4730 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); | 4730 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); |
4731 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(5), | 4731 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(5), |
4732 runner_->GetPostedTasks()[0].GetTimeToRun()); | 4732 runner_->GetPostedTasks()[0].first.GetTimeToRun()); |
4733 runner_->RunNextTask(); | 4733 runner_->RunNextTask(); |
4734 | 4734 |
4735 // Need to spin the loop now to ensure that | 4735 // Need to spin the loop now to ensure that |
4736 // QuicStreamFactory::OnSessionClosed() runs. | 4736 // QuicStreamFactory::OnSessionClosed() runs. |
4737 base::RunLoop run_loop; | 4737 base::RunLoop run_loop; |
4738 run_loop.RunUntilIdle(); | 4738 run_loop.RunUntilIdle(); |
4739 | 4739 |
4740 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4740 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4741 | 4741 |
4742 ASSERT_TRUE(runner_->GetPostedTasks().empty()); | 4742 ASSERT_TRUE(runner_->GetPostedTasks().empty()); |
(...skipping 17 matching lines...) Expand all Loading... |
4760 | 4760 |
4761 // QUIC should still be enabled. | 4761 // QUIC should still be enabled. |
4762 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4762 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4763 | 4763 |
4764 session2->connection()->CloseConnection( | 4764 session2->connection()->CloseConnection( |
4765 QUIC_NETWORK_IDLE_TIMEOUT, "test", ConnectionCloseBehavior::SILENT_CLOSE); | 4765 QUIC_NETWORK_IDLE_TIMEOUT, "test", ConnectionCloseBehavior::SILENT_CLOSE); |
4766 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4766 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4767 | 4767 |
4768 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); | 4768 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); |
4769 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(5), | 4769 ASSERT_EQ(clock_->NowInTicks() + base::TimeDelta::FromMinutes(5), |
4770 runner_->GetPostedTasks()[0].GetTimeToRun()); | 4770 runner_->GetPostedTasks()[0].first.GetTimeToRun()); |
4771 runner_->RunNextTask(); | 4771 runner_->RunNextTask(); |
4772 | 4772 |
4773 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); | 4773 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get())); |
4774 | 4774 |
4775 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 4775 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
4776 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 4776 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
4777 } | 4777 } |
4778 | 4778 |
4779 TEST_P(QuicStreamFactoryTest, EnableDelayTcpRace) { | 4779 TEST_P(QuicStreamFactoryTest, EnableDelayTcpRace) { |
4780 Initialize(); | 4780 Initialize(); |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5557 // Clear all cached states. | 5557 // Clear all cached states. |
5558 factory_->ClearCachedStatesInCryptoConfig( | 5558 factory_->ClearCachedStatesInCryptoConfig( |
5559 base::Callback<bool(const GURL&)>()); | 5559 base::Callback<bool(const GURL&)>()); |
5560 EXPECT_TRUE(test_cases[0].state->certs().empty()); | 5560 EXPECT_TRUE(test_cases[0].state->certs().empty()); |
5561 EXPECT_TRUE(test_cases[1].state->certs().empty()); | 5561 EXPECT_TRUE(test_cases[1].state->certs().empty()); |
5562 EXPECT_TRUE(test_cases[2].state->certs().empty()); | 5562 EXPECT_TRUE(test_cases[2].state->certs().empty()); |
5563 } | 5563 } |
5564 | 5564 |
5565 } // namespace test | 5565 } // namespace test |
5566 } // namespace net | 5566 } // namespace net |
OLD | NEW |