| 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_chromium_client_session.h" | 5 #include "net/quic/chromium/quic_chromium_client_session.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 DatagramClientSocket* socket, | 145 DatagramClientSocket* socket, |
| 146 QuicChromiumClientSession* session) const { | 146 QuicChromiumClientSession* session) const { |
| 147 std::unique_ptr<QuicChromiumPacketWriter> writer( | 147 std::unique_ptr<QuicChromiumPacketWriter> writer( |
| 148 new QuicChromiumPacketWriter(socket)); | 148 new QuicChromiumPacketWriter(socket)); |
| 149 writer->set_delegate(session); | 149 writer->set_delegate(session); |
| 150 return writer.release(); | 150 return writer.release(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 QuicCryptoClientConfig crypto_config_; | 153 QuicCryptoClientConfig crypto_config_; |
| 154 TestNetLog net_log_; | 154 TestNetLog net_log_; |
| 155 BoundTestNetLog bound_net_log_; | 155 BoundTestNetLog bound_test_net_log_; |
| 156 MockClientSocketFactory socket_factory_; | 156 MockClientSocketFactory socket_factory_; |
| 157 std::unique_ptr<MockRead> default_read_; | 157 std::unique_ptr<MockRead> default_read_; |
| 158 std::unique_ptr<SequencedSocketData> socket_data_; | 158 std::unique_ptr<SequencedSocketData> socket_data_; |
| 159 MockClock clock_; | 159 MockClock clock_; |
| 160 MockRandom random_; | 160 MockRandom random_; |
| 161 QuicChromiumConnectionHelper helper_; | 161 QuicChromiumConnectionHelper helper_; |
| 162 QuicChromiumAlarmFactory alarm_factory_; | 162 QuicChromiumAlarmFactory alarm_factory_; |
| 163 TransportSecurityState transport_security_state_; | 163 TransportSecurityState transport_security_state_; |
| 164 MockCryptoClientStreamFactory crypto_client_stream_factory_; | 164 MockCryptoClientStreamFactory crypto_client_stream_factory_; |
| 165 std::unique_ptr<QuicChromiumClientSession> session_; | 165 std::unique_ptr<QuicChromiumClientSession> session_; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 base::Bind(&base::RandInt), | 415 base::Bind(&base::RandInt), |
| 416 &net_log_, NetLog::Source()); | 416 &net_log_, NetLog::Source()); |
| 417 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); | 417 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); |
| 418 | 418 |
| 419 // Create reader and writer. | 419 // Create reader and writer. |
| 420 std::unique_ptr<QuicChromiumPacketReader> new_reader( | 420 std::unique_ptr<QuicChromiumPacketReader> new_reader( |
| 421 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), | 421 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), |
| 422 kQuicYieldAfterPacketsRead, | 422 kQuicYieldAfterPacketsRead, |
| 423 QuicTime::Delta::FromMilliseconds( | 423 QuicTime::Delta::FromMilliseconds( |
| 424 kQuicYieldAfterDurationMilliseconds), | 424 kQuicYieldAfterDurationMilliseconds), |
| 425 bound_net_log_.bound())); | 425 bound_test_net_log_.bound())); |
| 426 std::unique_ptr<QuicChromiumPacketWriter> new_writer( | 426 std::unique_ptr<QuicChromiumPacketWriter> new_writer( |
| 427 CreateQuicChromiumPacketWriter(new_socket.get(), session_.get())); | 427 CreateQuicChromiumPacketWriter(new_socket.get(), session_.get())); |
| 428 | 428 |
| 429 // Migrate session. | 429 // Migrate session. |
| 430 EXPECT_TRUE(session_->MigrateToSocket( | 430 EXPECT_TRUE(session_->MigrateToSocket( |
| 431 std::move(new_socket), std::move(new_reader), std::move(new_writer))); | 431 std::move(new_socket), std::move(new_reader), std::move(new_writer))); |
| 432 // Spin message loop to complete migration. | 432 // Spin message loop to complete migration. |
| 433 base::RunLoop().RunUntilIdle(); | 433 base::RunLoop().RunUntilIdle(); |
| 434 | 434 |
| 435 // Write data to session. | 435 // Write data to session. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 465 base::Bind(&base::RandInt), | 465 base::Bind(&base::RandInt), |
| 466 &net_log_, NetLog::Source()); | 466 &net_log_, NetLog::Source()); |
| 467 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); | 467 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); |
| 468 | 468 |
| 469 // Create reader and writer. | 469 // Create reader and writer. |
| 470 std::unique_ptr<QuicChromiumPacketReader> new_reader( | 470 std::unique_ptr<QuicChromiumPacketReader> new_reader( |
| 471 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), | 471 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), |
| 472 kQuicYieldAfterPacketsRead, | 472 kQuicYieldAfterPacketsRead, |
| 473 QuicTime::Delta::FromMilliseconds( | 473 QuicTime::Delta::FromMilliseconds( |
| 474 kQuicYieldAfterDurationMilliseconds), | 474 kQuicYieldAfterDurationMilliseconds), |
| 475 bound_net_log_.bound())); | 475 bound_test_net_log_.bound())); |
| 476 std::unique_ptr<QuicChromiumPacketWriter> new_writer( | 476 std::unique_ptr<QuicChromiumPacketWriter> new_writer( |
| 477 CreateQuicChromiumPacketWriter(new_socket.get(), session_.get())); | 477 CreateQuicChromiumPacketWriter(new_socket.get(), session_.get())); |
| 478 | 478 |
| 479 // Migrate session. | 479 // Migrate session. |
| 480 if (i < kMaxReadersPerQuicSession - 1) { | 480 if (i < kMaxReadersPerQuicSession - 1) { |
| 481 EXPECT_TRUE(session_->MigrateToSocket( | 481 EXPECT_TRUE(session_->MigrateToSocket( |
| 482 std::move(new_socket), std::move(new_reader), std::move(new_writer))); | 482 std::move(new_socket), std::move(new_reader), std::move(new_writer))); |
| 483 // Spin message loop to complete migration. | 483 // Spin message loop to complete migration. |
| 484 base::RunLoop().RunUntilIdle(); | 484 base::RunLoop().RunUntilIdle(); |
| 485 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 485 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 base::Bind(&base::RandInt), | 526 base::Bind(&base::RandInt), |
| 527 &net_log_, NetLog::Source()); | 527 &net_log_, NetLog::Source()); |
| 528 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); | 528 EXPECT_THAT(new_socket->Connect(kIpEndPoint), IsOk()); |
| 529 | 529 |
| 530 // Create reader and writer. | 530 // Create reader and writer. |
| 531 std::unique_ptr<QuicChromiumPacketReader> new_reader( | 531 std::unique_ptr<QuicChromiumPacketReader> new_reader( |
| 532 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), | 532 new QuicChromiumPacketReader(new_socket.get(), &clock_, session_.get(), |
| 533 kQuicYieldAfterPacketsRead, | 533 kQuicYieldAfterPacketsRead, |
| 534 QuicTime::Delta::FromMilliseconds( | 534 QuicTime::Delta::FromMilliseconds( |
| 535 kQuicYieldAfterDurationMilliseconds), | 535 kQuicYieldAfterDurationMilliseconds), |
| 536 bound_net_log_.bound())); | 536 bound_test_net_log_.bound())); |
| 537 std::unique_ptr<QuicChromiumPacketWriter> new_writer( | 537 std::unique_ptr<QuicChromiumPacketWriter> new_writer( |
| 538 CreateQuicChromiumPacketWriter(new_socket.get(), session_.get())); | 538 CreateQuicChromiumPacketWriter(new_socket.get(), session_.get())); |
| 539 | 539 |
| 540 // Store old socket and migrate session. | 540 // Store old socket and migrate session. |
| 541 EXPECT_TRUE(session_->MigrateToSocket( | 541 EXPECT_TRUE(session_->MigrateToSocket( |
| 542 std::move(new_socket), std::move(new_reader), std::move(new_writer))); | 542 std::move(new_socket), std::move(new_reader), std::move(new_writer))); |
| 543 // Spin message loop to complete migration. | 543 // Spin message loop to complete migration. |
| 544 base::RunLoop().RunUntilIdle(); | 544 base::RunLoop().RunUntilIdle(); |
| 545 | 545 |
| 546 // Read error on old socket does not impact session. | 546 // Read error on old socket does not impact session. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 558 | 558 |
| 559 EXPECT_TRUE(socket_data_->AllReadDataConsumed()); | 559 EXPECT_TRUE(socket_data_->AllReadDataConsumed()); |
| 560 EXPECT_TRUE(socket_data_->AllWriteDataConsumed()); | 560 EXPECT_TRUE(socket_data_->AllWriteDataConsumed()); |
| 561 EXPECT_TRUE(new_socket_data.AllReadDataConsumed()); | 561 EXPECT_TRUE(new_socket_data.AllReadDataConsumed()); |
| 562 EXPECT_TRUE(new_socket_data.AllWriteDataConsumed()); | 562 EXPECT_TRUE(new_socket_data.AllWriteDataConsumed()); |
| 563 } | 563 } |
| 564 | 564 |
| 565 } // namespace | 565 } // namespace |
| 566 } // namespace test | 566 } // namespace test |
| 567 } // namespace net | 567 } // namespace net |
| OLD | NEW |