| 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/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "net/base/socket_performance_watcher.h" | 13 #include "net/base/socket_performance_watcher.h" |
| 14 #include "net/base/test_completion_callback.h" | 14 #include "net/base/test_completion_callback.h" |
| 15 #include "net/base/test_data_directory.h" | 15 #include "net/base/test_data_directory.h" |
| 16 #include "net/cert/cert_verify_result.h" | 16 #include "net/cert/cert_verify_result.h" |
| 17 #include "net/http/transport_security_state.h" | 17 #include "net/http/transport_security_state.h" |
| 18 #include "net/log/test_net_log.h" | 18 #include "net/log/test_net_log.h" |
| 19 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 19 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
| 20 #include "net/quic/crypto/crypto_protocol.h" | 20 #include "net/quic/crypto/crypto_protocol.h" |
| 21 #include "net/quic/crypto/proof_verifier_chromium.h" | 21 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 22 #include "net/quic/crypto/quic_decrypter.h" | 22 #include "net/quic/crypto/quic_decrypter.h" |
| 23 #include "net/quic/crypto/quic_encrypter.h" | 23 #include "net/quic/crypto/quic_encrypter.h" |
| 24 #include "net/quic/crypto/quic_server_info.h" | 24 #include "net/quic/crypto/quic_server_info.h" |
| 25 #include "net/quic/quic_connection_helper.h" | 25 #include "net/quic/quic_chromium_connection_helper.h" |
| 26 #include "net/quic/quic_crypto_client_stream_factory.h" | 26 #include "net/quic/quic_crypto_client_stream_factory.h" |
| 27 #include "net/quic/quic_default_packet_writer.h" | 27 #include "net/quic/quic_default_packet_writer.h" |
| 28 #include "net/quic/quic_flags.h" | 28 #include "net/quic/quic_flags.h" |
| 29 #include "net/quic/quic_http_utils.h" | 29 #include "net/quic/quic_http_utils.h" |
| 30 #include "net/quic/quic_packet_reader.h" | 30 #include "net/quic/quic_packet_reader.h" |
| 31 #include "net/quic/quic_packet_writer.h" | 31 #include "net/quic/quic_packet_writer.h" |
| 32 #include "net/quic/quic_protocol.h" | 32 #include "net/quic/quic_protocol.h" |
| 33 #include "net/quic/test_tools/crypto_test_utils.h" | 33 #include "net/quic/test_tools/crypto_test_utils.h" |
| 34 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" | 34 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" |
| 35 #include "net/quic/test_tools/quic_chromium_client_session_peer.h" | 35 #include "net/quic/test_tools/quic_chromium_client_session_peer.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 117 } |
| 118 | 118 |
| 119 QuicCryptoClientConfig crypto_config_; | 119 QuicCryptoClientConfig crypto_config_; |
| 120 TestNetLog net_log_; | 120 TestNetLog net_log_; |
| 121 BoundTestNetLog bound_net_log_; | 121 BoundTestNetLog bound_net_log_; |
| 122 MockClientSocketFactory socket_factory_; | 122 MockClientSocketFactory socket_factory_; |
| 123 scoped_ptr<MockRead> default_read_; | 123 scoped_ptr<MockRead> default_read_; |
| 124 scoped_ptr<SequencedSocketData> socket_data_; | 124 scoped_ptr<SequencedSocketData> socket_data_; |
| 125 MockClock clock_; | 125 MockClock clock_; |
| 126 MockRandom random_; | 126 MockRandom random_; |
| 127 QuicConnectionHelper helper_; | 127 QuicChromiumConnectionHelper helper_; |
| 128 TransportSecurityState transport_security_state_; | 128 TransportSecurityState transport_security_state_; |
| 129 MockCryptoClientStreamFactory crypto_client_stream_factory_; | 129 MockCryptoClientStreamFactory crypto_client_stream_factory_; |
| 130 scoped_ptr<QuicChromiumClientSession> session_; | 130 scoped_ptr<QuicChromiumClientSession> session_; |
| 131 QuicConnectionVisitorInterface* visitor_; | 131 QuicConnectionVisitorInterface* visitor_; |
| 132 TestCompletionCallback callback_; | 132 TestCompletionCallback callback_; |
| 133 QuicTestPacketMaker maker_; | 133 QuicTestPacketMaker maker_; |
| 134 ProofVerifyDetailsChromium verify_details_; | 134 ProofVerifyDetailsChromium verify_details_; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 INSTANTIATE_TEST_CASE_P(Tests, | 137 INSTANTIATE_TEST_CASE_P(Tests, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 149 1, true, kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT)); | 149 1, true, kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT)); |
| 150 MockWrite writes[] = { | 150 MockWrite writes[] = { |
| 151 MockWrite(ASYNC, client_rst->data(), client_rst->length(), 1)}; | 151 MockWrite(ASYNC, client_rst->data(), client_rst->length(), 1)}; |
| 152 socket_data_.reset(new SequencedSocketData(reads, arraysize(reads), writes, | 152 socket_data_.reset(new SequencedSocketData(reads, arraysize(reads), writes, |
| 153 arraysize(writes))); | 153 arraysize(writes))); |
| 154 | 154 |
| 155 Initialize(); | 155 Initialize(); |
| 156 CompleteCryptoHandshake(); | 156 CompleteCryptoHandshake(); |
| 157 const size_t kMaxOpenStreams = session_->get_max_open_streams(); | 157 const size_t kMaxOpenStreams = session_->get_max_open_streams(); |
| 158 | 158 |
| 159 std::vector<QuicReliableClientStream*> streams; | 159 std::vector<QuicChromiumClientStream*> streams; |
| 160 for (size_t i = 0; i < kMaxOpenStreams; i++) { | 160 for (size_t i = 0; i < kMaxOpenStreams; i++) { |
| 161 QuicReliableClientStream* stream = | 161 QuicChromiumClientStream* stream = |
| 162 session_->CreateOutgoingDynamicStream(kDefaultPriority); | 162 session_->CreateOutgoingDynamicStream(kDefaultPriority); |
| 163 EXPECT_TRUE(stream); | 163 EXPECT_TRUE(stream); |
| 164 streams.push_back(stream); | 164 streams.push_back(stream); |
| 165 } | 165 } |
| 166 EXPECT_FALSE(session_->CreateOutgoingDynamicStream(kDefaultPriority)); | 166 EXPECT_FALSE(session_->CreateOutgoingDynamicStream(kDefaultPriority)); |
| 167 | 167 |
| 168 EXPECT_EQ(kMaxOpenStreams, session_->GetNumOpenOutgoingStreams()); | 168 EXPECT_EQ(kMaxOpenStreams, session_->GetNumOpenOutgoingStreams()); |
| 169 | 169 |
| 170 // Close a stream and ensure I can now open a new one. | 170 // Close a stream and ensure I can now open a new one. |
| 171 QuicStreamId stream_id = streams[0]->id(); | 171 QuicStreamId stream_id = streams[0]->id(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 184 1, true, kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT)); | 184 1, true, kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT)); |
| 185 MockWrite writes[] = { | 185 MockWrite writes[] = { |
| 186 MockWrite(ASYNC, client_rst->data(), client_rst->length(), 1)}; | 186 MockWrite(ASYNC, client_rst->data(), client_rst->length(), 1)}; |
| 187 socket_data_.reset(new SequencedSocketData(reads, arraysize(reads), writes, | 187 socket_data_.reset(new SequencedSocketData(reads, arraysize(reads), writes, |
| 188 arraysize(writes))); | 188 arraysize(writes))); |
| 189 | 189 |
| 190 Initialize(); | 190 Initialize(); |
| 191 CompleteCryptoHandshake(); | 191 CompleteCryptoHandshake(); |
| 192 const size_t kMaxOpenStreams = session_->get_max_open_streams(); | 192 const size_t kMaxOpenStreams = session_->get_max_open_streams(); |
| 193 | 193 |
| 194 std::vector<QuicReliableClientStream*> streams; | 194 std::vector<QuicChromiumClientStream*> streams; |
| 195 for (size_t i = 0; i < kMaxOpenStreams; i++) { | 195 for (size_t i = 0; i < kMaxOpenStreams; i++) { |
| 196 QuicReliableClientStream* stream = | 196 QuicChromiumClientStream* stream = |
| 197 session_->CreateOutgoingDynamicStream(kDefaultPriority); | 197 session_->CreateOutgoingDynamicStream(kDefaultPriority); |
| 198 EXPECT_TRUE(stream); | 198 EXPECT_TRUE(stream); |
| 199 streams.push_back(stream); | 199 streams.push_back(stream); |
| 200 } | 200 } |
| 201 | 201 |
| 202 QuicReliableClientStream* stream; | 202 QuicChromiumClientStream* stream; |
| 203 QuicChromiumClientSession::StreamRequest stream_request; | 203 QuicChromiumClientSession::StreamRequest stream_request; |
| 204 TestCompletionCallback callback; | 204 TestCompletionCallback callback; |
| 205 ASSERT_EQ(ERR_IO_PENDING, | 205 ASSERT_EQ(ERR_IO_PENDING, |
| 206 stream_request.StartRequest(session_->GetWeakPtr(), &stream, | 206 stream_request.StartRequest(session_->GetWeakPtr(), &stream, |
| 207 callback.callback())); | 207 callback.callback())); |
| 208 | 208 |
| 209 // Close a stream and ensure I can now open a new one. | 209 // Close a stream and ensure I can now open a new one. |
| 210 QuicStreamId stream_id = streams[0]->id(); | 210 QuicStreamId stream_id = streams[0]->id(); |
| 211 session_->CloseStream(stream_id); | 211 session_->CloseStream(stream_id); |
| 212 QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0); | 212 QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 session_->connection()->SendPing(); | 516 session_->connection()->SendPing(); |
| 517 EXPECT_FALSE(session_->connection()->connected()); | 517 EXPECT_FALSE(session_->connection()->connected()); |
| 518 | 518 |
| 519 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 519 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 520 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 520 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 521 } | 521 } |
| 522 | 522 |
| 523 } // namespace | 523 } // namespace |
| 524 } // namespace test | 524 } // namespace test |
| 525 } // namespace net | 525 } // namespace net |
| OLD | NEW |