| 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_chromium_client_session.h" | 5 #include "net/quic/quic_chromium_client_session.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "net/base/socket_performance_watcher.h" | 14 #include "net/base/socket_performance_watcher.h" |
| 15 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
| 16 #include "net/base/test_data_directory.h" | 16 #include "net/base/test_data_directory.h" |
| 17 #include "net/cert/cert_verify_result.h" | 17 #include "net/cert/cert_verify_result.h" |
| 18 #include "net/http/transport_security_state.h" | 18 #include "net/http/transport_security_state.h" |
| 19 #include "net/log/test_net_log.h" | 19 #include "net/log/test_net_log.h" |
| 20 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 20 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
| 21 #include "net/quic/crypto/crypto_protocol.h" | 21 #include "net/quic/crypto/crypto_protocol.h" |
| 22 #include "net/quic/crypto/proof_verifier_chromium.h" | 22 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 23 #include "net/quic/crypto/quic_decrypter.h" | 23 #include "net/quic/crypto/quic_decrypter.h" |
| 24 #include "net/quic/crypto/quic_encrypter.h" | 24 #include "net/quic/crypto/quic_encrypter.h" |
| 25 #include "net/quic/crypto/quic_server_info.h" | 25 #include "net/quic/crypto/quic_server_info.h" |
| 26 #include "net/quic/quic_chromium_alarm_factory.h" |
| 26 #include "net/quic/quic_chromium_connection_helper.h" | 27 #include "net/quic/quic_chromium_connection_helper.h" |
| 27 #include "net/quic/quic_chromium_packet_reader.h" | 28 #include "net/quic/quic_chromium_packet_reader.h" |
| 28 #include "net/quic/quic_chromium_packet_writer.h" | 29 #include "net/quic/quic_chromium_packet_writer.h" |
| 29 #include "net/quic/quic_crypto_client_stream_factory.h" | 30 #include "net/quic/quic_crypto_client_stream_factory.h" |
| 30 #include "net/quic/quic_flags.h" | 31 #include "net/quic/quic_flags.h" |
| 31 #include "net/quic/quic_http_utils.h" | 32 #include "net/quic/quic_http_utils.h" |
| 32 #include "net/quic/quic_packet_writer.h" | 33 #include "net/quic/quic_packet_writer.h" |
| 33 #include "net/quic/quic_protocol.h" | 34 #include "net/quic/quic_protocol.h" |
| 34 #include "net/quic/test_tools/crypto_test_utils.h" | 35 #include "net/quic/test_tools/crypto_test_utils.h" |
| 35 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" | 36 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 56 | 57 |
| 57 class QuicChromiumClientSessionTest | 58 class QuicChromiumClientSessionTest |
| 58 : public ::testing::TestWithParam<QuicVersion> { | 59 : public ::testing::TestWithParam<QuicVersion> { |
| 59 protected: | 60 protected: |
| 60 QuicChromiumClientSessionTest() | 61 QuicChromiumClientSessionTest() |
| 61 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), | 62 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), |
| 62 default_read_(new MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)), | 63 default_read_(new MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)), |
| 63 socket_data_( | 64 socket_data_( |
| 64 new SequencedSocketData(default_read_.get(), 1, nullptr, 0)), | 65 new SequencedSocketData(default_read_.get(), 1, nullptr, 0)), |
| 65 random_(0), | 66 random_(0), |
| 66 helper_(base::ThreadTaskRunnerHandle::Get().get(), &clock_, &random_), | 67 helper_(&clock_, &random_), |
| 68 alarm_factory_(base::ThreadTaskRunnerHandle::Get().get(), &clock_), |
| 67 maker_(GetParam(), 0, &clock_, kServerHostname) { | 69 maker_(GetParam(), 0, &clock_, kServerHostname) { |
| 68 // Advance the time, because timers do not like uninitialized times. | 70 // Advance the time, because timers do not like uninitialized times. |
| 69 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 71 clock_.AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 70 } | 72 } |
| 71 | 73 |
| 72 void Initialize() { | 74 void Initialize() { |
| 73 socket_factory_.AddSocketDataProvider(socket_data_.get()); | 75 socket_factory_.AddSocketDataProvider(socket_data_.get()); |
| 74 std::unique_ptr<DatagramClientSocket> socket = | 76 std::unique_ptr<DatagramClientSocket> socket = |
| 75 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND, | 77 socket_factory_.CreateDatagramClientSocket(DatagramSocket::DEFAULT_BIND, |
| 76 base::Bind(&base::RandInt), | 78 base::Bind(&base::RandInt), |
| 77 &net_log_, NetLog::Source()); | 79 &net_log_, NetLog::Source()); |
| 78 socket->Connect(kIpEndPoint); | 80 socket->Connect(kIpEndPoint); |
| 79 QuicChromiumPacketWriter* writer = | 81 QuicChromiumPacketWriter* writer = |
| 80 new net::QuicChromiumPacketWriter(socket.get()); | 82 new net::QuicChromiumPacketWriter(socket.get()); |
| 81 QuicConnection* connection = new QuicConnection( | 83 QuicConnection* connection = new QuicConnection( |
| 82 0, kIpEndPoint, &helper_, writer, true, Perspective::IS_CLIENT, | 84 0, kIpEndPoint, &helper_, &alarm_factory_, writer, true, |
| 83 SupportedVersions(GetParam())); | 85 Perspective::IS_CLIENT, SupportedVersions(GetParam())); |
| 84 writer->SetConnection(connection); | 86 writer->SetConnection(connection); |
| 85 session_.reset(new QuicChromiumClientSession( | 87 session_.reset(new QuicChromiumClientSession( |
| 86 connection, std::move(socket), | 88 connection, std::move(socket), |
| 87 /*stream_factory=*/nullptr, &crypto_client_stream_factory_, &clock_, | 89 /*stream_factory=*/nullptr, &crypto_client_stream_factory_, &clock_, |
| 88 &transport_security_state_, base::WrapUnique((QuicServerInfo*)nullptr), | 90 &transport_security_state_, base::WrapUnique((QuicServerInfo*)nullptr), |
| 89 QuicServerId(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED), | 91 QuicServerId(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED), |
| 90 kQuicYieldAfterPacketsRead, | 92 kQuicYieldAfterPacketsRead, |
| 91 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), | 93 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), |
| 92 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, | 94 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, |
| 93 "CONNECTION_UNKNOWN", base::TimeTicks::Now(), &push_promise_index_, | 95 "CONNECTION_UNKNOWN", base::TimeTicks::Now(), &push_promise_index_, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 120 | 122 |
| 121 QuicCryptoClientConfig crypto_config_; | 123 QuicCryptoClientConfig crypto_config_; |
| 122 TestNetLog net_log_; | 124 TestNetLog net_log_; |
| 123 BoundTestNetLog bound_net_log_; | 125 BoundTestNetLog bound_net_log_; |
| 124 MockClientSocketFactory socket_factory_; | 126 MockClientSocketFactory socket_factory_; |
| 125 std::unique_ptr<MockRead> default_read_; | 127 std::unique_ptr<MockRead> default_read_; |
| 126 std::unique_ptr<SequencedSocketData> socket_data_; | 128 std::unique_ptr<SequencedSocketData> socket_data_; |
| 127 MockClock clock_; | 129 MockClock clock_; |
| 128 MockRandom random_; | 130 MockRandom random_; |
| 129 QuicChromiumConnectionHelper helper_; | 131 QuicChromiumConnectionHelper helper_; |
| 132 QuicChromiumAlarmFactory alarm_factory_; |
| 130 TransportSecurityState transport_security_state_; | 133 TransportSecurityState transport_security_state_; |
| 131 MockCryptoClientStreamFactory crypto_client_stream_factory_; | 134 MockCryptoClientStreamFactory crypto_client_stream_factory_; |
| 132 std::unique_ptr<QuicChromiumClientSession> session_; | 135 std::unique_ptr<QuicChromiumClientSession> session_; |
| 133 QuicConnectionVisitorInterface* visitor_; | 136 QuicConnectionVisitorInterface* visitor_; |
| 134 TestCompletionCallback callback_; | 137 TestCompletionCallback callback_; |
| 135 QuicTestPacketMaker maker_; | 138 QuicTestPacketMaker maker_; |
| 136 ProofVerifyDetailsChromium verify_details_; | 139 ProofVerifyDetailsChromium verify_details_; |
| 137 QuicClientPushPromiseIndex push_promise_index_; | 140 QuicClientPushPromiseIndex push_promise_index_; |
| 138 }; | 141 }; |
| 139 | 142 |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 session_->connection()->SendPing(); | 531 session_->connection()->SendPing(); |
| 529 EXPECT_FALSE(session_->connection()->connected()); | 532 EXPECT_FALSE(session_->connection()->connected()); |
| 530 | 533 |
| 531 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 534 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 532 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 535 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 533 } | 536 } |
| 534 | 537 |
| 535 } // namespace | 538 } // namespace |
| 536 } // namespace test | 539 } // namespace test |
| 537 } // namespace net | 540 } // namespace net |
| OLD | NEW |