| 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 596 |
| 597 session->OnGoAway(QuicGoAwayFrame()); | 597 session->OnGoAway(QuicGoAwayFrame()); |
| 598 | 598 |
| 599 EXPECT_FALSE( | 599 EXPECT_FALSE( |
| 600 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 600 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 601 | 601 |
| 602 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 602 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 603 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 603 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 604 } | 604 } |
| 605 | 605 |
| 606 TEST_P(QuicStreamFactoryTest, GoAwayForConnectionMigrationWithPortOnly) { |
| 607 Initialize(); |
| 608 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 609 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 610 |
| 611 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 612 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 613 socket_factory_.AddSocketDataProvider(&socket_data); |
| 614 |
| 615 QuicStreamRequest request(factory_.get()); |
| 616 EXPECT_EQ(ERR_IO_PENDING, |
| 617 request.Request(host_port_pair_, privacy_mode_, |
| 618 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 619 callback_.callback())); |
| 620 |
| 621 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 622 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 623 EXPECT_TRUE(stream.get()); |
| 624 |
| 625 QuicChromiumClientSession* session = |
| 626 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 627 |
| 628 session->OnGoAway( |
| 629 QuicGoAwayFrame(QUIC_ERROR_MIGRATING_PORT, 0, |
| 630 "peer connection migration due to port change only")); |
| 631 NetErrorDetails details; |
| 632 EXPECT_FALSE(details.quic_port_migration_detected); |
| 633 session->PopulateNetErrorDetails(&details); |
| 634 EXPECT_TRUE(details.quic_port_migration_detected); |
| 635 details.quic_port_migration_detected = false; |
| 636 stream->PopulateNetErrorDetails(&details); |
| 637 EXPECT_TRUE(details.quic_port_migration_detected); |
| 638 |
| 639 EXPECT_FALSE( |
| 640 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 641 |
| 642 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 643 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 644 } |
| 645 |
| 606 TEST_P(QuicStreamFactoryTest, Pooling) { | 646 TEST_P(QuicStreamFactoryTest, Pooling) { |
| 607 Initialize(); | 647 Initialize(); |
| 608 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 648 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 609 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 649 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 610 | 650 |
| 611 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 651 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 612 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 652 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 613 socket_factory_.AddSocketDataProvider(&socket_data); | 653 socket_factory_.AddSocketDataProvider(&socket_data); |
| 614 | 654 |
| 615 HostPortPair server2(kServer2HostName, kDefaultServerPort); | 655 HostPortPair server2(kServer2HostName, kDefaultServerPort); |
| (...skipping 3246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3862 EXPECT_TRUE(stream2.get()); | 3902 EXPECT_TRUE(stream2.get()); |
| 3863 | 3903 |
| 3864 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 3904 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 3865 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 3905 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 3866 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 3906 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 3867 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 3907 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 3868 } | 3908 } |
| 3869 | 3909 |
| 3870 } // namespace test | 3910 } // namespace test |
| 3871 } // namespace net | 3911 } // namespace net |
| OLD | NEW |