| 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" |
| 11 #include "net/cert/cert_verifier.h" | 11 #include "net/cert/cert_verifier.h" |
| 12 #include "net/cert/multi_log_ct_verifier.h" | 12 #include "net/cert/multi_log_ct_verifier.h" |
| 13 #include "net/dns/mock_host_resolver.h" | 13 #include "net/dns/mock_host_resolver.h" |
| 14 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
| 15 #include "net/http/http_response_info.h" | 15 #include "net/http/http_response_info.h" |
| 16 #include "net/http/http_server_properties_impl.h" | 16 #include "net/http/http_server_properties_impl.h" |
| 17 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
| 18 #include "net/http/transport_security_state.h" | 18 #include "net/http/transport_security_state.h" |
| 19 #include "net/quic/crypto/crypto_handshake.h" | 19 #include "net/quic/crypto/crypto_handshake.h" |
| 20 #include "net/quic/crypto/proof_verifier_chromium.h" | 20 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 21 #include "net/quic/crypto/properties_based_quic_server_info.h" | 21 #include "net/quic/crypto/properties_based_quic_server_info.h" |
| 22 #include "net/quic/crypto/quic_crypto_client_config.h" | 22 #include "net/quic/crypto/quic_crypto_client_config.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_client_promised_info.h" |
| 26 #include "net/quic/quic_http_stream.h" | 27 #include "net/quic/quic_http_stream.h" |
| 27 #include "net/quic/quic_http_utils.h" | 28 #include "net/quic/quic_http_utils.h" |
| 28 #include "net/quic/quic_server_id.h" | 29 #include "net/quic/quic_server_id.h" |
| 29 #include "net/quic/test_tools/mock_clock.h" | 30 #include "net/quic/test_tools/mock_clock.h" |
| 30 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" | 31 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" |
| 31 #include "net/quic/test_tools/mock_random.h" | 32 #include "net/quic/test_tools/mock_random.h" |
| 32 #include "net/quic/test_tools/quic_stream_factory_peer.h" | 33 #include "net/quic/test_tools/quic_stream_factory_peer.h" |
| 33 #include "net/quic/test_tools/quic_test_packet_maker.h" | 34 #include "net/quic/test_tools/quic_test_packet_maker.h" |
| 34 #include "net/quic/test_tools/quic_test_utils.h" | 35 #include "net/quic/test_tools/quic_test_utils.h" |
| 35 #include "net/quic/test_tools/test_task_runner.h" | 36 #include "net/quic/test_tools/test_task_runner.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 49 namespace net { | 50 namespace net { |
| 50 | 51 |
| 51 namespace test { | 52 namespace test { |
| 52 | 53 |
| 53 namespace { | 54 namespace { |
| 54 const char kDefaultServerHostName[] = "www.example.org"; | 55 const char kDefaultServerHostName[] = "www.example.org"; |
| 55 const char kServer2HostName[] = "mail.example.org"; | 56 const char kServer2HostName[] = "mail.example.org"; |
| 56 const char kServer3HostName[] = "docs.example.org"; | 57 const char kServer3HostName[] = "docs.example.org"; |
| 57 const char kServer4HostName[] = "images.example.org"; | 58 const char kServer4HostName[] = "images.example.org"; |
| 58 const int kDefaultServerPort = 443; | 59 const int kDefaultServerPort = 443; |
| 60 const char kDefaultUrl[] = "https://www.example.org/"; |
| 61 const char kServer2Url[] = "https://mail.example.org/"; |
| 62 const char kServer3Url[] = "https://docs.example.org/"; |
| 63 const char kServer4Url[] = "https://images.example.org/"; |
| 59 | 64 |
| 60 // Run all tests with all the combinations of versions and | 65 // Run all tests with all the combinations of versions and |
| 61 // enable_connection_racing. | 66 // enable_connection_racing. |
| 62 struct TestParams { | 67 struct TestParams { |
| 63 TestParams(const QuicVersion version, bool enable_connection_racing) | 68 TestParams(const QuicVersion version, bool enable_connection_racing) |
| 64 : version(version), enable_connection_racing(enable_connection_racing) {} | 69 : version(version), enable_connection_racing(enable_connection_racing) {} |
| 65 | 70 |
| 66 friend ostream& operator<<(ostream& os, const TestParams& p) { | 71 friend ostream& operator<<(ostream& os, const TestParams& p) { |
| 67 os << "{ version: " << QuicVersionToString(p.version); | 72 os << "{ version: " << QuicVersionToString(p.version); |
| 68 os << " enable_connection_racing: " << p.enable_connection_racing << " }"; | 73 os << " enable_connection_racing: " << p.enable_connection_racing << " }"; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 runner_(new TestTaskRunner(clock_)), | 199 runner_(new TestTaskRunner(clock_)), |
| 195 maker_(GetParam().version, 0, clock_, kDefaultServerHostName), | 200 maker_(GetParam().version, 0, clock_, kDefaultServerHostName), |
| 196 cert_verifier_(CertVerifier::CreateDefault()), | 201 cert_verifier_(CertVerifier::CreateDefault()), |
| 197 channel_id_service_( | 202 channel_id_service_( |
| 198 new ChannelIDService(new DefaultChannelIDStore(nullptr), | 203 new ChannelIDService(new DefaultChannelIDStore(nullptr), |
| 199 base::ThreadTaskRunnerHandle::Get())), | 204 base::ThreadTaskRunnerHandle::Get())), |
| 200 cert_transparency_verifier_(new MultiLogCTVerifier()), | 205 cert_transparency_verifier_(new MultiLogCTVerifier()), |
| 201 scoped_mock_network_change_notifier_(nullptr), | 206 scoped_mock_network_change_notifier_(nullptr), |
| 202 factory_(nullptr), | 207 factory_(nullptr), |
| 203 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), | 208 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), |
| 209 url_(kDefaultUrl), |
| 210 url2_(kServer2Url), |
| 211 url3_(kServer3Url), |
| 212 url4_(kServer4Url), |
| 204 privacy_mode_(PRIVACY_MODE_DISABLED), | 213 privacy_mode_(PRIVACY_MODE_DISABLED), |
| 205 enable_port_selection_(true), | 214 enable_port_selection_(true), |
| 206 always_require_handshake_confirmation_(false), | 215 always_require_handshake_confirmation_(false), |
| 207 disable_connection_pooling_(false), | 216 disable_connection_pooling_(false), |
| 208 load_server_info_timeout_srtt_multiplier_(0.0f), | 217 load_server_info_timeout_srtt_multiplier_(0.0f), |
| 209 enable_connection_racing_(true), | 218 enable_connection_racing_(true), |
| 210 enable_non_blocking_io_(true), | 219 enable_non_blocking_io_(true), |
| 211 disable_disk_cache_(false), | 220 disable_disk_cache_(false), |
| 212 prefer_aes_(false), | 221 prefer_aes_(false), |
| 213 max_number_of_lossy_connections_(0), | 222 max_number_of_lossy_connections_(0), |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 bool goaway_received) { | 298 bool goaway_received) { |
| 290 // Should only be called if there is no active session for this destination. | 299 // Should only be called if there is no active session for this destination. |
| 291 EXPECT_FALSE(HasActiveSession(destination)); | 300 EXPECT_FALSE(HasActiveSession(destination)); |
| 292 size_t socket_count = socket_factory_.udp_client_socket_ports().size(); | 301 size_t socket_count = socket_factory_.udp_client_socket_ports().size(); |
| 293 | 302 |
| 294 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 303 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 295 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 304 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 296 socket_factory_.AddSocketDataProvider(&socket_data); | 305 socket_factory_.AddSocketDataProvider(&socket_data); |
| 297 | 306 |
| 298 QuicStreamRequest request(factory_.get()); | 307 QuicStreamRequest request(factory_.get()); |
| 308 GURL url("https://" + destination.host() + "/"); |
| 299 EXPECT_EQ(ERR_IO_PENDING, | 309 EXPECT_EQ(ERR_IO_PENDING, |
| 300 request.Request(destination, privacy_mode_, | 310 request.Request(destination, privacy_mode_, |
| 301 /*cert_verify_flags=*/0, destination.host(), | 311 /*cert_verify_flags=*/0, url, "GET", net_log_, |
| 302 "GET", net_log_, callback_.callback())); | 312 callback_.callback())); |
| 303 | 313 |
| 304 EXPECT_EQ(OK, callback_.WaitForResult()); | 314 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 305 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 315 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 306 EXPECT_TRUE(stream.get()); | 316 EXPECT_TRUE(stream.get()); |
| 307 stream.reset(); | 317 stream.reset(); |
| 308 | 318 |
| 309 QuicChromiumClientSession* session = | 319 QuicChromiumClientSession* session = |
| 310 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), destination); | 320 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), destination); |
| 311 | 321 |
| 312 if (socket_count + 1 != socket_factory_.udp_client_socket_ports().size()) { | 322 if (socket_count + 1 != socket_factory_.udp_client_socket_ports().size()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 QuicTestPacketMaker maker_; | 401 QuicTestPacketMaker maker_; |
| 392 HttpServerPropertiesImpl http_server_properties_; | 402 HttpServerPropertiesImpl http_server_properties_; |
| 393 scoped_ptr<CertVerifier> cert_verifier_; | 403 scoped_ptr<CertVerifier> cert_verifier_; |
| 394 scoped_ptr<ChannelIDService> channel_id_service_; | 404 scoped_ptr<ChannelIDService> channel_id_service_; |
| 395 TransportSecurityState transport_security_state_; | 405 TransportSecurityState transport_security_state_; |
| 396 scoped_ptr<CTVerifier> cert_transparency_verifier_; | 406 scoped_ptr<CTVerifier> cert_transparency_verifier_; |
| 397 scoped_ptr<ScopedMockNetworkChangeNotifier> | 407 scoped_ptr<ScopedMockNetworkChangeNotifier> |
| 398 scoped_mock_network_change_notifier_; | 408 scoped_mock_network_change_notifier_; |
| 399 scoped_ptr<QuicStreamFactory> factory_; | 409 scoped_ptr<QuicStreamFactory> factory_; |
| 400 HostPortPair host_port_pair_; | 410 HostPortPair host_port_pair_; |
| 411 GURL url_; |
| 412 GURL url2_; |
| 413 GURL url3_; |
| 414 GURL url4_; |
| 415 |
| 401 PrivacyMode privacy_mode_; | 416 PrivacyMode privacy_mode_; |
| 402 BoundNetLog net_log_; | 417 BoundNetLog net_log_; |
| 403 TestCompletionCallback callback_; | 418 TestCompletionCallback callback_; |
| 404 | 419 |
| 405 // Variables to configure QuicStreamFactory. | 420 // Variables to configure QuicStreamFactory. |
| 406 bool enable_port_selection_; | 421 bool enable_port_selection_; |
| 407 bool always_require_handshake_confirmation_; | 422 bool always_require_handshake_confirmation_; |
| 408 bool disable_connection_pooling_; | 423 bool disable_connection_pooling_; |
| 409 double load_server_info_timeout_srtt_multiplier_; | 424 double load_server_info_timeout_srtt_multiplier_; |
| 410 bool enable_connection_racing_; | 425 bool enable_connection_racing_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 434 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 449 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 435 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 450 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 436 | 451 |
| 437 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 452 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 438 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 453 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 439 socket_factory_.AddSocketDataProvider(&socket_data); | 454 socket_factory_.AddSocketDataProvider(&socket_data); |
| 440 | 455 |
| 441 QuicStreamRequest request(factory_.get()); | 456 QuicStreamRequest request(factory_.get()); |
| 442 EXPECT_EQ(ERR_IO_PENDING, | 457 EXPECT_EQ(ERR_IO_PENDING, |
| 443 request.Request(host_port_pair_, privacy_mode_, | 458 request.Request(host_port_pair_, privacy_mode_, |
| 444 /*cert_verify_flags=*/0, host_port_pair_.host(), | 459 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 445 "GET", net_log_, callback_.callback())); | 460 callback_.callback())); |
| 446 | 461 |
| 447 EXPECT_EQ(OK, callback_.WaitForResult()); | 462 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 448 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 463 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 449 EXPECT_TRUE(stream.get()); | 464 EXPECT_TRUE(stream.get()); |
| 450 | 465 |
| 451 // Will reset stream 3. | 466 // Will reset stream 3. |
| 452 stream = CreateFromSession(host_port_pair_); | 467 stream = CreateFromSession(host_port_pair_); |
| 453 EXPECT_TRUE(stream.get()); | 468 EXPECT_TRUE(stream.get()); |
| 454 | 469 |
| 455 // TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result | 470 // TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result |
| 456 // in streams on different sessions. | 471 // in streams on different sessions. |
| 457 QuicStreamRequest request2(factory_.get()); | 472 QuicStreamRequest request2(factory_.get()); |
| 458 EXPECT_EQ(OK, | 473 EXPECT_EQ(OK, request2.Request(host_port_pair_, privacy_mode_, |
| 459 request2.Request(host_port_pair_, privacy_mode_, | 474 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 460 /*cert_verify_flags=*/0, host_port_pair_.host(), | 475 callback_.callback())); |
| 461 "GET", net_log_, callback_.callback())); | |
| 462 stream = request2.ReleaseStream(); // Will reset stream 5. | 476 stream = request2.ReleaseStream(); // Will reset stream 5. |
| 463 stream.reset(); // Will reset stream 7. | 477 stream.reset(); // Will reset stream 7. |
| 464 | 478 |
| 465 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 479 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 466 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 480 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 467 } | 481 } |
| 468 | 482 |
| 469 TEST_P(QuicStreamFactoryTest, CreateZeroRtt) { | 483 TEST_P(QuicStreamFactoryTest, CreateZeroRtt) { |
| 470 Initialize(); | 484 Initialize(); |
| 471 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 485 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 472 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 486 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 473 | 487 |
| 474 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 488 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 475 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 489 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 476 socket_factory_.AddSocketDataProvider(&socket_data); | 490 socket_factory_.AddSocketDataProvider(&socket_data); |
| 477 | 491 |
| 478 crypto_client_stream_factory_.set_handshake_mode( | 492 crypto_client_stream_factory_.set_handshake_mode( |
| 479 MockCryptoClientStream::ZERO_RTT); | 493 MockCryptoClientStream::ZERO_RTT); |
| 480 host_resolver_.set_synchronous_mode(true); | 494 host_resolver_.set_synchronous_mode(true); |
| 481 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 495 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 482 "192.168.0.1", ""); | 496 "192.168.0.1", ""); |
| 483 | 497 |
| 484 QuicStreamRequest request(factory_.get()); | 498 QuicStreamRequest request(factory_.get()); |
| 485 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 499 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 486 /*cert_verify_flags=*/0, host_port_pair_.host(), | 500 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 487 "GET", net_log_, callback_.callback())); | 501 callback_.callback())); |
| 488 | 502 |
| 489 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 503 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 490 EXPECT_TRUE(stream.get()); | 504 EXPECT_TRUE(stream.get()); |
| 491 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 505 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 492 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 506 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 493 } | 507 } |
| 494 | 508 |
| 495 TEST_P(QuicStreamFactoryTest, CreateZeroRttPost) { | 509 TEST_P(QuicStreamFactoryTest, CreateZeroRttPost) { |
| 496 Initialize(); | 510 Initialize(); |
| 497 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 511 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 498 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 512 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 499 | 513 |
| 500 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 514 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 501 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 515 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 502 socket_factory_.AddSocketDataProvider(&socket_data); | 516 socket_factory_.AddSocketDataProvider(&socket_data); |
| 503 | 517 |
| 504 crypto_client_stream_factory_.set_handshake_mode( | 518 crypto_client_stream_factory_.set_handshake_mode( |
| 505 MockCryptoClientStream::ZERO_RTT); | 519 MockCryptoClientStream::ZERO_RTT); |
| 506 host_resolver_.set_synchronous_mode(true); | 520 host_resolver_.set_synchronous_mode(true); |
| 507 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 521 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 508 "192.168.0.1", ""); | 522 "192.168.0.1", ""); |
| 509 | 523 |
| 510 QuicStreamRequest request(factory_.get()); | 524 QuicStreamRequest request(factory_.get()); |
| 511 // Posts require handshake confirmation, so this will return asynchronously. | 525 // Posts require handshake confirmation, so this will return asynchronously. |
| 512 EXPECT_EQ(ERR_IO_PENDING, | 526 EXPECT_EQ(ERR_IO_PENDING, |
| 513 request.Request(host_port_pair_, privacy_mode_, | 527 request.Request(host_port_pair_, privacy_mode_, |
| 514 /*cert_verify_flags=*/0, host_port_pair_.host(), | 528 /*cert_verify_flags=*/0, url_, "POST", net_log_, |
| 515 "POST", net_log_, callback_.callback())); | 529 callback_.callback())); |
| 516 | 530 |
| 517 // Confirm the handshake and verify that the stream is created. | 531 // Confirm the handshake and verify that the stream is created. |
| 518 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( | 532 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( |
| 519 QuicSession::HANDSHAKE_CONFIRMED); | 533 QuicSession::HANDSHAKE_CONFIRMED); |
| 520 | 534 |
| 521 EXPECT_EQ(OK, callback_.WaitForResult()); | 535 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 522 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 536 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 523 EXPECT_TRUE(stream.get()); | 537 EXPECT_TRUE(stream.get()); |
| 524 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 538 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 525 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 539 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 526 } | 540 } |
| 527 | 541 |
| 528 TEST_P(QuicStreamFactoryTest, NoZeroRttForDifferentHost) { | 542 TEST_P(QuicStreamFactoryTest, NoZeroRttForDifferentHost) { |
| 529 Initialize(); | 543 Initialize(); |
| 530 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 544 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 531 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 545 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 532 | 546 |
| 533 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 547 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 534 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 548 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 535 socket_factory_.AddSocketDataProvider(&socket_data); | 549 socket_factory_.AddSocketDataProvider(&socket_data); |
| 536 | 550 |
| 537 crypto_client_stream_factory_.set_handshake_mode( | 551 crypto_client_stream_factory_.set_handshake_mode( |
| 538 MockCryptoClientStream::ZERO_RTT); | 552 MockCryptoClientStream::ZERO_RTT); |
| 539 host_resolver_.set_synchronous_mode(true); | 553 host_resolver_.set_synchronous_mode(true); |
| 540 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 554 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 541 "192.168.0.1", ""); | 555 "192.168.0.1", ""); |
| 542 | 556 |
| 543 QuicStreamRequest request(factory_.get()); | 557 QuicStreamRequest request(factory_.get()); |
| 544 int rv = | 558 int rv = request.Request(host_port_pair_, privacy_mode_, |
| 545 request.Request(host_port_pair_, privacy_mode_, /*cert_verify_flags=*/0, | 559 /*cert_verify_flags=*/0, url2_, "GET", net_log_, |
| 546 kServer2HostName, "GET", net_log_, callback_.callback()); | 560 callback_.callback()); |
| 547 // If server and origin have different hostnames, then handshake confirmation | 561 // If server and origin have different hostnames, then handshake confirmation |
| 548 // should be required, so Request will return asynchronously. | 562 // should be required, so Request will return asynchronously. |
| 549 EXPECT_EQ(ERR_IO_PENDING, rv); | 563 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 550 // Confirm handshake. | 564 // Confirm handshake. |
| 551 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( | 565 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( |
| 552 QuicSession::HANDSHAKE_CONFIRMED); | 566 QuicSession::HANDSHAKE_CONFIRMED); |
| 553 EXPECT_EQ(OK, callback_.WaitForResult()); | 567 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 554 | 568 |
| 555 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 569 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 556 EXPECT_TRUE(stream.get()); | 570 EXPECT_TRUE(stream.get()); |
| 557 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 571 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 558 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 572 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 559 } | 573 } |
| 560 | 574 |
| 561 TEST_P(QuicStreamFactoryTest, GoAway) { | 575 TEST_P(QuicStreamFactoryTest, GoAway) { |
| 562 Initialize(); | 576 Initialize(); |
| 563 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 577 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 564 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 578 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 565 | 579 |
| 566 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 580 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 567 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 581 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 568 socket_factory_.AddSocketDataProvider(&socket_data); | 582 socket_factory_.AddSocketDataProvider(&socket_data); |
| 569 | 583 |
| 570 QuicStreamRequest request(factory_.get()); | 584 QuicStreamRequest request(factory_.get()); |
| 571 EXPECT_EQ(ERR_IO_PENDING, | 585 EXPECT_EQ(ERR_IO_PENDING, |
| 572 request.Request(host_port_pair_, privacy_mode_, | 586 request.Request(host_port_pair_, privacy_mode_, |
| 573 /*cert_verify_flags=*/0, host_port_pair_.host(), | 587 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 574 "GET", net_log_, callback_.callback())); | 588 callback_.callback())); |
| 575 | 589 |
| 576 EXPECT_EQ(OK, callback_.WaitForResult()); | 590 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 577 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 591 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 578 EXPECT_TRUE(stream.get()); | 592 EXPECT_TRUE(stream.get()); |
| 579 | 593 |
| 580 QuicChromiumClientSession* session = | 594 QuicChromiumClientSession* session = |
| 581 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 595 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 582 | 596 |
| 583 session->OnGoAway(QuicGoAwayFrame()); | 597 session->OnGoAway(QuicGoAwayFrame()); |
| 584 | 598 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 599 socket_factory_.AddSocketDataProvider(&socket_data); | 613 socket_factory_.AddSocketDataProvider(&socket_data); |
| 600 | 614 |
| 601 HostPortPair server2(kServer2HostName, kDefaultServerPort); | 615 HostPortPair server2(kServer2HostName, kDefaultServerPort); |
| 602 host_resolver_.set_synchronous_mode(true); | 616 host_resolver_.set_synchronous_mode(true); |
| 603 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 617 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 604 "192.168.0.1", ""); | 618 "192.168.0.1", ""); |
| 605 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 619 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 606 | 620 |
| 607 QuicStreamRequest request(factory_.get()); | 621 QuicStreamRequest request(factory_.get()); |
| 608 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 622 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 609 /*cert_verify_flags=*/0, host_port_pair_.host(), | 623 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 610 "GET", net_log_, callback_.callback())); | 624 callback_.callback())); |
| 611 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 625 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 612 EXPECT_TRUE(stream.get()); | 626 EXPECT_TRUE(stream.get()); |
| 613 | 627 |
| 614 TestCompletionCallback callback; | 628 TestCompletionCallback callback; |
| 615 QuicStreamRequest request2(factory_.get()); | 629 QuicStreamRequest request2(factory_.get()); |
| 616 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 630 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 617 /*cert_verify_flags=*/0, server2.host(), "GET", | 631 /*cert_verify_flags=*/0, url2_, "GET", |
| 618 net_log_, callback.callback())); | 632 net_log_, callback.callback())); |
| 619 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 633 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 620 EXPECT_TRUE(stream2.get()); | 634 EXPECT_TRUE(stream2.get()); |
| 621 | 635 |
| 622 EXPECT_EQ( | 636 EXPECT_EQ( |
| 623 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_), | 637 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_), |
| 624 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); | 638 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); |
| 625 | 639 |
| 626 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 640 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 627 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 641 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 641 socket_factory_.AddSocketDataProvider(&socket_data2); | 655 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 642 | 656 |
| 643 HostPortPair server2(kServer2HostName, kDefaultServerPort); | 657 HostPortPair server2(kServer2HostName, kDefaultServerPort); |
| 644 host_resolver_.set_synchronous_mode(true); | 658 host_resolver_.set_synchronous_mode(true); |
| 645 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 659 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 646 "192.168.0.1", ""); | 660 "192.168.0.1", ""); |
| 647 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 661 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 648 | 662 |
| 649 QuicStreamRequest request(factory_.get()); | 663 QuicStreamRequest request(factory_.get()); |
| 650 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 664 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 651 /*cert_verify_flags=*/0, host_port_pair_.host(), | 665 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 652 "GET", net_log_, callback_.callback())); | 666 callback_.callback())); |
| 653 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 667 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 654 EXPECT_TRUE(stream.get()); | 668 EXPECT_TRUE(stream.get()); |
| 655 | 669 |
| 656 TestCompletionCallback callback; | 670 TestCompletionCallback callback; |
| 657 QuicStreamRequest request2(factory_.get()); | 671 QuicStreamRequest request2(factory_.get()); |
| 658 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 672 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 659 /*cert_verify_flags=*/0, server2.host(), "GET", | 673 /*cert_verify_flags=*/0, url2_, "GET", |
| 660 net_log_, callback.callback())); | 674 net_log_, callback.callback())); |
| 661 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 675 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 662 EXPECT_TRUE(stream2.get()); | 676 EXPECT_TRUE(stream2.get()); |
| 663 | 677 |
| 664 EXPECT_NE( | 678 EXPECT_NE( |
| 665 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_), | 679 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_), |
| 666 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); | 680 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); |
| 667 | 681 |
| 668 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 682 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 669 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 683 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 684 socket_factory_.AddSocketDataProvider(&socket_data2); | 698 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 685 | 699 |
| 686 HostPortPair server2(kServer2HostName, kDefaultServerPort); | 700 HostPortPair server2(kServer2HostName, kDefaultServerPort); |
| 687 host_resolver_.set_synchronous_mode(true); | 701 host_resolver_.set_synchronous_mode(true); |
| 688 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 702 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 689 "192.168.0.1", ""); | 703 "192.168.0.1", ""); |
| 690 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 704 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 691 | 705 |
| 692 QuicStreamRequest request(factory_.get()); | 706 QuicStreamRequest request(factory_.get()); |
| 693 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 707 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 694 /*cert_verify_flags=*/0, host_port_pair_.host(), | 708 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 695 "GET", net_log_, callback_.callback())); | 709 callback_.callback())); |
| 696 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 710 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 697 EXPECT_TRUE(stream.get()); | 711 EXPECT_TRUE(stream.get()); |
| 698 | 712 |
| 699 TestCompletionCallback callback; | 713 TestCompletionCallback callback; |
| 700 QuicStreamRequest request2(factory_.get()); | 714 QuicStreamRequest request2(factory_.get()); |
| 701 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 715 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 702 /*cert_verify_flags=*/0, server2.host(), "GET", | 716 /*cert_verify_flags=*/0, url2_, "GET", |
| 703 net_log_, callback.callback())); | 717 net_log_, callback.callback())); |
| 704 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 718 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 705 EXPECT_TRUE(stream2.get()); | 719 EXPECT_TRUE(stream2.get()); |
| 706 | 720 |
| 707 factory_->OnSessionGoingAway( | 721 factory_->OnSessionGoingAway( |
| 708 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_)); | 722 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_)); |
| 709 EXPECT_FALSE( | 723 EXPECT_FALSE( |
| 710 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 724 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 711 EXPECT_FALSE( | 725 EXPECT_FALSE( |
| 712 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server2)); | 726 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server2)); |
| 713 | 727 |
| 714 TestCompletionCallback callback3; | 728 TestCompletionCallback callback3; |
| 715 QuicStreamRequest request3(factory_.get()); | 729 QuicStreamRequest request3(factory_.get()); |
| 716 EXPECT_EQ(OK, request3.Request(server2, privacy_mode_, | 730 EXPECT_EQ(OK, request3.Request(server2, privacy_mode_, |
| 717 /*cert_verify_flags=*/0, server2.host(), "GET", | 731 /*cert_verify_flags=*/0, url2_, "GET", |
| 718 net_log_, callback3.callback())); | 732 net_log_, callback3.callback())); |
| 719 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 733 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
| 720 EXPECT_TRUE(stream3.get()); | 734 EXPECT_TRUE(stream3.get()); |
| 721 | 735 |
| 722 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server2)); | 736 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server2)); |
| 723 | 737 |
| 724 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 738 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 725 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 739 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 726 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 740 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 727 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 741 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 739 | 753 |
| 740 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 754 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 741 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 755 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 742 | 756 |
| 743 host_resolver_.set_synchronous_mode(true); | 757 host_resolver_.set_synchronous_mode(true); |
| 744 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 758 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 745 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 759 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 746 | 760 |
| 747 QuicStreamRequest request(factory_.get()); | 761 QuicStreamRequest request(factory_.get()); |
| 748 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, | 762 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 749 /*cert_verify_flags=*/0, server1.host(), "GET", | 763 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 750 net_log_, callback_.callback())); | 764 callback_.callback())); |
| 751 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 765 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 752 EXPECT_TRUE(stream.get()); | 766 EXPECT_TRUE(stream.get()); |
| 753 | 767 |
| 754 TestCompletionCallback callback; | 768 TestCompletionCallback callback; |
| 755 QuicStreamRequest request2(factory_.get()); | 769 QuicStreamRequest request2(factory_.get()); |
| 756 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 770 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 757 /*cert_verify_flags=*/0, server2.host(), "GET", | 771 /*cert_verify_flags=*/0, url2_, "GET", |
| 758 net_log_, callback_.callback())); | 772 net_log_, callback_.callback())); |
| 759 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 773 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 760 EXPECT_TRUE(stream2.get()); | 774 EXPECT_TRUE(stream2.get()); |
| 761 | 775 |
| 762 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), | 776 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), |
| 763 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); | 777 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); |
| 764 | 778 |
| 765 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 779 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 766 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 780 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 767 } | 781 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 782 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 796 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 783 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 797 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 784 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 798 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 785 | 799 |
| 786 host_resolver_.set_synchronous_mode(true); | 800 host_resolver_.set_synchronous_mode(true); |
| 787 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 801 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 788 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 802 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 789 | 803 |
| 790 QuicStreamRequest request(factory_.get()); | 804 QuicStreamRequest request(factory_.get()); |
| 791 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, | 805 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 792 /*cert_verify_flags=*/0, server1.host(), "GET", | 806 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 793 net_log_, callback_.callback())); | 807 callback_.callback())); |
| 794 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 808 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 795 EXPECT_TRUE(stream.get()); | 809 EXPECT_TRUE(stream.get()); |
| 796 | 810 |
| 797 TestCompletionCallback callback; | 811 TestCompletionCallback callback; |
| 798 QuicStreamRequest request2(factory_.get()); | 812 QuicStreamRequest request2(factory_.get()); |
| 799 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 813 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 800 /*cert_verify_flags=*/0, server2.host(), "GET", | 814 /*cert_verify_flags=*/0, url2_, "GET", |
| 801 net_log_, callback_.callback())); | 815 net_log_, callback_.callback())); |
| 802 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 816 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 803 EXPECT_TRUE(stream2.get()); | 817 EXPECT_TRUE(stream2.get()); |
| 804 | 818 |
| 805 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), | 819 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), |
| 806 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); | 820 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); |
| 807 | 821 |
| 808 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 822 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 809 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 823 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 810 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 824 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 811 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 825 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 812 } | 826 } |
| 813 | 827 |
| 814 class QuicAlternativeServiceCertificateValidationPooling | 828 class QuicAlternativeServiceCertificateValidationPooling |
| 815 : public QuicStreamFactoryTest { | 829 : public QuicStreamFactoryTest { |
| 816 public: | 830 public: |
| 817 void Run(bool valid) { | 831 void Run(bool valid) { |
| 818 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 832 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 819 SequencedSocketData socket_data1(reads, arraysize(reads), nullptr, 0); | 833 SequencedSocketData socket_data1(reads, arraysize(reads), nullptr, 0); |
| 820 socket_factory_.AddSocketDataProvider(&socket_data1); | 834 socket_factory_.AddSocketDataProvider(&socket_data1); |
| 821 | 835 |
| 822 HostPortPair server1(kDefaultServerHostName, 443); | 836 HostPortPair server1(kDefaultServerHostName, 443); |
| 823 HostPortPair server2(kServer2HostName, 443); | 837 HostPortPair server2(kServer2HostName, 443); |
| 824 | 838 |
| 825 std::string origin_host(valid ? kServer2HostName : "invalid.example.com"); | 839 GURL url(valid ? url2_ : GURL("http://invalid.example.com/")); |
| 826 HostPortPair alternative(kDefaultServerHostName, 443); | 840 HostPortPair alternative(kDefaultServerHostName, 443); |
| 827 | 841 |
| 828 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 842 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 829 bool common_name_fallback_used; | 843 bool common_name_fallback_used; |
| 830 EXPECT_EQ(valid, | 844 EXPECT_EQ(valid, |
| 831 verify_details.cert_verify_result.verified_cert->VerifyNameMatch( | 845 verify_details.cert_verify_result.verified_cert->VerifyNameMatch( |
| 832 origin_host, &common_name_fallback_used)); | 846 url.host(), &common_name_fallback_used)); |
| 833 EXPECT_TRUE( | 847 EXPECT_TRUE( |
| 834 verify_details.cert_verify_result.verified_cert->VerifyNameMatch( | 848 verify_details.cert_verify_result.verified_cert->VerifyNameMatch( |
| 835 alternative.host(), &common_name_fallback_used)); | 849 alternative.host(), &common_name_fallback_used)); |
| 836 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 850 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 837 | 851 |
| 838 host_resolver_.set_synchronous_mode(true); | 852 host_resolver_.set_synchronous_mode(true); |
| 839 host_resolver_.rules()->AddIPLiteralRule(alternative.host(), "192.168.0.1", | 853 host_resolver_.rules()->AddIPLiteralRule(alternative.host(), "192.168.0.1", |
| 840 ""); | 854 ""); |
| 841 | 855 |
| 842 // Open first stream to alternative. | 856 // Open first stream to alternative. |
| 843 QuicStreamRequest request1(factory_.get()); | 857 QuicStreamRequest request1(factory_.get()); |
| 844 EXPECT_EQ(OK, request1.Request(alternative, privacy_mode_, | 858 EXPECT_EQ(OK, request1.Request(alternative, privacy_mode_, |
| 845 /*cert_verify_flags=*/0, alternative.host(), | 859 /*cert_verify_flags=*/0, url_, "GET", |
| 846 "GET", net_log_, callback_.callback())); | 860 net_log_, callback_.callback())); |
| 847 scoped_ptr<QuicHttpStream> stream1 = request1.ReleaseStream(); | 861 scoped_ptr<QuicHttpStream> stream1 = request1.ReleaseStream(); |
| 848 EXPECT_TRUE(stream1.get()); | 862 EXPECT_TRUE(stream1.get()); |
| 849 | 863 |
| 850 QuicStreamRequest request2(factory_.get()); | 864 QuicStreamRequest request2(factory_.get()); |
| 851 int rv = request2.Request(alternative, privacy_mode_, | 865 int rv = request2.Request(alternative, privacy_mode_, |
| 852 /*cert_verify_flags=*/0, origin_host, "GET", | 866 /*cert_verify_flags=*/0, url, "GET", net_log_, |
| 853 net_log_, callback_.callback()); | 867 callback_.callback()); |
| 854 if (valid) { | 868 if (valid) { |
| 855 // Alternative service of origin to |alternative| should pool to session | 869 // Alternative service of origin to |alternative| should pool to session |
| 856 // of |stream1| even if origin is different. Since only one | 870 // of |stream1| even if origin is different. Since only one |
| 857 // SocketDataProvider is set up, the second request succeeding means that | 871 // SocketDataProvider is set up, the second request succeeding means that |
| 858 // it pooled to the session opened by the first one. | 872 // it pooled to the session opened by the first one. |
| 859 EXPECT_EQ(OK, rv); | 873 EXPECT_EQ(OK, rv); |
| 860 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 874 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 861 EXPECT_TRUE(stream2.get()); | 875 EXPECT_TRUE(stream2.get()); |
| 862 } else { | 876 } else { |
| 863 EXPECT_EQ(ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN, rv); | 877 EXPECT_EQ(ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN, rv); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 verify_details.cert_verify_result.public_key_hashes.push_back( | 913 verify_details.cert_verify_result.public_key_hashes.push_back( |
| 900 test::GetTestHashValue(primary_pin)); | 914 test::GetTestHashValue(primary_pin)); |
| 901 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 915 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 902 | 916 |
| 903 host_resolver_.set_synchronous_mode(true); | 917 host_resolver_.set_synchronous_mode(true); |
| 904 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 918 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 905 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 919 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 906 | 920 |
| 907 QuicStreamRequest request(factory_.get()); | 921 QuicStreamRequest request(factory_.get()); |
| 908 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, | 922 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 909 /*cert_verify_flags=*/0, server1.host(), "GET", | 923 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 910 net_log_, callback_.callback())); | 924 callback_.callback())); |
| 911 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 925 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 912 EXPECT_TRUE(stream.get()); | 926 EXPECT_TRUE(stream.get()); |
| 913 | 927 |
| 914 TestCompletionCallback callback; | 928 TestCompletionCallback callback; |
| 915 QuicStreamRequest request2(factory_.get()); | 929 QuicStreamRequest request2(factory_.get()); |
| 916 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 930 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 917 /*cert_verify_flags=*/0, server2.host(), "GET", | 931 /*cert_verify_flags=*/0, url2_, "GET", |
| 918 net_log_, callback_.callback())); | 932 net_log_, callback_.callback())); |
| 919 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 933 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 920 EXPECT_TRUE(stream2.get()); | 934 EXPECT_TRUE(stream2.get()); |
| 921 | 935 |
| 922 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), | 936 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), |
| 923 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); | 937 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); |
| 924 | 938 |
| 925 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 939 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 926 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 940 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 927 } | 941 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 948 test::GetTestHashValue(primary_pin)); | 962 test::GetTestHashValue(primary_pin)); |
| 949 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 963 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 950 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 964 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 951 | 965 |
| 952 host_resolver_.set_synchronous_mode(true); | 966 host_resolver_.set_synchronous_mode(true); |
| 953 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 967 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 954 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 968 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 955 | 969 |
| 956 QuicStreamRequest request(factory_.get()); | 970 QuicStreamRequest request(factory_.get()); |
| 957 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, | 971 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 958 /*cert_verify_flags=*/0, server1.host(), "GET", | 972 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 959 net_log_, callback_.callback())); | 973 callback_.callback())); |
| 960 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 974 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 961 EXPECT_TRUE(stream.get()); | 975 EXPECT_TRUE(stream.get()); |
| 962 | 976 |
| 963 TestCompletionCallback callback; | 977 TestCompletionCallback callback; |
| 964 QuicStreamRequest request2(factory_.get()); | 978 QuicStreamRequest request2(factory_.get()); |
| 965 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 979 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 966 /*cert_verify_flags=*/0, server2.host(), "GET", | 980 /*cert_verify_flags=*/0, url2_, "GET", |
| 967 net_log_, callback_.callback())); | 981 net_log_, callback_.callback())); |
| 968 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 982 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 969 EXPECT_TRUE(stream2.get()); | 983 EXPECT_TRUE(stream2.get()); |
| 970 | 984 |
| 971 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), | 985 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), |
| 972 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); | 986 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); |
| 973 | 987 |
| 974 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 988 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 975 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 989 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 976 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 990 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1002 verify_details2.cert_verify_result.public_key_hashes.push_back( | 1016 verify_details2.cert_verify_result.public_key_hashes.push_back( |
| 1003 test::GetTestHashValue(primary_pin)); | 1017 test::GetTestHashValue(primary_pin)); |
| 1004 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); | 1018 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); |
| 1005 | 1019 |
| 1006 host_resolver_.set_synchronous_mode(true); | 1020 host_resolver_.set_synchronous_mode(true); |
| 1007 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 1021 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 1008 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 1022 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1009 | 1023 |
| 1010 QuicStreamRequest request(factory_.get()); | 1024 QuicStreamRequest request(factory_.get()); |
| 1011 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, | 1025 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 1012 /*cert_verify_flags=*/0, server1.host(), "GET", | 1026 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1013 net_log_, callback_.callback())); | 1027 callback_.callback())); |
| 1014 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1028 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1015 EXPECT_TRUE(stream.get()); | 1029 EXPECT_TRUE(stream.get()); |
| 1016 | 1030 |
| 1017 TestCompletionCallback callback; | 1031 TestCompletionCallback callback; |
| 1018 QuicStreamRequest request2(factory_.get()); | 1032 QuicStreamRequest request2(factory_.get()); |
| 1019 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 1033 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 1020 /*cert_verify_flags=*/0, server2.host(), "GET", | 1034 /*cert_verify_flags=*/0, url2_, "GET", |
| 1021 net_log_, callback_.callback())); | 1035 net_log_, callback_.callback())); |
| 1022 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1036 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1023 EXPECT_TRUE(stream2.get()); | 1037 EXPECT_TRUE(stream2.get()); |
| 1024 | 1038 |
| 1025 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), | 1039 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server1), |
| 1026 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); | 1040 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2)); |
| 1027 | 1041 |
| 1028 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 1042 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 1029 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 1043 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 1030 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1044 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1031 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1045 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1032 } | 1046 } |
| 1033 | 1047 |
| 1034 TEST_P(QuicStreamFactoryTest, Goaway) { | 1048 TEST_P(QuicStreamFactoryTest, Goaway) { |
| 1035 Initialize(); | 1049 Initialize(); |
| 1036 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 1050 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 1037 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 1051 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1038 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 1052 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1039 | 1053 |
| 1040 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1054 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1041 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 1055 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 1042 socket_factory_.AddSocketDataProvider(&socket_data); | 1056 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1043 SequencedSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | 1057 SequencedSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 1044 socket_factory_.AddSocketDataProvider(&socket_data2); | 1058 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1045 | 1059 |
| 1046 QuicStreamRequest request(factory_.get()); | 1060 QuicStreamRequest request(factory_.get()); |
| 1047 EXPECT_EQ(ERR_IO_PENDING, | 1061 EXPECT_EQ(ERR_IO_PENDING, |
| 1048 request.Request(host_port_pair_, privacy_mode_, | 1062 request.Request(host_port_pair_, privacy_mode_, |
| 1049 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1063 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1050 "GET", net_log_, callback_.callback())); | 1064 callback_.callback())); |
| 1051 | 1065 |
| 1052 EXPECT_EQ(OK, callback_.WaitForResult()); | 1066 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1053 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1067 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1054 EXPECT_TRUE(stream.get()); | 1068 EXPECT_TRUE(stream.get()); |
| 1055 | 1069 |
| 1056 // Mark the session as going away. Ensure that while it is still alive | 1070 // Mark the session as going away. Ensure that while it is still alive |
| 1057 // that it is no longer active. | 1071 // that it is no longer active. |
| 1058 QuicChromiumClientSession* session = | 1072 QuicChromiumClientSession* session = |
| 1059 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 1073 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 1060 factory_->OnSessionGoingAway(session); | 1074 factory_->OnSessionGoingAway(session); |
| 1061 EXPECT_EQ(true, | 1075 EXPECT_EQ(true, |
| 1062 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); | 1076 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1063 EXPECT_FALSE( | 1077 EXPECT_FALSE( |
| 1064 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 1078 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 1065 EXPECT_FALSE(HasActiveSession(host_port_pair_)); | 1079 EXPECT_FALSE(HasActiveSession(host_port_pair_)); |
| 1066 | 1080 |
| 1067 // Create a new request for the same destination and verify that a | 1081 // Create a new request for the same destination and verify that a |
| 1068 // new session is created. | 1082 // new session is created. |
| 1069 QuicStreamRequest request2(factory_.get()); | 1083 QuicStreamRequest request2(factory_.get()); |
| 1070 EXPECT_EQ(ERR_IO_PENDING, | 1084 EXPECT_EQ(ERR_IO_PENDING, |
| 1071 request2.Request(host_port_pair_, privacy_mode_, | 1085 request2.Request(host_port_pair_, privacy_mode_, |
| 1072 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1086 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1073 "GET", net_log_, callback_.callback())); | 1087 callback_.callback())); |
| 1074 EXPECT_EQ(OK, callback_.WaitForResult()); | 1088 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1075 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1089 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1076 EXPECT_TRUE(stream2.get()); | 1090 EXPECT_TRUE(stream2.get()); |
| 1077 | 1091 |
| 1078 EXPECT_TRUE( | 1092 EXPECT_TRUE( |
| 1079 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 1093 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 1080 EXPECT_NE(session, QuicStreamFactoryPeer::GetActiveSession(factory_.get(), | 1094 EXPECT_NE(session, QuicStreamFactoryPeer::GetActiveSession(factory_.get(), |
| 1081 host_port_pair_)); | 1095 host_port_pair_)); |
| 1082 EXPECT_EQ(true, | 1096 EXPECT_EQ(true, |
| 1083 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); | 1097 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1111 arraysize(writes)); | 1125 arraysize(writes)); |
| 1112 socket_factory_.AddSocketDataProvider(&socket_data); | 1126 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1113 | 1127 |
| 1114 HttpRequestInfo request_info; | 1128 HttpRequestInfo request_info; |
| 1115 std::vector<QuicHttpStream*> streams; | 1129 std::vector<QuicHttpStream*> streams; |
| 1116 // The MockCryptoClientStream sets max_open_streams to be | 1130 // The MockCryptoClientStream sets max_open_streams to be |
| 1117 // kDefaultMaxStreamsPerConnection / 2. | 1131 // kDefaultMaxStreamsPerConnection / 2. |
| 1118 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection / 2; i++) { | 1132 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection / 2; i++) { |
| 1119 QuicStreamRequest request(factory_.get()); | 1133 QuicStreamRequest request(factory_.get()); |
| 1120 int rv = request.Request(host_port_pair_, privacy_mode_, | 1134 int rv = request.Request(host_port_pair_, privacy_mode_, |
| 1121 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1135 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1122 "GET", net_log_, callback_.callback()); | 1136 callback_.callback()); |
| 1123 if (i == 0) { | 1137 if (i == 0) { |
| 1124 EXPECT_EQ(ERR_IO_PENDING, rv); | 1138 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1125 EXPECT_EQ(OK, callback_.WaitForResult()); | 1139 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1126 } else { | 1140 } else { |
| 1127 EXPECT_EQ(OK, rv); | 1141 EXPECT_EQ(OK, rv); |
| 1128 } | 1142 } |
| 1129 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1143 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1130 EXPECT_TRUE(stream); | 1144 EXPECT_TRUE(stream); |
| 1131 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1145 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1132 net_log_, CompletionCallback())); | 1146 net_log_, CompletionCallback())); |
| 1133 streams.push_back(stream.release()); | 1147 streams.push_back(stream.release()); |
| 1134 } | 1148 } |
| 1135 | 1149 |
| 1136 QuicStreamRequest request(factory_.get()); | 1150 QuicStreamRequest request(factory_.get()); |
| 1137 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 1151 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 1138 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1152 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1139 "GET", net_log_, CompletionCallback())); | 1153 CompletionCallback())); |
| 1140 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1154 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1141 EXPECT_TRUE(stream); | 1155 EXPECT_TRUE(stream); |
| 1142 EXPECT_EQ(ERR_IO_PENDING, | 1156 EXPECT_EQ(ERR_IO_PENDING, |
| 1143 stream->InitializeStream(&request_info, DEFAULT_PRIORITY, net_log_, | 1157 stream->InitializeStream(&request_info, DEFAULT_PRIORITY, net_log_, |
| 1144 callback_.callback())); | 1158 callback_.callback())); |
| 1145 | 1159 |
| 1146 // Close the first stream. | 1160 // Close the first stream. |
| 1147 streams.front()->Close(false); | 1161 streams.front()->Close(false); |
| 1148 // Trigger exchange of RSTs that in turn allow progress for the last | 1162 // Trigger exchange of RSTs that in turn allow progress for the last |
| 1149 // stream. | 1163 // stream. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1166 TEST_P(QuicStreamFactoryTest, ResolutionErrorInCreate) { | 1180 TEST_P(QuicStreamFactoryTest, ResolutionErrorInCreate) { |
| 1167 Initialize(); | 1181 Initialize(); |
| 1168 SequencedSocketData socket_data(nullptr, 0, nullptr, 0); | 1182 SequencedSocketData socket_data(nullptr, 0, nullptr, 0); |
| 1169 socket_factory_.AddSocketDataProvider(&socket_data); | 1183 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1170 | 1184 |
| 1171 host_resolver_.rules()->AddSimulatedFailure(kDefaultServerHostName); | 1185 host_resolver_.rules()->AddSimulatedFailure(kDefaultServerHostName); |
| 1172 | 1186 |
| 1173 QuicStreamRequest request(factory_.get()); | 1187 QuicStreamRequest request(factory_.get()); |
| 1174 EXPECT_EQ(ERR_IO_PENDING, | 1188 EXPECT_EQ(ERR_IO_PENDING, |
| 1175 request.Request(host_port_pair_, privacy_mode_, | 1189 request.Request(host_port_pair_, privacy_mode_, |
| 1176 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1190 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1177 "GET", net_log_, callback_.callback())); | 1191 callback_.callback())); |
| 1178 | 1192 |
| 1179 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); | 1193 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); |
| 1180 | 1194 |
| 1181 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1195 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1182 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1196 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1183 } | 1197 } |
| 1184 | 1198 |
| 1185 TEST_P(QuicStreamFactoryTest, ConnectErrorInCreate) { | 1199 TEST_P(QuicStreamFactoryTest, ConnectErrorInCreate) { |
| 1186 Initialize(); | 1200 Initialize(); |
| 1187 MockConnect connect(SYNCHRONOUS, ERR_ADDRESS_IN_USE); | 1201 MockConnect connect(SYNCHRONOUS, ERR_ADDRESS_IN_USE); |
| 1188 SequencedSocketData socket_data(nullptr, 0, nullptr, 0); | 1202 SequencedSocketData socket_data(nullptr, 0, nullptr, 0); |
| 1189 socket_data.set_connect_data(connect); | 1203 socket_data.set_connect_data(connect); |
| 1190 socket_factory_.AddSocketDataProvider(&socket_data); | 1204 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1191 | 1205 |
| 1192 QuicStreamRequest request(factory_.get()); | 1206 QuicStreamRequest request(factory_.get()); |
| 1193 EXPECT_EQ(ERR_IO_PENDING, | 1207 EXPECT_EQ(ERR_IO_PENDING, |
| 1194 request.Request(host_port_pair_, privacy_mode_, | 1208 request.Request(host_port_pair_, privacy_mode_, |
| 1195 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1209 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1196 "GET", net_log_, callback_.callback())); | 1210 callback_.callback())); |
| 1197 | 1211 |
| 1198 EXPECT_EQ(ERR_ADDRESS_IN_USE, callback_.WaitForResult()); | 1212 EXPECT_EQ(ERR_ADDRESS_IN_USE, callback_.WaitForResult()); |
| 1199 | 1213 |
| 1200 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1214 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1201 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1215 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1202 } | 1216 } |
| 1203 | 1217 |
| 1204 TEST_P(QuicStreamFactoryTest, CancelCreate) { | 1218 TEST_P(QuicStreamFactoryTest, CancelCreate) { |
| 1205 Initialize(); | 1219 Initialize(); |
| 1206 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1220 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1207 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 1221 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 1208 socket_factory_.AddSocketDataProvider(&socket_data); | 1222 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1209 { | 1223 { |
| 1210 QuicStreamRequest request(factory_.get()); | 1224 QuicStreamRequest request(factory_.get()); |
| 1211 EXPECT_EQ(ERR_IO_PENDING, | 1225 EXPECT_EQ(ERR_IO_PENDING, |
| 1212 request.Request(host_port_pair_, privacy_mode_, | 1226 request.Request(host_port_pair_, privacy_mode_, |
| 1213 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1227 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1214 "GET", net_log_, callback_.callback())); | 1228 callback_.callback())); |
| 1215 } | 1229 } |
| 1216 | 1230 |
| 1217 base::RunLoop().RunUntilIdle(); | 1231 base::RunLoop().RunUntilIdle(); |
| 1218 | 1232 |
| 1219 scoped_ptr<QuicHttpStream> stream(CreateFromSession(host_port_pair_)); | 1233 scoped_ptr<QuicHttpStream> stream(CreateFromSession(host_port_pair_)); |
| 1220 EXPECT_TRUE(stream.get()); | 1234 EXPECT_TRUE(stream.get()); |
| 1221 stream.reset(); | 1235 stream.reset(); |
| 1222 | 1236 |
| 1223 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1237 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1224 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1238 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 writes.size()); | 1288 writes.size()); |
| 1275 socket_factory_.AddSocketDataProvider(&socket_data); | 1289 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1276 | 1290 |
| 1277 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1291 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1278 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1292 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1279 socket_factory_.AddSocketDataProvider(&socket_data2); | 1293 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1280 | 1294 |
| 1281 QuicStreamRequest request(factory_.get()); | 1295 QuicStreamRequest request(factory_.get()); |
| 1282 EXPECT_EQ(ERR_IO_PENDING, | 1296 EXPECT_EQ(ERR_IO_PENDING, |
| 1283 request.Request(host_port_pair_, privacy_mode_, | 1297 request.Request(host_port_pair_, privacy_mode_, |
| 1284 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1298 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1285 "GET", net_log_, callback_.callback())); | 1299 callback_.callback())); |
| 1286 | 1300 |
| 1287 EXPECT_EQ(OK, callback_.WaitForResult()); | 1301 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1288 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1302 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1289 HttpRequestInfo request_info; | 1303 HttpRequestInfo request_info; |
| 1290 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1304 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1291 net_log_, CompletionCallback())); | 1305 net_log_, CompletionCallback())); |
| 1292 | 1306 |
| 1293 // Close the session and verify that stream saw the error. | 1307 // Close the session and verify that stream saw the error. |
| 1294 factory_->CloseAllSessions(ERR_INTERNET_DISCONNECTED, QUIC_INTERNAL_ERROR); | 1308 factory_->CloseAllSessions(ERR_INTERNET_DISCONNECTED, QUIC_INTERNAL_ERROR); |
| 1295 EXPECT_EQ(ERR_INTERNET_DISCONNECTED, | 1309 EXPECT_EQ(ERR_INTERNET_DISCONNECTED, |
| 1296 stream->ReadResponseHeaders(callback_.callback())); | 1310 stream->ReadResponseHeaders(callback_.callback())); |
| 1297 | 1311 |
| 1298 // Now attempting to request a stream to the same origin should create | 1312 // Now attempting to request a stream to the same origin should create |
| 1299 // a new session. | 1313 // a new session. |
| 1300 | 1314 |
| 1301 QuicStreamRequest request2(factory_.get()); | 1315 QuicStreamRequest request2(factory_.get()); |
| 1302 EXPECT_EQ(ERR_IO_PENDING, | 1316 EXPECT_EQ(ERR_IO_PENDING, |
| 1303 request2.Request(host_port_pair_, privacy_mode_, | 1317 request2.Request(host_port_pair_, privacy_mode_, |
| 1304 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1318 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1305 "GET", net_log_, callback_.callback())); | 1319 callback_.callback())); |
| 1306 | 1320 |
| 1307 EXPECT_EQ(OK, callback_.WaitForResult()); | 1321 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1308 stream = request2.ReleaseStream(); | 1322 stream = request2.ReleaseStream(); |
| 1309 stream.reset(); // Will reset stream 3. | 1323 stream.reset(); // Will reset stream 3. |
| 1310 | 1324 |
| 1311 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1325 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1312 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1326 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1313 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1327 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1314 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1328 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1315 } | 1329 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1330 writes.size()); | 1344 writes.size()); |
| 1331 socket_factory_.AddSocketDataProvider(&socket_data); | 1345 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1332 | 1346 |
| 1333 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1347 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1334 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1348 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1335 socket_factory_.AddSocketDataProvider(&socket_data2); | 1349 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1336 | 1350 |
| 1337 QuicStreamRequest request(factory_.get()); | 1351 QuicStreamRequest request(factory_.get()); |
| 1338 EXPECT_EQ(ERR_IO_PENDING, | 1352 EXPECT_EQ(ERR_IO_PENDING, |
| 1339 request.Request(host_port_pair_, privacy_mode_, | 1353 request.Request(host_port_pair_, privacy_mode_, |
| 1340 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1354 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1341 "GET", net_log_, callback_.callback())); | 1355 callback_.callback())); |
| 1342 | 1356 |
| 1343 EXPECT_EQ(OK, callback_.WaitForResult()); | 1357 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1344 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1358 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1345 HttpRequestInfo request_info; | 1359 HttpRequestInfo request_info; |
| 1346 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1360 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1347 net_log_, CompletionCallback())); | 1361 net_log_, CompletionCallback())); |
| 1348 | 1362 |
| 1349 // Change the IP address and verify that stream saw the error. | 1363 // Change the IP address and verify that stream saw the error. |
| 1350 NotifyIPAddressChanged(); | 1364 NotifyIPAddressChanged(); |
| 1351 EXPECT_EQ(ERR_NETWORK_CHANGED, | 1365 EXPECT_EQ(ERR_NETWORK_CHANGED, |
| 1352 stream->ReadResponseHeaders(callback_.callback())); | 1366 stream->ReadResponseHeaders(callback_.callback())); |
| 1353 EXPECT_TRUE(factory_->require_confirmation()); | 1367 EXPECT_TRUE(factory_->require_confirmation()); |
| 1354 | 1368 |
| 1355 // Now attempting to request a stream to the same origin should create | 1369 // Now attempting to request a stream to the same origin should create |
| 1356 // a new session. | 1370 // a new session. |
| 1357 | 1371 |
| 1358 QuicStreamRequest request2(factory_.get()); | 1372 QuicStreamRequest request2(factory_.get()); |
| 1359 EXPECT_EQ(ERR_IO_PENDING, | 1373 EXPECT_EQ(ERR_IO_PENDING, |
| 1360 request2.Request(host_port_pair_, privacy_mode_, | 1374 request2.Request(host_port_pair_, privacy_mode_, |
| 1361 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1375 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1362 "GET", net_log_, callback_.callback())); | 1376 callback_.callback())); |
| 1363 | 1377 |
| 1364 EXPECT_EQ(OK, callback_.WaitForResult()); | 1378 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1365 stream = request2.ReleaseStream(); | 1379 stream = request2.ReleaseStream(); |
| 1366 stream.reset(); // Will reset stream 3. | 1380 stream.reset(); // Will reset stream 3. |
| 1367 | 1381 |
| 1368 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1382 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1369 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1383 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1370 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1384 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1371 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1385 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1372 } | 1386 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1384 MockWrite writes[] = {MockWrite(SYNCHRONOUS, request_packet->data(), | 1398 MockWrite writes[] = {MockWrite(SYNCHRONOUS, request_packet->data(), |
| 1385 request_packet->length(), 1)}; | 1399 request_packet->length(), 1)}; |
| 1386 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 1400 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 1387 arraysize(writes)); | 1401 arraysize(writes)); |
| 1388 socket_factory_.AddSocketDataProvider(&socket_data); | 1402 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1389 | 1403 |
| 1390 // Create request and QuicHttpStream. | 1404 // Create request and QuicHttpStream. |
| 1391 QuicStreamRequest request(factory_.get()); | 1405 QuicStreamRequest request(factory_.get()); |
| 1392 EXPECT_EQ(ERR_IO_PENDING, | 1406 EXPECT_EQ(ERR_IO_PENDING, |
| 1393 request.Request(host_port_pair_, privacy_mode_, | 1407 request.Request(host_port_pair_, privacy_mode_, |
| 1394 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1408 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1395 "GET", net_log_, callback_.callback())); | 1409 callback_.callback())); |
| 1396 EXPECT_EQ(OK, callback_.WaitForResult()); | 1410 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1397 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1411 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1398 EXPECT_TRUE(stream.get()); | 1412 EXPECT_TRUE(stream.get()); |
| 1399 | 1413 |
| 1400 // Cause QUIC stream to be created. | 1414 // Cause QUIC stream to be created. |
| 1401 HttpRequestInfo request_info; | 1415 HttpRequestInfo request_info; |
| 1402 request_info.method = "GET"; | 1416 request_info.method = "GET"; |
| 1403 request_info.url = GURL("https://www.example.org/"); | 1417 request_info.url = GURL("https://www.example.org/"); |
| 1404 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1418 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1405 net_log_, CompletionCallback())); | 1419 net_log_, CompletionCallback())); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 | 1463 |
| 1450 // Create a new request for the same destination and verify that a | 1464 // Create a new request for the same destination and verify that a |
| 1451 // new session is created. | 1465 // new session is created. |
| 1452 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1466 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1453 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1467 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1454 socket_factory_.AddSocketDataProvider(&socket_data2); | 1468 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1455 | 1469 |
| 1456 QuicStreamRequest request2(factory_.get()); | 1470 QuicStreamRequest request2(factory_.get()); |
| 1457 EXPECT_EQ(ERR_IO_PENDING, | 1471 EXPECT_EQ(ERR_IO_PENDING, |
| 1458 request2.Request(host_port_pair_, privacy_mode_, | 1472 request2.Request(host_port_pair_, privacy_mode_, |
| 1459 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1473 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1460 "GET", net_log_, callback_.callback())); | 1474 callback_.callback())); |
| 1461 EXPECT_EQ(OK, callback_.WaitForResult()); | 1475 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1462 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1476 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1463 EXPECT_TRUE(stream2.get()); | 1477 EXPECT_TRUE(stream2.get()); |
| 1464 | 1478 |
| 1465 EXPECT_TRUE( | 1479 EXPECT_TRUE( |
| 1466 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 1480 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 1467 QuicChromiumClientSession* new_session = | 1481 QuicChromiumClientSession* new_session = |
| 1468 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 1482 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 1469 EXPECT_NE(session, new_session); | 1483 EXPECT_NE(session, new_session); |
| 1470 | 1484 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1499 MockWrite writes[] = {MockWrite(SYNCHRONOUS, request_packet->data(), | 1513 MockWrite writes[] = {MockWrite(SYNCHRONOUS, request_packet->data(), |
| 1500 request_packet->length(), 1)}; | 1514 request_packet->length(), 1)}; |
| 1501 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 1515 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 1502 arraysize(writes)); | 1516 arraysize(writes)); |
| 1503 socket_factory_.AddSocketDataProvider(&socket_data); | 1517 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1504 | 1518 |
| 1505 // Create request and QuicHttpStream. | 1519 // Create request and QuicHttpStream. |
| 1506 QuicStreamRequest request(factory_.get()); | 1520 QuicStreamRequest request(factory_.get()); |
| 1507 EXPECT_EQ(ERR_IO_PENDING, | 1521 EXPECT_EQ(ERR_IO_PENDING, |
| 1508 request.Request(host_port_pair_, privacy_mode_, | 1522 request.Request(host_port_pair_, privacy_mode_, |
| 1509 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1523 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1510 "GET", net_log_, callback_.callback())); | 1524 callback_.callback())); |
| 1511 EXPECT_EQ(OK, callback_.WaitForResult()); | 1525 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1512 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1526 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1513 EXPECT_TRUE(stream.get()); | 1527 EXPECT_TRUE(stream.get()); |
| 1514 | 1528 |
| 1515 // Cause QUIC stream to be created. | 1529 // Cause QUIC stream to be created. |
| 1516 HttpRequestInfo request_info; | 1530 HttpRequestInfo request_info; |
| 1517 request_info.method = "GET"; | 1531 request_info.method = "GET"; |
| 1518 request_info.url = GURL("https://www.example.org/"); | 1532 request_info.url = GURL("https://www.example.org/"); |
| 1519 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1533 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1520 net_log_, CompletionCallback())); | 1534 net_log_, CompletionCallback())); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 | 1574 |
| 1561 // Create a new request for the same destination and verify that a | 1575 // Create a new request for the same destination and verify that a |
| 1562 // new session is created. | 1576 // new session is created. |
| 1563 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1577 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1564 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1578 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1565 socket_factory_.AddSocketDataProvider(&socket_data2); | 1579 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1566 | 1580 |
| 1567 QuicStreamRequest request2(factory_.get()); | 1581 QuicStreamRequest request2(factory_.get()); |
| 1568 EXPECT_EQ(ERR_IO_PENDING, | 1582 EXPECT_EQ(ERR_IO_PENDING, |
| 1569 request2.Request(host_port_pair_, privacy_mode_, | 1583 request2.Request(host_port_pair_, privacy_mode_, |
| 1570 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1584 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1571 "GET", net_log_, callback_.callback())); | 1585 callback_.callback())); |
| 1572 EXPECT_EQ(OK, callback_.WaitForResult()); | 1586 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1573 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1587 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1574 EXPECT_TRUE(stream2.get()); | 1588 EXPECT_TRUE(stream2.get()); |
| 1575 | 1589 |
| 1576 EXPECT_TRUE( | 1590 EXPECT_TRUE( |
| 1577 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 1591 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 1578 EXPECT_NE(session, QuicStreamFactoryPeer::GetActiveSession(factory_.get(), | 1592 EXPECT_NE(session, QuicStreamFactoryPeer::GetActiveSession(factory_.get(), |
| 1579 host_port_pair_)); | 1593 host_port_pair_)); |
| 1580 EXPECT_EQ(true, | 1594 EXPECT_EQ(true, |
| 1581 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); | 1595 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1601 MockWrite(SYNCHRONOUS, client_rst->data(), client_rst->length(), 1), | 1615 MockWrite(SYNCHRONOUS, client_rst->data(), client_rst->length(), 1), |
| 1602 }; | 1616 }; |
| 1603 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 1617 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 1604 arraysize(writes)); | 1618 arraysize(writes)); |
| 1605 socket_factory_.AddSocketDataProvider(&socket_data); | 1619 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1606 | 1620 |
| 1607 // Create request and QuicHttpStream. | 1621 // Create request and QuicHttpStream. |
| 1608 QuicStreamRequest request(factory_.get()); | 1622 QuicStreamRequest request(factory_.get()); |
| 1609 EXPECT_EQ(ERR_IO_PENDING, | 1623 EXPECT_EQ(ERR_IO_PENDING, |
| 1610 request.Request(host_port_pair_, privacy_mode_, | 1624 request.Request(host_port_pair_, privacy_mode_, |
| 1611 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1625 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1612 "GET", net_log_, callback_.callback())); | 1626 callback_.callback())); |
| 1613 EXPECT_EQ(OK, callback_.WaitForResult()); | 1627 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1614 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1628 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1615 EXPECT_TRUE(stream.get()); | 1629 EXPECT_TRUE(stream.get()); |
| 1616 | 1630 |
| 1617 // Cause QUIC stream to be created. | 1631 // Cause QUIC stream to be created. |
| 1618 HttpRequestInfo request_info; | 1632 HttpRequestInfo request_info; |
| 1619 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1633 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1620 net_log_, CompletionCallback())); | 1634 net_log_, CompletionCallback())); |
| 1621 | 1635 |
| 1622 // Ensure that session is alive and active. | 1636 // Ensure that session is alive and active. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 MockWrite(ASYNC, client_rst->data(), client_rst->length(), 1), | 1669 MockWrite(ASYNC, client_rst->data(), client_rst->length(), 1), |
| 1656 }; | 1670 }; |
| 1657 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 1671 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 1658 arraysize(writes)); | 1672 arraysize(writes)); |
| 1659 socket_factory_.AddSocketDataProvider(&socket_data); | 1673 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1660 | 1674 |
| 1661 // Create request and QuicHttpStream. | 1675 // Create request and QuicHttpStream. |
| 1662 QuicStreamRequest request(factory_.get()); | 1676 QuicStreamRequest request(factory_.get()); |
| 1663 EXPECT_EQ(ERR_IO_PENDING, | 1677 EXPECT_EQ(ERR_IO_PENDING, |
| 1664 request.Request(host_port_pair_, privacy_mode_, | 1678 request.Request(host_port_pair_, privacy_mode_, |
| 1665 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1679 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1666 "GET", net_log_, callback_.callback())); | 1680 callback_.callback())); |
| 1667 EXPECT_EQ(OK, callback_.WaitForResult()); | 1681 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1668 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1682 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1669 EXPECT_TRUE(stream.get()); | 1683 EXPECT_TRUE(stream.get()); |
| 1670 | 1684 |
| 1671 // Cause QUIC stream to be created. | 1685 // Cause QUIC stream to be created. |
| 1672 HttpRequestInfo request_info; | 1686 HttpRequestInfo request_info; |
| 1673 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1687 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1674 net_log_, CompletionCallback())); | 1688 net_log_, CompletionCallback())); |
| 1675 | 1689 |
| 1676 // Ensure that session is alive and active. | 1690 // Ensure that session is alive and active. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1704 MockWrite(SYNCHRONOUS, client_rst->data(), client_rst->length(), 1), | 1718 MockWrite(SYNCHRONOUS, client_rst->data(), client_rst->length(), 1), |
| 1705 }; | 1719 }; |
| 1706 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 1720 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 1707 arraysize(writes)); | 1721 arraysize(writes)); |
| 1708 socket_factory_.AddSocketDataProvider(&socket_data); | 1722 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1709 | 1723 |
| 1710 // Create request and QuicHttpStream. | 1724 // Create request and QuicHttpStream. |
| 1711 QuicStreamRequest request(factory_.get()); | 1725 QuicStreamRequest request(factory_.get()); |
| 1712 EXPECT_EQ(ERR_IO_PENDING, | 1726 EXPECT_EQ(ERR_IO_PENDING, |
| 1713 request.Request(host_port_pair_, privacy_mode_, | 1727 request.Request(host_port_pair_, privacy_mode_, |
| 1714 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1728 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1715 "GET", net_log_, callback_.callback())); | 1729 callback_.callback())); |
| 1716 EXPECT_EQ(OK, callback_.WaitForResult()); | 1730 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1717 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1731 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1718 EXPECT_TRUE(stream.get()); | 1732 EXPECT_TRUE(stream.get()); |
| 1719 | 1733 |
| 1720 // Cause QUIC stream to be created. | 1734 // Cause QUIC stream to be created. |
| 1721 HttpRequestInfo request_info; | 1735 HttpRequestInfo request_info; |
| 1722 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1736 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1723 net_log_, CompletionCallback())); | 1737 net_log_, CompletionCallback())); |
| 1724 | 1738 |
| 1725 // Ensure that session is alive and active. | 1739 // Ensure that session is alive and active. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1756 MockWrite(ASYNC, client_rst->data(), client_rst->length(), 1), | 1770 MockWrite(ASYNC, client_rst->data(), client_rst->length(), 1), |
| 1757 }; | 1771 }; |
| 1758 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 1772 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 1759 arraysize(writes)); | 1773 arraysize(writes)); |
| 1760 socket_factory_.AddSocketDataProvider(&socket_data); | 1774 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1761 | 1775 |
| 1762 // Create request and QuicHttpStream. | 1776 // Create request and QuicHttpStream. |
| 1763 QuicStreamRequest request(factory_.get()); | 1777 QuicStreamRequest request(factory_.get()); |
| 1764 EXPECT_EQ(ERR_IO_PENDING, | 1778 EXPECT_EQ(ERR_IO_PENDING, |
| 1765 request.Request(host_port_pair_, privacy_mode_, | 1779 request.Request(host_port_pair_, privacy_mode_, |
| 1766 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1780 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1767 "GET", net_log_, callback_.callback())); | 1781 callback_.callback())); |
| 1768 EXPECT_EQ(OK, callback_.WaitForResult()); | 1782 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1769 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1783 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1770 EXPECT_TRUE(stream.get()); | 1784 EXPECT_TRUE(stream.get()); |
| 1771 | 1785 |
| 1772 // Cause QUIC stream to be created. | 1786 // Cause QUIC stream to be created. |
| 1773 HttpRequestInfo request_info; | 1787 HttpRequestInfo request_info; |
| 1774 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1788 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1775 net_log_, CompletionCallback())); | 1789 net_log_, CompletionCallback())); |
| 1776 | 1790 |
| 1777 // Ensure that session is alive and active. | 1791 // Ensure that session is alive and active. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1800 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 1814 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1801 | 1815 |
| 1802 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1816 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1803 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0u); | 1817 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0u); |
| 1804 socket_factory_.AddSocketDataProvider(&socket_data); | 1818 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1805 | 1819 |
| 1806 // Create request and QuicHttpStream. | 1820 // Create request and QuicHttpStream. |
| 1807 QuicStreamRequest request(factory_.get()); | 1821 QuicStreamRequest request(factory_.get()); |
| 1808 EXPECT_EQ(ERR_IO_PENDING, | 1822 EXPECT_EQ(ERR_IO_PENDING, |
| 1809 request.Request(host_port_pair_, privacy_mode_, | 1823 request.Request(host_port_pair_, privacy_mode_, |
| 1810 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1824 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1811 "GET", net_log_, callback_.callback())); | 1825 callback_.callback())); |
| 1812 EXPECT_EQ(OK, callback_.WaitForResult()); | 1826 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1813 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1827 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1814 EXPECT_TRUE(stream.get()); | 1828 EXPECT_TRUE(stream.get()); |
| 1815 | 1829 |
| 1816 // Ensure that session is alive and active. | 1830 // Ensure that session is alive and active. |
| 1817 QuicChromiumClientSession* session = | 1831 QuicChromiumClientSession* session = |
| 1818 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 1832 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 1819 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); | 1833 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1820 EXPECT_TRUE(HasActiveSession(host_port_pair_)); | 1834 EXPECT_TRUE(HasActiveSession(host_port_pair_)); |
| 1821 | 1835 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1838 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 1852 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1839 | 1853 |
| 1840 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1854 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1841 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0u); | 1855 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0u); |
| 1842 socket_factory_.AddSocketDataProvider(&socket_data); | 1856 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1843 | 1857 |
| 1844 // Create request and QuicHttpStream. | 1858 // Create request and QuicHttpStream. |
| 1845 QuicStreamRequest request(factory_.get()); | 1859 QuicStreamRequest request(factory_.get()); |
| 1846 EXPECT_EQ(ERR_IO_PENDING, | 1860 EXPECT_EQ(ERR_IO_PENDING, |
| 1847 request.Request(host_port_pair_, privacy_mode_, | 1861 request.Request(host_port_pair_, privacy_mode_, |
| 1848 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1862 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1849 "GET", net_log_, callback_.callback())); | 1863 callback_.callback())); |
| 1850 EXPECT_EQ(OK, callback_.WaitForResult()); | 1864 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1851 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1865 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1852 EXPECT_TRUE(stream.get()); | 1866 EXPECT_TRUE(stream.get()); |
| 1853 | 1867 |
| 1854 // Ensure that session is alive and active. | 1868 // Ensure that session is alive and active. |
| 1855 QuicChromiumClientSession* session = | 1869 QuicChromiumClientSession* session = |
| 1856 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 1870 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 1857 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); | 1871 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1858 EXPECT_TRUE(HasActiveSession(host_port_pair_)); | 1872 EXPECT_TRUE(HasActiveSession(host_port_pair_)); |
| 1859 | 1873 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1882 MockWrite writes[] = {MockWrite(SYNCHRONOUS, request_packet->data(), | 1896 MockWrite writes[] = {MockWrite(SYNCHRONOUS, request_packet->data(), |
| 1883 request_packet->length(), 1)}; | 1897 request_packet->length(), 1)}; |
| 1884 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 1898 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 1885 arraysize(writes)); | 1899 arraysize(writes)); |
| 1886 socket_factory_.AddSocketDataProvider(&socket_data); | 1900 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1887 | 1901 |
| 1888 // Create request and QuicHttpStream. | 1902 // Create request and QuicHttpStream. |
| 1889 QuicStreamRequest request(factory_.get()); | 1903 QuicStreamRequest request(factory_.get()); |
| 1890 EXPECT_EQ(ERR_IO_PENDING, | 1904 EXPECT_EQ(ERR_IO_PENDING, |
| 1891 request.Request(host_port_pair_, privacy_mode_, | 1905 request.Request(host_port_pair_, privacy_mode_, |
| 1892 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1906 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1893 "GET", net_log_, callback_.callback())); | 1907 callback_.callback())); |
| 1894 EXPECT_EQ(OK, callback_.WaitForResult()); | 1908 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1895 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1909 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1896 EXPECT_TRUE(stream.get()); | 1910 EXPECT_TRUE(stream.get()); |
| 1897 | 1911 |
| 1898 // Cause QUIC stream to be created. | 1912 // Cause QUIC stream to be created. |
| 1899 HttpRequestInfo request_info; | 1913 HttpRequestInfo request_info; |
| 1900 request_info.method = "GET"; | 1914 request_info.method = "GET"; |
| 1901 request_info.url = GURL("https://www.example.org/"); | 1915 request_info.url = GURL("https://www.example.org/"); |
| 1902 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1916 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1903 net_log_, CompletionCallback())); | 1917 net_log_, CompletionCallback())); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 | 1964 |
| 1951 // Create a new request for the same destination and verify that a | 1965 // Create a new request for the same destination and verify that a |
| 1952 // new session is created. | 1966 // new session is created. |
| 1953 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 1967 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1954 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1968 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1955 socket_factory_.AddSocketDataProvider(&socket_data2); | 1969 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1956 | 1970 |
| 1957 QuicStreamRequest request2(factory_.get()); | 1971 QuicStreamRequest request2(factory_.get()); |
| 1958 EXPECT_EQ(ERR_IO_PENDING, | 1972 EXPECT_EQ(ERR_IO_PENDING, |
| 1959 request2.Request(host_port_pair_, privacy_mode_, | 1973 request2.Request(host_port_pair_, privacy_mode_, |
| 1960 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1974 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 1961 "GET", net_log_, callback_.callback())); | 1975 callback_.callback())); |
| 1962 EXPECT_EQ(OK, callback_.WaitForResult()); | 1976 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1963 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1977 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1964 EXPECT_TRUE(stream2.get()); | 1978 EXPECT_TRUE(stream2.get()); |
| 1965 | 1979 |
| 1966 EXPECT_TRUE( | 1980 EXPECT_TRUE( |
| 1967 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 1981 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 1968 QuicChromiumClientSession* new_session = | 1982 QuicChromiumClientSession* new_session = |
| 1969 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 1983 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 1970 EXPECT_NE(session, new_session); | 1984 EXPECT_NE(session, new_session); |
| 1971 | 1985 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2005 MockWrite(SYNCHRONOUS, client_rst->data(), client_rst->length(), 1), | 2019 MockWrite(SYNCHRONOUS, client_rst->data(), client_rst->length(), 1), |
| 2006 }; | 2020 }; |
| 2007 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 2021 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 2008 arraysize(writes)); | 2022 arraysize(writes)); |
| 2009 socket_factory_.AddSocketDataProvider(&socket_data); | 2023 socket_factory_.AddSocketDataProvider(&socket_data); |
| 2010 | 2024 |
| 2011 // Create request and QuicHttpStream. | 2025 // Create request and QuicHttpStream. |
| 2012 QuicStreamRequest request(factory_.get()); | 2026 QuicStreamRequest request(factory_.get()); |
| 2013 EXPECT_EQ(ERR_IO_PENDING, | 2027 EXPECT_EQ(ERR_IO_PENDING, |
| 2014 request.Request(host_port_pair_, privacy_mode_, | 2028 request.Request(host_port_pair_, privacy_mode_, |
| 2015 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2029 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2016 "GET", net_log_, callback_.callback())); | 2030 callback_.callback())); |
| 2017 EXPECT_EQ(OK, callback_.WaitForResult()); | 2031 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 2018 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2032 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2019 EXPECT_TRUE(stream.get()); | 2033 EXPECT_TRUE(stream.get()); |
| 2020 | 2034 |
| 2021 // Cause QUIC stream to be created. | 2035 // Cause QUIC stream to be created. |
| 2022 HttpRequestInfo request_info; | 2036 HttpRequestInfo request_info; |
| 2023 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2037 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2024 net_log_, CompletionCallback())); | 2038 net_log_, CompletionCallback())); |
| 2025 | 2039 |
| 2026 // Ensure that session is alive and active. | 2040 // Ensure that session is alive and active. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2063 writes.size()); | 2077 writes.size()); |
| 2064 socket_factory_.AddSocketDataProvider(&socket_data); | 2078 socket_factory_.AddSocketDataProvider(&socket_data); |
| 2065 | 2079 |
| 2066 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 2080 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 2067 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 2081 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 2068 socket_factory_.AddSocketDataProvider(&socket_data2); | 2082 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 2069 | 2083 |
| 2070 QuicStreamRequest request(factory_.get()); | 2084 QuicStreamRequest request(factory_.get()); |
| 2071 EXPECT_EQ(ERR_IO_PENDING, | 2085 EXPECT_EQ(ERR_IO_PENDING, |
| 2072 request.Request(host_port_pair_, privacy_mode_, | 2086 request.Request(host_port_pair_, privacy_mode_, |
| 2073 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2087 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2074 "GET", net_log_, callback_.callback())); | 2088 callback_.callback())); |
| 2075 | 2089 |
| 2076 EXPECT_EQ(OK, callback_.WaitForResult()); | 2090 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 2077 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2091 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2078 HttpRequestInfo request_info; | 2092 HttpRequestInfo request_info; |
| 2079 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2093 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2080 net_log_, CompletionCallback())); | 2094 net_log_, CompletionCallback())); |
| 2081 | 2095 |
| 2082 factory_->OnSSLConfigChanged(); | 2096 factory_->OnSSLConfigChanged(); |
| 2083 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 2097 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 2084 stream->ReadResponseHeaders(callback_.callback())); | 2098 stream->ReadResponseHeaders(callback_.callback())); |
| 2085 EXPECT_FALSE(factory_->require_confirmation()); | 2099 EXPECT_FALSE(factory_->require_confirmation()); |
| 2086 | 2100 |
| 2087 // Now attempting to request a stream to the same origin should create | 2101 // Now attempting to request a stream to the same origin should create |
| 2088 // a new session. | 2102 // a new session. |
| 2089 | 2103 |
| 2090 QuicStreamRequest request2(factory_.get()); | 2104 QuicStreamRequest request2(factory_.get()); |
| 2091 EXPECT_EQ(ERR_IO_PENDING, | 2105 EXPECT_EQ(ERR_IO_PENDING, |
| 2092 request2.Request(host_port_pair_, privacy_mode_, | 2106 request2.Request(host_port_pair_, privacy_mode_, |
| 2093 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2107 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2094 "GET", net_log_, callback_.callback())); | 2108 callback_.callback())); |
| 2095 | 2109 |
| 2096 EXPECT_EQ(OK, callback_.WaitForResult()); | 2110 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 2097 stream = request2.ReleaseStream(); | 2111 stream = request2.ReleaseStream(); |
| 2098 stream.reset(); // Will reset stream 3. | 2112 stream.reset(); // Will reset stream 3. |
| 2099 | 2113 |
| 2100 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2114 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 2101 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2115 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 2102 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 2116 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 2103 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 2117 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 2104 } | 2118 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2118 writes.size()); | 2132 writes.size()); |
| 2119 socket_factory_.AddSocketDataProvider(&socket_data); | 2133 socket_factory_.AddSocketDataProvider(&socket_data); |
| 2120 | 2134 |
| 2121 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 2135 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 2122 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 2136 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 2123 socket_factory_.AddSocketDataProvider(&socket_data2); | 2137 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 2124 | 2138 |
| 2125 QuicStreamRequest request(factory_.get()); | 2139 QuicStreamRequest request(factory_.get()); |
| 2126 EXPECT_EQ(ERR_IO_PENDING, | 2140 EXPECT_EQ(ERR_IO_PENDING, |
| 2127 request.Request(host_port_pair_, privacy_mode_, | 2141 request.Request(host_port_pair_, privacy_mode_, |
| 2128 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2142 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2129 "GET", net_log_, callback_.callback())); | 2143 callback_.callback())); |
| 2130 | 2144 |
| 2131 EXPECT_EQ(OK, callback_.WaitForResult()); | 2145 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 2132 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2146 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2133 HttpRequestInfo request_info; | 2147 HttpRequestInfo request_info; |
| 2134 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2148 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2135 net_log_, CompletionCallback())); | 2149 net_log_, CompletionCallback())); |
| 2136 | 2150 |
| 2137 // Add a cert and verify that stream saw the event. | 2151 // Add a cert and verify that stream saw the event. |
| 2138 factory_->OnCertAdded(nullptr); | 2152 factory_->OnCertAdded(nullptr); |
| 2139 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 2153 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 2140 stream->ReadResponseHeaders(callback_.callback())); | 2154 stream->ReadResponseHeaders(callback_.callback())); |
| 2141 EXPECT_FALSE(factory_->require_confirmation()); | 2155 EXPECT_FALSE(factory_->require_confirmation()); |
| 2142 | 2156 |
| 2143 // Now attempting to request a stream to the same origin should create | 2157 // Now attempting to request a stream to the same origin should create |
| 2144 // a new session. | 2158 // a new session. |
| 2145 | 2159 |
| 2146 QuicStreamRequest request2(factory_.get()); | 2160 QuicStreamRequest request2(factory_.get()); |
| 2147 EXPECT_EQ(ERR_IO_PENDING, | 2161 EXPECT_EQ(ERR_IO_PENDING, |
| 2148 request2.Request(host_port_pair_, privacy_mode_, | 2162 request2.Request(host_port_pair_, privacy_mode_, |
| 2149 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2163 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2150 "GET", net_log_, callback_.callback())); | 2164 callback_.callback())); |
| 2151 | 2165 |
| 2152 EXPECT_EQ(OK, callback_.WaitForResult()); | 2166 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 2153 stream = request2.ReleaseStream(); | 2167 stream = request2.ReleaseStream(); |
| 2154 stream.reset(); // Will reset stream 3. | 2168 stream.reset(); // Will reset stream 3. |
| 2155 | 2169 |
| 2156 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2170 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 2157 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2171 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 2158 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 2172 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 2159 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 2173 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 2160 } | 2174 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2174 writes.size()); | 2188 writes.size()); |
| 2175 socket_factory_.AddSocketDataProvider(&socket_data); | 2189 socket_factory_.AddSocketDataProvider(&socket_data); |
| 2176 | 2190 |
| 2177 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 2191 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 2178 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 2192 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 2179 socket_factory_.AddSocketDataProvider(&socket_data2); | 2193 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 2180 | 2194 |
| 2181 QuicStreamRequest request(factory_.get()); | 2195 QuicStreamRequest request(factory_.get()); |
| 2182 EXPECT_EQ(ERR_IO_PENDING, | 2196 EXPECT_EQ(ERR_IO_PENDING, |
| 2183 request.Request(host_port_pair_, privacy_mode_, | 2197 request.Request(host_port_pair_, privacy_mode_, |
| 2184 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2198 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2185 "GET", net_log_, callback_.callback())); | 2199 callback_.callback())); |
| 2186 | 2200 |
| 2187 EXPECT_EQ(OK, callback_.WaitForResult()); | 2201 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 2188 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2202 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2189 HttpRequestInfo request_info; | 2203 HttpRequestInfo request_info; |
| 2190 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2204 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2191 net_log_, CompletionCallback())); | 2205 net_log_, CompletionCallback())); |
| 2192 | 2206 |
| 2193 // Change the CA cert and verify that stream saw the event. | 2207 // Change the CA cert and verify that stream saw the event. |
| 2194 factory_->OnCACertChanged(nullptr); | 2208 factory_->OnCACertChanged(nullptr); |
| 2195 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 2209 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 2196 stream->ReadResponseHeaders(callback_.callback())); | 2210 stream->ReadResponseHeaders(callback_.callback())); |
| 2197 EXPECT_FALSE(factory_->require_confirmation()); | 2211 EXPECT_FALSE(factory_->require_confirmation()); |
| 2198 | 2212 |
| 2199 // Now attempting to request a stream to the same origin should create | 2213 // Now attempting to request a stream to the same origin should create |
| 2200 // a new session. | 2214 // a new session. |
| 2201 | 2215 |
| 2202 QuicStreamRequest request2(factory_.get()); | 2216 QuicStreamRequest request2(factory_.get()); |
| 2203 EXPECT_EQ(ERR_IO_PENDING, | 2217 EXPECT_EQ(ERR_IO_PENDING, |
| 2204 request2.Request(host_port_pair_, privacy_mode_, | 2218 request2.Request(host_port_pair_, privacy_mode_, |
| 2205 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2219 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2206 "GET", net_log_, callback_.callback())); | 2220 callback_.callback())); |
| 2207 | 2221 |
| 2208 EXPECT_EQ(OK, callback_.WaitForResult()); | 2222 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 2209 stream = request2.ReleaseStream(); | 2223 stream = request2.ReleaseStream(); |
| 2210 stream.reset(); // Will reset stream 3. | 2224 stream.reset(); // Will reset stream 3. |
| 2211 | 2225 |
| 2212 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2226 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 2213 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2227 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 2214 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 2228 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 2215 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 2229 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 2216 } | 2230 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2319 crypto_client_stream_factory_.set_handshake_mode( | 2333 crypto_client_stream_factory_.set_handshake_mode( |
| 2320 MockCryptoClientStream::ZERO_RTT); | 2334 MockCryptoClientStream::ZERO_RTT); |
| 2321 host_resolver_.set_synchronous_mode(true); | 2335 host_resolver_.set_synchronous_mode(true); |
| 2322 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2336 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2323 "192.168.0.1", ""); | 2337 "192.168.0.1", ""); |
| 2324 | 2338 |
| 2325 QuicStreamRequest request(factory_.get()); | 2339 QuicStreamRequest request(factory_.get()); |
| 2326 QuicServerId server_id(host_port_pair_, privacy_mode_); | 2340 QuicServerId server_id(host_port_pair_, privacy_mode_); |
| 2327 EXPECT_EQ(ERR_IO_PENDING, | 2341 EXPECT_EQ(ERR_IO_PENDING, |
| 2328 request.Request(host_port_pair_, privacy_mode_, | 2342 request.Request(host_port_pair_, privacy_mode_, |
| 2329 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2343 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2330 "GET", net_log_, callback_.callback())); | 2344 callback_.callback())); |
| 2331 EXPECT_EQ(2u, QuicStreamFactoryPeer::GetNumberOfActiveJobs(factory_.get(), | 2345 EXPECT_EQ(2u, QuicStreamFactoryPeer::GetNumberOfActiveJobs(factory_.get(), |
| 2332 server_id)); | 2346 server_id)); |
| 2333 | 2347 |
| 2334 runner_->RunNextTask(); | 2348 runner_->RunNextTask(); |
| 2335 | 2349 |
| 2336 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2350 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2337 EXPECT_TRUE(stream.get()); | 2351 EXPECT_TRUE(stream.get()); |
| 2338 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2352 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 2339 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2353 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 2340 EXPECT_EQ(0u, QuicStreamFactoryPeer::GetNumberOfActiveJobs(factory_.get(), | 2354 EXPECT_EQ(0u, QuicStreamFactoryPeer::GetNumberOfActiveJobs(factory_.get(), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2354 socket_factory_.AddSocketDataProvider(&socket_data); | 2368 socket_factory_.AddSocketDataProvider(&socket_data); |
| 2355 | 2369 |
| 2356 crypto_client_stream_factory_.set_handshake_mode( | 2370 crypto_client_stream_factory_.set_handshake_mode( |
| 2357 MockCryptoClientStream::ZERO_RTT); | 2371 MockCryptoClientStream::ZERO_RTT); |
| 2358 host_resolver_.set_synchronous_mode(true); | 2372 host_resolver_.set_synchronous_mode(true); |
| 2359 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2373 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2360 "192.168.0.1", ""); | 2374 "192.168.0.1", ""); |
| 2361 | 2375 |
| 2362 QuicStreamRequest request(factory_.get()); | 2376 QuicStreamRequest request(factory_.get()); |
| 2363 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 2377 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2364 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2378 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2365 "GET", net_log_, callback_.callback())); | 2379 callback_.callback())); |
| 2366 | 2380 |
| 2367 // If we are waiting for disk cache, we would have posted a task. Verify that | 2381 // If we are waiting for disk cache, we would have posted a task. Verify that |
| 2368 // the CancelWaitForDataReady task hasn't been posted. | 2382 // the CancelWaitForDataReady task hasn't been posted. |
| 2369 ASSERT_EQ(0u, runner_->GetPostedTasks().size()); | 2383 ASSERT_EQ(0u, runner_->GetPostedTasks().size()); |
| 2370 | 2384 |
| 2371 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2385 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2372 EXPECT_TRUE(stream.get()); | 2386 EXPECT_TRUE(stream.get()); |
| 2373 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2387 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 2374 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2388 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 2375 } | 2389 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2412 MockCryptoClientStream::ZERO_RTT); | 2426 MockCryptoClientStream::ZERO_RTT); |
| 2413 host_resolver_.set_synchronous_mode(true); | 2427 host_resolver_.set_synchronous_mode(true); |
| 2414 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2428 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2415 "192.168.0.1", ""); | 2429 "192.168.0.1", ""); |
| 2416 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2430 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2417 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 2431 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 2418 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); | 2432 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); |
| 2419 | 2433 |
| 2420 QuicStreamRequest request(factory_.get()); | 2434 QuicStreamRequest request(factory_.get()); |
| 2421 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 2435 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2422 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2436 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2423 "GET", net_log_, callback_.callback())); | 2437 callback_.callback())); |
| 2424 | 2438 |
| 2425 QuicChromiumClientSession* session = | 2439 QuicChromiumClientSession* session = |
| 2426 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 2440 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 2427 | 2441 |
| 2428 DVLOG(1) << "Create 1st session and test packet loss"; | 2442 DVLOG(1) << "Create 1st session and test packet loss"; |
| 2429 | 2443 |
| 2430 // Set packet_loss_rate to a lower value than packet_loss_threshold. | 2444 // Set packet_loss_rate to a lower value than packet_loss_threshold. |
| 2431 EXPECT_FALSE( | 2445 EXPECT_FALSE( |
| 2432 factory_->OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); | 2446 factory_->OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); |
| 2433 EXPECT_TRUE(session->connection()->connected()); | 2447 EXPECT_TRUE(session->connection()->connected()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2450 EXPECT_TRUE( | 2464 EXPECT_TRUE( |
| 2451 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 2465 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 2452 | 2466 |
| 2453 // Test N-in-a-row high packet loss connections. | 2467 // Test N-in-a-row high packet loss connections. |
| 2454 | 2468 |
| 2455 DVLOG(1) << "Create 2nd session and test packet loss"; | 2469 DVLOG(1) << "Create 2nd session and test packet loss"; |
| 2456 | 2470 |
| 2457 TestCompletionCallback callback2; | 2471 TestCompletionCallback callback2; |
| 2458 QuicStreamRequest request2(factory_.get()); | 2472 QuicStreamRequest request2(factory_.get()); |
| 2459 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 2473 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2460 /*cert_verify_flags=*/0, server2.host(), "GET", | 2474 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2461 net_log_, callback2.callback())); | 2475 callback2.callback())); |
| 2462 QuicChromiumClientSession* session2 = | 2476 QuicChromiumClientSession* session2 = |
| 2463 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); | 2477 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); |
| 2464 | 2478 |
| 2465 // If there is no packet loss during handshake confirmation, number of lossy | 2479 // If there is no packet loss during handshake confirmation, number of lossy |
| 2466 // connections for the port should be 0. | 2480 // connections for the port should be 0. |
| 2467 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 2481 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 2468 factory_.get(), server2.port())); | 2482 factory_.get(), server2.port())); |
| 2469 EXPECT_FALSE( | 2483 EXPECT_FALSE( |
| 2470 factory_->OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); | 2484 factory_->OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); |
| 2471 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 2485 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2482 EXPECT_TRUE(session2->connection()->connected()); | 2496 EXPECT_TRUE(session2->connection()->connected()); |
| 2483 EXPECT_FALSE( | 2497 EXPECT_FALSE( |
| 2484 QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), server2.port())); | 2498 QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), server2.port())); |
| 2485 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server2)); | 2499 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(factory_.get(), server2)); |
| 2486 | 2500 |
| 2487 DVLOG(1) << "Create 3rd session which also has packet loss"; | 2501 DVLOG(1) << "Create 3rd session which also has packet loss"; |
| 2488 | 2502 |
| 2489 TestCompletionCallback callback3; | 2503 TestCompletionCallback callback3; |
| 2490 QuicStreamRequest request3(factory_.get()); | 2504 QuicStreamRequest request3(factory_.get()); |
| 2491 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, | 2505 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 2492 /*cert_verify_flags=*/0, server3.host(), "GET", | 2506 /*cert_verify_flags=*/0, url3_, "GET", |
| 2493 net_log_, callback3.callback())); | 2507 net_log_, callback3.callback())); |
| 2494 QuicChromiumClientSession* session3 = | 2508 QuicChromiumClientSession* session3 = |
| 2495 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); | 2509 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); |
| 2496 | 2510 |
| 2497 DVLOG(1) << "Create 4th session with packet loss and test IsQuicDisabled()"; | 2511 DVLOG(1) << "Create 4th session with packet loss and test IsQuicDisabled()"; |
| 2498 TestCompletionCallback callback4; | 2512 TestCompletionCallback callback4; |
| 2499 QuicStreamRequest request4(factory_.get()); | 2513 QuicStreamRequest request4(factory_.get()); |
| 2500 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, | 2514 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, |
| 2501 /*cert_verify_flags=*/0, server4.host(), "GET", | 2515 /*cert_verify_flags=*/0, url4_, "GET", |
| 2502 net_log_, callback4.callback())); | 2516 net_log_, callback4.callback())); |
| 2503 QuicChromiumClientSession* session4 = | 2517 QuicChromiumClientSession* session4 = |
| 2504 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server4); | 2518 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server4); |
| 2505 | 2519 |
| 2506 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in | 2520 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in |
| 2507 // a row and that should close the session and disable QUIC. | 2521 // a row and that should close the session and disable QUIC. |
| 2508 EXPECT_TRUE( | 2522 EXPECT_TRUE( |
| 2509 factory_->OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); | 2523 factory_->OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); |
| 2510 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 2524 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 2511 factory_.get(), server3.port())); | 2525 factory_.get(), server3.port())); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2572 | 2586 |
| 2573 crypto_client_stream_factory_.set_handshake_mode( | 2587 crypto_client_stream_factory_.set_handshake_mode( |
| 2574 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2588 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2575 host_resolver_.set_synchronous_mode(true); | 2589 host_resolver_.set_synchronous_mode(true); |
| 2576 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2590 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2577 "192.168.0.1", ""); | 2591 "192.168.0.1", ""); |
| 2578 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2592 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2579 | 2593 |
| 2580 QuicStreamRequest request(factory_.get()); | 2594 QuicStreamRequest request(factory_.get()); |
| 2581 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 2595 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2582 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2596 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2583 "GET", net_log_, callback_.callback())); | 2597 callback_.callback())); |
| 2584 | 2598 |
| 2585 QuicChromiumClientSession* session = | 2599 QuicChromiumClientSession* session = |
| 2586 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 2600 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 2587 | 2601 |
| 2588 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; | 2602 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; |
| 2589 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, | 2603 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, |
| 2590 ConnectionCloseSource::FROM_PEER); | 2604 ConnectionCloseSource::FROM_PEER); |
| 2591 // Need to spin the loop now to ensure that | 2605 // Need to spin the loop now to ensure that |
| 2592 // QuicStreamFactory::OnSessionClosed() runs. | 2606 // QuicStreamFactory::OnSessionClosed() runs. |
| 2593 base::RunLoop run_loop; | 2607 base::RunLoop run_loop; |
| 2594 run_loop.RunUntilIdle(); | 2608 run_loop.RunUntilIdle(); |
| 2595 | 2609 |
| 2596 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( | 2610 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( |
| 2597 factory_.get())); | 2611 factory_.get())); |
| 2598 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2612 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 2599 host_port_pair_.port())); | 2613 host_port_pair_.port())); |
| 2600 | 2614 |
| 2601 // Test two-in-a-row public reset post handshakes.. | 2615 // Test two-in-a-row public reset post handshakes.. |
| 2602 DVLOG(1) << "Create 2nd session and trigger public reset post handshake"; | 2616 DVLOG(1) << "Create 2nd session and trigger public reset post handshake"; |
| 2603 TestCompletionCallback callback2; | 2617 TestCompletionCallback callback2; |
| 2604 QuicStreamRequest request2(factory_.get()); | 2618 QuicStreamRequest request2(factory_.get()); |
| 2605 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 2619 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2606 /*cert_verify_flags=*/0, server2.host(), "GET", | 2620 /*cert_verify_flags=*/0, url2_, "GET", |
| 2607 net_log_, callback2.callback())); | 2621 net_log_, callback2.callback())); |
| 2608 QuicChromiumClientSession* session2 = | 2622 QuicChromiumClientSession* session2 = |
| 2609 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); | 2623 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); |
| 2610 | 2624 |
| 2611 session2->connection()->CloseConnection(QUIC_PUBLIC_RESET, | 2625 session2->connection()->CloseConnection(QUIC_PUBLIC_RESET, |
| 2612 ConnectionCloseSource::FROM_PEER); | 2626 ConnectionCloseSource::FROM_PEER); |
| 2613 // Need to spin the loop now to ensure that | 2627 // Need to spin the loop now to ensure that |
| 2614 // QuicStreamFactory::OnSessionClosed() runs. | 2628 // QuicStreamFactory::OnSessionClosed() runs. |
| 2615 base::RunLoop run_loop2; | 2629 base::RunLoop run_loop2; |
| 2616 run_loop2.RunUntilIdle(); | 2630 run_loop2.RunUntilIdle(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2657 | 2671 |
| 2658 crypto_client_stream_factory_.set_handshake_mode( | 2672 crypto_client_stream_factory_.set_handshake_mode( |
| 2659 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2673 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2660 host_resolver_.set_synchronous_mode(true); | 2674 host_resolver_.set_synchronous_mode(true); |
| 2661 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2675 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2662 "192.168.0.1", ""); | 2676 "192.168.0.1", ""); |
| 2663 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2677 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2664 | 2678 |
| 2665 QuicStreamRequest request(factory_.get()); | 2679 QuicStreamRequest request(factory_.get()); |
| 2666 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 2680 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2667 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2681 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2668 "GET", net_log_, callback_.callback())); | 2682 callback_.callback())); |
| 2669 | 2683 |
| 2670 QuicChromiumClientSession* session = | 2684 QuicChromiumClientSession* session = |
| 2671 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 2685 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 2672 | 2686 |
| 2673 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2687 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2674 EXPECT_TRUE(stream.get()); | 2688 EXPECT_TRUE(stream.get()); |
| 2675 HttpRequestInfo request_info; | 2689 HttpRequestInfo request_info; |
| 2676 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2690 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2677 net_log_, CompletionCallback())); | 2691 net_log_, CompletionCallback())); |
| 2678 | 2692 |
| 2679 DVLOG(1) | 2693 DVLOG(1) |
| 2680 << "Created 1st session and initialized a stream. Now trigger timeout"; | 2694 << "Created 1st session and initialized a stream. Now trigger timeout"; |
| 2681 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, | 2695 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, |
| 2682 ConnectionCloseSource::FROM_SELF); | 2696 ConnectionCloseSource::FROM_SELF); |
| 2683 // Need to spin the loop now to ensure that | 2697 // Need to spin the loop now to ensure that |
| 2684 // QuicStreamFactory::OnSessionClosed() runs. | 2698 // QuicStreamFactory::OnSessionClosed() runs. |
| 2685 base::RunLoop run_loop; | 2699 base::RunLoop run_loop; |
| 2686 run_loop.RunUntilIdle(); | 2700 run_loop.RunUntilIdle(); |
| 2687 | 2701 |
| 2688 EXPECT_EQ( | 2702 EXPECT_EQ( |
| 2689 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 2703 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
| 2690 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2704 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 2691 host_port_pair_.port())); | 2705 host_port_pair_.port())); |
| 2692 | 2706 |
| 2693 // Test two-in-a-row timeouts with open streams. | 2707 // Test two-in-a-row timeouts with open streams. |
| 2694 DVLOG(1) << "Create 2nd session and timeout with open stream"; | 2708 DVLOG(1) << "Create 2nd session and timeout with open stream"; |
| 2695 TestCompletionCallback callback2; | 2709 TestCompletionCallback callback2; |
| 2696 QuicStreamRequest request2(factory_.get()); | 2710 QuicStreamRequest request2(factory_.get()); |
| 2697 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 2711 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2698 /*cert_verify_flags=*/0, server2.host(), "GET", | 2712 /*cert_verify_flags=*/0, url2_, "GET", |
| 2699 net_log_, callback2.callback())); | 2713 net_log_, callback2.callback())); |
| 2700 QuicChromiumClientSession* session2 = | 2714 QuicChromiumClientSession* session2 = |
| 2701 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); | 2715 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); |
| 2702 | 2716 |
| 2703 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 2717 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 2704 EXPECT_TRUE(stream2.get()); | 2718 EXPECT_TRUE(stream2.get()); |
| 2705 EXPECT_EQ(OK, stream2->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2719 EXPECT_EQ(OK, stream2->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2706 net_log_, CompletionCallback())); | 2720 net_log_, CompletionCallback())); |
| 2707 | 2721 |
| 2708 session2->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, | 2722 session2->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2755 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2769 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2756 host_resolver_.set_synchronous_mode(true); | 2770 host_resolver_.set_synchronous_mode(true); |
| 2757 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2771 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2758 "192.168.0.1", ""); | 2772 "192.168.0.1", ""); |
| 2759 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2773 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2760 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 2774 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 2761 | 2775 |
| 2762 // Test first and third out of three public reset post handshakes. | 2776 // Test first and third out of three public reset post handshakes. |
| 2763 QuicStreamRequest request(factory_.get()); | 2777 QuicStreamRequest request(factory_.get()); |
| 2764 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 2778 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2765 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2779 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2766 "GET", net_log_, callback_.callback())); | 2780 callback_.callback())); |
| 2767 | 2781 |
| 2768 QuicChromiumClientSession* session = | 2782 QuicChromiumClientSession* session = |
| 2769 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 2783 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 2770 | 2784 |
| 2771 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; | 2785 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; |
| 2772 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, | 2786 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, |
| 2773 ConnectionCloseSource::FROM_PEER); | 2787 ConnectionCloseSource::FROM_PEER); |
| 2774 // Need to spin the loop now to ensure that | 2788 // Need to spin the loop now to ensure that |
| 2775 // QuicStreamFactory::OnSessionClosed() runs. | 2789 // QuicStreamFactory::OnSessionClosed() runs. |
| 2776 base::RunLoop run_loop; | 2790 base::RunLoop run_loop; |
| 2777 run_loop.RunUntilIdle(); | 2791 run_loop.RunUntilIdle(); |
| 2778 | 2792 |
| 2779 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( | 2793 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( |
| 2780 factory_.get())); | 2794 factory_.get())); |
| 2781 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2795 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 2782 host_port_pair_.port())); | 2796 host_port_pair_.port())); |
| 2783 | 2797 |
| 2784 DVLOG(1) << "Create 2nd session without disable trigger"; | 2798 DVLOG(1) << "Create 2nd session without disable trigger"; |
| 2785 TestCompletionCallback callback2; | 2799 TestCompletionCallback callback2; |
| 2786 QuicStreamRequest request2(factory_.get()); | 2800 QuicStreamRequest request2(factory_.get()); |
| 2787 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 2801 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2788 /*cert_verify_flags=*/0, server2.host(), "GET", | 2802 /*cert_verify_flags=*/0, url2_, "GET", |
| 2789 net_log_, callback2.callback())); | 2803 net_log_, callback2.callback())); |
| 2790 QuicChromiumClientSession* session2 = | 2804 QuicChromiumClientSession* session2 = |
| 2791 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); | 2805 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); |
| 2792 | 2806 |
| 2793 session2->connection()->CloseConnection(QUIC_NO_ERROR, | 2807 session2->connection()->CloseConnection(QUIC_NO_ERROR, |
| 2794 ConnectionCloseSource::FROM_SELF); | 2808 ConnectionCloseSource::FROM_SELF); |
| 2795 // Need to spin the loop now to ensure that | 2809 // Need to spin the loop now to ensure that |
| 2796 // QuicStreamFactory::OnSessionClosed() runs. | 2810 // QuicStreamFactory::OnSessionClosed() runs. |
| 2797 base::RunLoop run_loop2; | 2811 base::RunLoop run_loop2; |
| 2798 run_loop2.RunUntilIdle(); | 2812 run_loop2.RunUntilIdle(); |
| 2799 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( | 2813 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( |
| 2800 factory_.get())); | 2814 factory_.get())); |
| 2801 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2815 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 2802 host_port_pair_.port())); | 2816 host_port_pair_.port())); |
| 2803 | 2817 |
| 2804 DVLOG(1) << "Create 3rd session with public reset post handshake," | 2818 DVLOG(1) << "Create 3rd session with public reset post handshake," |
| 2805 << " will disable QUIC"; | 2819 << " will disable QUIC"; |
| 2806 TestCompletionCallback callback3; | 2820 TestCompletionCallback callback3; |
| 2807 QuicStreamRequest request3(factory_.get()); | 2821 QuicStreamRequest request3(factory_.get()); |
| 2808 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, | 2822 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 2809 /*cert_verify_flags=*/0, server3.host(), "GET", | 2823 /*cert_verify_flags=*/0, url2_, "GET", |
| 2810 net_log_, callback3.callback())); | 2824 net_log_, callback3.callback())); |
| 2811 QuicChromiumClientSession* session3 = | 2825 QuicChromiumClientSession* session3 = |
| 2812 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); | 2826 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); |
| 2813 | 2827 |
| 2814 session3->connection()->CloseConnection(QUIC_PUBLIC_RESET, | 2828 session3->connection()->CloseConnection(QUIC_PUBLIC_RESET, |
| 2815 ConnectionCloseSource::FROM_PEER); | 2829 ConnectionCloseSource::FROM_PEER); |
| 2816 // Need to spin the loop now to ensure that | 2830 // Need to spin the loop now to ensure that |
| 2817 // QuicStreamFactory::OnSessionClosed() runs. | 2831 // QuicStreamFactory::OnSessionClosed() runs. |
| 2818 base::RunLoop run_loop3; | 2832 base::RunLoop run_loop3; |
| 2819 run_loop3.RunUntilIdle(); | 2833 run_loop3.RunUntilIdle(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2873 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2887 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2874 host_resolver_.set_synchronous_mode(true); | 2888 host_resolver_.set_synchronous_mode(true); |
| 2875 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2889 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2876 "192.168.0.1", ""); | 2890 "192.168.0.1", ""); |
| 2877 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2891 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2878 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 2892 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 2879 | 2893 |
| 2880 // Test first and third out of three timeouts with open streams. | 2894 // Test first and third out of three timeouts with open streams. |
| 2881 QuicStreamRequest request(factory_.get()); | 2895 QuicStreamRequest request(factory_.get()); |
| 2882 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 2896 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2883 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2897 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2884 "GET", net_log_, callback_.callback())); | 2898 callback_.callback())); |
| 2885 | 2899 |
| 2886 QuicChromiumClientSession* session = | 2900 QuicChromiumClientSession* session = |
| 2887 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 2901 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 2888 | 2902 |
| 2889 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2903 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2890 EXPECT_TRUE(stream.get()); | 2904 EXPECT_TRUE(stream.get()); |
| 2891 HttpRequestInfo request_info; | 2905 HttpRequestInfo request_info; |
| 2892 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2906 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2893 net_log_, CompletionCallback())); | 2907 net_log_, CompletionCallback())); |
| 2894 | 2908 |
| 2895 DVLOG(1) | 2909 DVLOG(1) |
| 2896 << "Created 1st session and initialized a stream. Now trigger timeout"; | 2910 << "Created 1st session and initialized a stream. Now trigger timeout"; |
| 2897 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, | 2911 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, |
| 2898 ConnectionCloseSource::FROM_SELF); | 2912 ConnectionCloseSource::FROM_SELF); |
| 2899 // Need to spin the loop now to ensure that | 2913 // Need to spin the loop now to ensure that |
| 2900 // QuicStreamFactory::OnSessionClosed() runs. | 2914 // QuicStreamFactory::OnSessionClosed() runs. |
| 2901 base::RunLoop run_loop; | 2915 base::RunLoop run_loop; |
| 2902 run_loop.RunUntilIdle(); | 2916 run_loop.RunUntilIdle(); |
| 2903 | 2917 |
| 2904 EXPECT_EQ( | 2918 EXPECT_EQ( |
| 2905 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 2919 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
| 2906 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2920 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 2907 host_port_pair_.port())); | 2921 host_port_pair_.port())); |
| 2908 | 2922 |
| 2909 // Test two-in-a-row timeouts with open streams. | 2923 // Test two-in-a-row timeouts with open streams. |
| 2910 DVLOG(1) << "Create 2nd session without timeout"; | 2924 DVLOG(1) << "Create 2nd session without timeout"; |
| 2911 TestCompletionCallback callback2; | 2925 TestCompletionCallback callback2; |
| 2912 QuicStreamRequest request2(factory_.get()); | 2926 QuicStreamRequest request2(factory_.get()); |
| 2913 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 2927 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2914 /*cert_verify_flags=*/0, server2.host(), "GET", | 2928 /*cert_verify_flags=*/0, url2_, "GET", |
| 2915 net_log_, callback2.callback())); | 2929 net_log_, callback2.callback())); |
| 2916 QuicChromiumClientSession* session2 = | 2930 QuicChromiumClientSession* session2 = |
| 2917 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); | 2931 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); |
| 2918 | 2932 |
| 2919 session2->connection()->CloseConnection(QUIC_NO_ERROR, | 2933 session2->connection()->CloseConnection(QUIC_NO_ERROR, |
| 2920 ConnectionCloseSource::FROM_PEER); | 2934 ConnectionCloseSource::FROM_PEER); |
| 2921 // Need to spin the loop now to ensure that | 2935 // Need to spin the loop now to ensure that |
| 2922 // QuicStreamFactory::OnSessionClosed() runs. | 2936 // QuicStreamFactory::OnSessionClosed() runs. |
| 2923 base::RunLoop run_loop2; | 2937 base::RunLoop run_loop2; |
| 2924 run_loop2.RunUntilIdle(); | 2938 run_loop2.RunUntilIdle(); |
| 2925 EXPECT_EQ( | 2939 EXPECT_EQ( |
| 2926 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 2940 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
| 2927 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 2941 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 2928 host_port_pair_.port())); | 2942 host_port_pair_.port())); |
| 2929 | 2943 |
| 2930 DVLOG(1) << "Create 3rd session with timeout with open streams," | 2944 DVLOG(1) << "Create 3rd session with timeout with open streams," |
| 2931 << " will disable QUIC"; | 2945 << " will disable QUIC"; |
| 2932 | 2946 |
| 2933 TestCompletionCallback callback3; | 2947 TestCompletionCallback callback3; |
| 2934 QuicStreamRequest request3(factory_.get()); | 2948 QuicStreamRequest request3(factory_.get()); |
| 2935 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, | 2949 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 2936 /*cert_verify_flags=*/0, server3.host(), "GET", | 2950 /*cert_verify_flags=*/0, url3_, "GET", |
| 2937 net_log_, callback3.callback())); | 2951 net_log_, callback3.callback())); |
| 2938 QuicChromiumClientSession* session3 = | 2952 QuicChromiumClientSession* session3 = |
| 2939 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); | 2953 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); |
| 2940 | 2954 |
| 2941 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 2955 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
| 2942 EXPECT_TRUE(stream3.get()); | 2956 EXPECT_TRUE(stream3.get()); |
| 2943 EXPECT_EQ(OK, stream3->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2957 EXPECT_EQ(OK, stream3->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2944 net_log_, CompletionCallback())); | 2958 net_log_, CompletionCallback())); |
| 2945 session3->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, | 2959 session3->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, |
| 2946 ConnectionCloseSource::FROM_SELF); | 2960 ConnectionCloseSource::FROM_SELF); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2984 | 2998 |
| 2985 crypto_client_stream_factory_.set_handshake_mode( | 2999 crypto_client_stream_factory_.set_handshake_mode( |
| 2986 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 3000 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2987 host_resolver_.set_synchronous_mode(true); | 3001 host_resolver_.set_synchronous_mode(true); |
| 2988 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 3002 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2989 "192.168.0.1", ""); | 3003 "192.168.0.1", ""); |
| 2990 | 3004 |
| 2991 // Test first timeouts with open streams will disable QUIC. | 3005 // Test first timeouts with open streams will disable QUIC. |
| 2992 QuicStreamRequest request(factory_.get()); | 3006 QuicStreamRequest request(factory_.get()); |
| 2993 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 3007 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2994 /*cert_verify_flags=*/0, host_port_pair_.host(), | 3008 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 2995 "GET", net_log_, callback_.callback())); | 3009 callback_.callback())); |
| 2996 | 3010 |
| 2997 QuicChromiumClientSession* session = | 3011 QuicChromiumClientSession* session = |
| 2998 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 3012 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 2999 | 3013 |
| 3000 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 3014 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 3001 EXPECT_TRUE(stream.get()); | 3015 EXPECT_TRUE(stream.get()); |
| 3002 HttpRequestInfo request_info; | 3016 HttpRequestInfo request_info; |
| 3003 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 3017 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 3004 net_log_, CompletionCallback())); | 3018 net_log_, CompletionCallback())); |
| 3005 | 3019 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3063 host_resolver_.set_synchronous_mode(true); | 3077 host_resolver_.set_synchronous_mode(true); |
| 3064 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 3078 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 3065 "192.168.0.1", ""); | 3079 "192.168.0.1", ""); |
| 3066 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 3080 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 3067 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 3081 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 3068 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); | 3082 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); |
| 3069 | 3083 |
| 3070 // Test first and fourth out of four public reset post handshakes. | 3084 // Test first and fourth out of four public reset post handshakes. |
| 3071 QuicStreamRequest request(factory_.get()); | 3085 QuicStreamRequest request(factory_.get()); |
| 3072 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 3086 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 3073 /*cert_verify_flags=*/0, host_port_pair_.host(), | 3087 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 3074 "GET", net_log_, callback_.callback())); | 3088 callback_.callback())); |
| 3075 | 3089 |
| 3076 QuicChromiumClientSession* session = | 3090 QuicChromiumClientSession* session = |
| 3077 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 3091 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 3078 | 3092 |
| 3079 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; | 3093 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; |
| 3080 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, | 3094 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, |
| 3081 ConnectionCloseSource::FROM_PEER); | 3095 ConnectionCloseSource::FROM_PEER); |
| 3082 // Need to spin the loop now to ensure that | 3096 // Need to spin the loop now to ensure that |
| 3083 // QuicStreamFactory::OnSessionClosed() runs. | 3097 // QuicStreamFactory::OnSessionClosed() runs. |
| 3084 base::RunLoop run_loop; | 3098 base::RunLoop run_loop; |
| 3085 run_loop.RunUntilIdle(); | 3099 run_loop.RunUntilIdle(); |
| 3086 | 3100 |
| 3087 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( | 3101 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( |
| 3088 factory_.get())); | 3102 factory_.get())); |
| 3089 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 3103 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 3090 host_port_pair_.port())); | 3104 host_port_pair_.port())); |
| 3091 | 3105 |
| 3092 DVLOG(1) << "Create 2nd and 3rd sessions without disable trigger"; | 3106 DVLOG(1) << "Create 2nd and 3rd sessions without disable trigger"; |
| 3093 TestCompletionCallback callback2; | 3107 TestCompletionCallback callback2; |
| 3094 QuicStreamRequest request2(factory_.get()); | 3108 QuicStreamRequest request2(factory_.get()); |
| 3095 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 3109 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 3096 /*cert_verify_flags=*/0, server2.host(), "GET", | 3110 /*cert_verify_flags=*/0, url2_, "GET", |
| 3097 net_log_, callback2.callback())); | 3111 net_log_, callback2.callback())); |
| 3098 QuicChromiumClientSession* session2 = | 3112 QuicChromiumClientSession* session2 = |
| 3099 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); | 3113 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); |
| 3100 | 3114 |
| 3101 session2->connection()->CloseConnection(QUIC_NO_ERROR, | 3115 session2->connection()->CloseConnection(QUIC_NO_ERROR, |
| 3102 ConnectionCloseSource::FROM_SELF); | 3116 ConnectionCloseSource::FROM_SELF); |
| 3103 // Need to spin the loop now to ensure that | 3117 // Need to spin the loop now to ensure that |
| 3104 // QuicStreamFactory::OnSessionClosed() runs. | 3118 // QuicStreamFactory::OnSessionClosed() runs. |
| 3105 base::RunLoop run_loop2; | 3119 base::RunLoop run_loop2; |
| 3106 run_loop2.RunUntilIdle(); | 3120 run_loop2.RunUntilIdle(); |
| 3107 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( | 3121 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( |
| 3108 factory_.get())); | 3122 factory_.get())); |
| 3109 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 3123 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 3110 host_port_pair_.port())); | 3124 host_port_pair_.port())); |
| 3111 | 3125 |
| 3112 TestCompletionCallback callback3; | 3126 TestCompletionCallback callback3; |
| 3113 QuicStreamRequest request3(factory_.get()); | 3127 QuicStreamRequest request3(factory_.get()); |
| 3114 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, | 3128 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 3115 /*cert_verify_flags=*/0, server3.host(), "GET", | 3129 /*cert_verify_flags=*/0, url3_, "GET", |
| 3116 net_log_, callback3.callback())); | 3130 net_log_, callback3.callback())); |
| 3117 QuicChromiumClientSession* session3 = | 3131 QuicChromiumClientSession* session3 = |
| 3118 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); | 3132 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); |
| 3119 | 3133 |
| 3120 session3->connection()->CloseConnection(QUIC_NO_ERROR, | 3134 session3->connection()->CloseConnection(QUIC_NO_ERROR, |
| 3121 ConnectionCloseSource::FROM_SELF); | 3135 ConnectionCloseSource::FROM_SELF); |
| 3122 // Need to spin the loop now to ensure that | 3136 // Need to spin the loop now to ensure that |
| 3123 // QuicStreamFactory::OnSessionClosed() runs. | 3137 // QuicStreamFactory::OnSessionClosed() runs. |
| 3124 base::RunLoop run_loop3; | 3138 base::RunLoop run_loop3; |
| 3125 run_loop3.RunUntilIdle(); | 3139 run_loop3.RunUntilIdle(); |
| 3126 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( | 3140 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake( |
| 3127 factory_.get())); | 3141 factory_.get())); |
| 3128 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 3142 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 3129 host_port_pair_.port())); | 3143 host_port_pair_.port())); |
| 3130 | 3144 |
| 3131 DVLOG(1) << "Create 4rd session with public reset post handshake," | 3145 DVLOG(1) << "Create 4rd session with public reset post handshake," |
| 3132 << " will not disable QUIC"; | 3146 << " will not disable QUIC"; |
| 3133 TestCompletionCallback callback4; | 3147 TestCompletionCallback callback4; |
| 3134 QuicStreamRequest request4(factory_.get()); | 3148 QuicStreamRequest request4(factory_.get()); |
| 3135 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, | 3149 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, |
| 3136 /*cert_verify_flags=*/0, server4.host(), "GET", | 3150 /*cert_verify_flags=*/0, url4_, "GET", |
| 3137 net_log_, callback4.callback())); | 3151 net_log_, callback4.callback())); |
| 3138 QuicChromiumClientSession* session4 = | 3152 QuicChromiumClientSession* session4 = |
| 3139 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server4); | 3153 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server4); |
| 3140 | 3154 |
| 3141 session4->connection()->CloseConnection(QUIC_PUBLIC_RESET, | 3155 session4->connection()->CloseConnection(QUIC_PUBLIC_RESET, |
| 3142 ConnectionCloseSource::FROM_PEER); | 3156 ConnectionCloseSource::FROM_PEER); |
| 3143 // Need to spin the loop now to ensure that | 3157 // Need to spin the loop now to ensure that |
| 3144 // QuicStreamFactory::OnSessionClosed() runs. | 3158 // QuicStreamFactory::OnSessionClosed() runs. |
| 3145 base::RunLoop run_loop4; | 3159 base::RunLoop run_loop4; |
| 3146 run_loop4.RunUntilIdle(); | 3160 run_loop4.RunUntilIdle(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3207 host_resolver_.set_synchronous_mode(true); | 3221 host_resolver_.set_synchronous_mode(true); |
| 3208 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 3222 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 3209 "192.168.0.1", ""); | 3223 "192.168.0.1", ""); |
| 3210 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 3224 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 3211 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 3225 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 3212 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); | 3226 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); |
| 3213 | 3227 |
| 3214 // Test first and fourth out of three timeouts with open streams. | 3228 // Test first and fourth out of three timeouts with open streams. |
| 3215 QuicStreamRequest request(factory_.get()); | 3229 QuicStreamRequest request(factory_.get()); |
| 3216 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 3230 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 3217 /*cert_verify_flags=*/0, host_port_pair_.host(), | 3231 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 3218 "GET", net_log_, callback_.callback())); | 3232 callback_.callback())); |
| 3219 | 3233 |
| 3220 QuicChromiumClientSession* session = | 3234 QuicChromiumClientSession* session = |
| 3221 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); | 3235 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 3222 | 3236 |
| 3223 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 3237 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 3224 EXPECT_TRUE(stream.get()); | 3238 EXPECT_TRUE(stream.get()); |
| 3225 HttpRequestInfo request_info; | 3239 HttpRequestInfo request_info; |
| 3226 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 3240 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 3227 net_log_, CompletionCallback())); | 3241 net_log_, CompletionCallback())); |
| 3228 | 3242 |
| 3229 DVLOG(1) | 3243 DVLOG(1) |
| 3230 << "Created 1st session and initialized a stream. Now trigger timeout"; | 3244 << "Created 1st session and initialized a stream. Now trigger timeout"; |
| 3231 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, | 3245 session->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, |
| 3232 ConnectionCloseSource::FROM_SELF); | 3246 ConnectionCloseSource::FROM_SELF); |
| 3233 // Need to spin the loop now to ensure that | 3247 // Need to spin the loop now to ensure that |
| 3234 // QuicStreamFactory::OnSessionClosed() runs. | 3248 // QuicStreamFactory::OnSessionClosed() runs. |
| 3235 base::RunLoop run_loop; | 3249 base::RunLoop run_loop; |
| 3236 run_loop.RunUntilIdle(); | 3250 run_loop.RunUntilIdle(); |
| 3237 | 3251 |
| 3238 EXPECT_EQ( | 3252 EXPECT_EQ( |
| 3239 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 3253 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
| 3240 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 3254 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 3241 host_port_pair_.port())); | 3255 host_port_pair_.port())); |
| 3242 | 3256 |
| 3243 DVLOG(1) << "Create 2nd and 3rd sessions without timeout"; | 3257 DVLOG(1) << "Create 2nd and 3rd sessions without timeout"; |
| 3244 TestCompletionCallback callback2; | 3258 TestCompletionCallback callback2; |
| 3245 QuicStreamRequest request2(factory_.get()); | 3259 QuicStreamRequest request2(factory_.get()); |
| 3246 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, | 3260 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 3247 /*cert_verify_flags=*/0, server2.host(), "GET", | 3261 /*cert_verify_flags=*/0, url2_, "GET", |
| 3248 net_log_, callback2.callback())); | 3262 net_log_, callback2.callback())); |
| 3249 QuicChromiumClientSession* session2 = | 3263 QuicChromiumClientSession* session2 = |
| 3250 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); | 3264 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server2); |
| 3251 | 3265 |
| 3252 session2->connection()->CloseConnection(QUIC_NO_ERROR, | 3266 session2->connection()->CloseConnection(QUIC_NO_ERROR, |
| 3253 ConnectionCloseSource::FROM_PEER); | 3267 ConnectionCloseSource::FROM_PEER); |
| 3254 // Need to spin the loop now to ensure that | 3268 // Need to spin the loop now to ensure that |
| 3255 // QuicStreamFactory::OnSessionClosed() runs. | 3269 // QuicStreamFactory::OnSessionClosed() runs. |
| 3256 base::RunLoop run_loop2; | 3270 base::RunLoop run_loop2; |
| 3257 run_loop2.RunUntilIdle(); | 3271 run_loop2.RunUntilIdle(); |
| 3258 EXPECT_EQ( | 3272 EXPECT_EQ( |
| 3259 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 3273 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
| 3260 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 3274 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 3261 host_port_pair_.port())); | 3275 host_port_pair_.port())); |
| 3262 | 3276 |
| 3263 TestCompletionCallback callback3; | 3277 TestCompletionCallback callback3; |
| 3264 QuicStreamRequest request3(factory_.get()); | 3278 QuicStreamRequest request3(factory_.get()); |
| 3265 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, | 3279 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 3266 /*cert_verify_flags=*/0, server3.host(), "GET", | 3280 /*cert_verify_flags=*/0, url3_, "GET", |
| 3267 net_log_, callback3.callback())); | 3281 net_log_, callback3.callback())); |
| 3268 QuicChromiumClientSession* session3 = | 3282 QuicChromiumClientSession* session3 = |
| 3269 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); | 3283 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server3); |
| 3270 | 3284 |
| 3271 session3->connection()->CloseConnection(QUIC_NO_ERROR, | 3285 session3->connection()->CloseConnection(QUIC_NO_ERROR, |
| 3272 ConnectionCloseSource::FROM_PEER); | 3286 ConnectionCloseSource::FROM_PEER); |
| 3273 // Need to spin the loop now to ensure that | 3287 // Need to spin the loop now to ensure that |
| 3274 // QuicStreamFactory::OnSessionClosed() runs. | 3288 // QuicStreamFactory::OnSessionClosed() runs. |
| 3275 base::RunLoop run_loop3; | 3289 base::RunLoop run_loop3; |
| 3276 run_loop3.RunUntilIdle(); | 3290 run_loop3.RunUntilIdle(); |
| 3277 EXPECT_EQ( | 3291 EXPECT_EQ( |
| 3278 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); | 3292 1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(factory_.get())); |
| 3279 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), | 3293 EXPECT_FALSE(QuicStreamFactoryPeer::IsQuicDisabled(factory_.get(), |
| 3280 host_port_pair_.port())); | 3294 host_port_pair_.port())); |
| 3281 | 3295 |
| 3282 DVLOG(1) << "Create 4th session with timeout with open streams," | 3296 DVLOG(1) << "Create 4th session with timeout with open streams," |
| 3283 << " will not disable QUIC"; | 3297 << " will not disable QUIC"; |
| 3284 | 3298 |
| 3285 TestCompletionCallback callback4; | 3299 TestCompletionCallback callback4; |
| 3286 QuicStreamRequest request4(factory_.get()); | 3300 QuicStreamRequest request4(factory_.get()); |
| 3287 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, | 3301 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, |
| 3288 /*cert_verify_flags=*/0, server4.host(), "GET", | 3302 /*cert_verify_flags=*/0, url4_, "GET", |
| 3289 net_log_, callback4.callback())); | 3303 net_log_, callback4.callback())); |
| 3290 QuicChromiumClientSession* session4 = | 3304 QuicChromiumClientSession* session4 = |
| 3291 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server4); | 3305 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), server4); |
| 3292 | 3306 |
| 3293 scoped_ptr<QuicHttpStream> stream4 = request4.ReleaseStream(); | 3307 scoped_ptr<QuicHttpStream> stream4 = request4.ReleaseStream(); |
| 3294 EXPECT_TRUE(stream4.get()); | 3308 EXPECT_TRUE(stream4.get()); |
| 3295 EXPECT_EQ(OK, stream4->InitializeStream(&request_info, DEFAULT_PRIORITY, | 3309 EXPECT_EQ(OK, stream4->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 3296 net_log_, CompletionCallback())); | 3310 net_log_, CompletionCallback())); |
| 3297 session4->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, | 3311 session4->connection()->CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, |
| 3298 ConnectionCloseSource::FROM_SELF); | 3312 ConnectionCloseSource::FROM_SELF); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3335 | 3349 |
| 3336 crypto_client_stream_factory_.set_handshake_mode( | 3350 crypto_client_stream_factory_.set_handshake_mode( |
| 3337 MockCryptoClientStream::ZERO_RTT); | 3351 MockCryptoClientStream::ZERO_RTT); |
| 3338 host_resolver_.set_synchronous_mode(true); | 3352 host_resolver_.set_synchronous_mode(true); |
| 3339 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 3353 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 3340 "192.168.0.1", ""); | 3354 "192.168.0.1", ""); |
| 3341 | 3355 |
| 3342 QuicStreamRequest request(factory_.get()); | 3356 QuicStreamRequest request(factory_.get()); |
| 3343 EXPECT_EQ(ERR_IO_PENDING, | 3357 EXPECT_EQ(ERR_IO_PENDING, |
| 3344 request.Request(host_port_pair_, privacy_mode_, | 3358 request.Request(host_port_pair_, privacy_mode_, |
| 3345 /*cert_verify_flags=*/0, host_port_pair_.host(), | 3359 /*cert_verify_flags=*/0, url_, "POST", net_log_, |
| 3346 "POST", net_log_, callback_.callback())); | 3360 callback_.callback())); |
| 3347 | 3361 |
| 3348 // If we don't delay TCP connection, then time delay should be 0. | 3362 // If we don't delay TCP connection, then time delay should be 0. |
| 3349 EXPECT_FALSE(factory_->delay_tcp_race()); | 3363 EXPECT_FALSE(factory_->delay_tcp_race()); |
| 3350 EXPECT_EQ(base::TimeDelta(), request.GetTimeDelayForWaitingJob()); | 3364 EXPECT_EQ(base::TimeDelta(), request.GetTimeDelayForWaitingJob()); |
| 3351 | 3365 |
| 3352 // Enable |delay_tcp_race_| param and verify delay is one RTT and that | 3366 // Enable |delay_tcp_race_| param and verify delay is one RTT and that |
| 3353 // server supports QUIC. | 3367 // server supports QUIC. |
| 3354 QuicStreamFactoryPeer::SetDelayTcpRace(factory_.get(), true); | 3368 QuicStreamFactoryPeer::SetDelayTcpRace(factory_.get(), true); |
| 3355 EXPECT_TRUE(factory_->delay_tcp_race()); | 3369 EXPECT_TRUE(factory_->delay_tcp_race()); |
| 3356 EXPECT_EQ(base::TimeDelta::FromMicroseconds(15), | 3370 EXPECT_EQ(base::TimeDelta::FromMicroseconds(15), |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 "192.168.0.1", ""); | 3501 "192.168.0.1", ""); |
| 3488 | 3502 |
| 3489 // Set up the TaskObserver to verify QuicChromiumPacketReader::StartReading | 3503 // Set up the TaskObserver to verify QuicChromiumPacketReader::StartReading |
| 3490 // posts a task. | 3504 // posts a task. |
| 3491 // TODO(rtenneti): Change SpdySessionTestTaskObserver to NetTestTaskObserver?? | 3505 // TODO(rtenneti): Change SpdySessionTestTaskObserver to NetTestTaskObserver?? |
| 3492 SpdySessionTestTaskObserver observer("quic_chromium_packet_reader.cc", | 3506 SpdySessionTestTaskObserver observer("quic_chromium_packet_reader.cc", |
| 3493 "StartReading"); | 3507 "StartReading"); |
| 3494 | 3508 |
| 3495 QuicStreamRequest request(factory_.get()); | 3509 QuicStreamRequest request(factory_.get()); |
| 3496 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 3510 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 3497 /*cert_verify_flags=*/0, host_port_pair_.host(), | 3511 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 3498 "GET", net_log_, callback_.callback())); | 3512 callback_.callback())); |
| 3499 | 3513 |
| 3500 // Call run_loop so that QuicChromiumPacketReader::OnReadComplete() gets | 3514 // Call run_loop so that QuicChromiumPacketReader::OnReadComplete() gets |
| 3501 // called. | 3515 // called. |
| 3502 base::RunLoop run_loop; | 3516 base::RunLoop run_loop; |
| 3503 run_loop.RunUntilIdle(); | 3517 run_loop.RunUntilIdle(); |
| 3504 | 3518 |
| 3505 // Verify task that the observer's executed_count is 1, which indicates | 3519 // Verify task that the observer's executed_count is 1, which indicates |
| 3506 // QuicChromiumPacketReader::StartReading() has posted only one task and | 3520 // QuicChromiumPacketReader::StartReading() has posted only one task and |
| 3507 // yielded the read. | 3521 // yielded the read. |
| 3508 EXPECT_EQ(1u, observer.executed_count()); | 3522 EXPECT_EQ(1u, observer.executed_count()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3536 "192.168.0.1", ""); | 3550 "192.168.0.1", ""); |
| 3537 | 3551 |
| 3538 // Set up the TaskObserver to verify QuicChromiumPacketReader::StartReading | 3552 // Set up the TaskObserver to verify QuicChromiumPacketReader::StartReading |
| 3539 // posts a task. | 3553 // posts a task. |
| 3540 // TODO(rtenneti): Change SpdySessionTestTaskObserver to NetTestTaskObserver?? | 3554 // TODO(rtenneti): Change SpdySessionTestTaskObserver to NetTestTaskObserver?? |
| 3541 SpdySessionTestTaskObserver observer("quic_chromium_packet_reader.cc", | 3555 SpdySessionTestTaskObserver observer("quic_chromium_packet_reader.cc", |
| 3542 "StartReading"); | 3556 "StartReading"); |
| 3543 | 3557 |
| 3544 QuicStreamRequest request(factory_.get()); | 3558 QuicStreamRequest request(factory_.get()); |
| 3545 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, | 3559 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 3546 /*cert_verify_flags=*/0, host_port_pair_.host(), | 3560 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 3547 "GET", net_log_, callback_.callback())); | 3561 callback_.callback())); |
| 3548 | 3562 |
| 3549 // Call run_loop so that QuicChromiumPacketReader::OnReadComplete() gets | 3563 // Call run_loop so that QuicChromiumPacketReader::OnReadComplete() gets |
| 3550 // called. | 3564 // called. |
| 3551 base::RunLoop run_loop; | 3565 base::RunLoop run_loop; |
| 3552 run_loop.RunUntilIdle(); | 3566 run_loop.RunUntilIdle(); |
| 3553 | 3567 |
| 3554 // Verify task that the observer's executed_count is 1, which indicates | 3568 // Verify task that the observer's executed_count is 1, which indicates |
| 3555 // QuicChromiumPacketReader::StartReading() has posted only one task and | 3569 // QuicChromiumPacketReader::StartReading() has posted only one task and |
| 3556 // yielded the read. | 3570 // yielded the read. |
| 3557 EXPECT_EQ(1u, observer.executed_count()); | 3571 EXPECT_EQ(1u, observer.executed_count()); |
| 3558 | 3572 |
| 3559 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 3573 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 3560 EXPECT_TRUE(stream.get()); | 3574 EXPECT_TRUE(stream.get()); |
| 3561 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 3575 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 3562 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 3576 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 3563 } | 3577 } |
| 3564 | 3578 |
| 3579 TEST_P(QuicStreamFactoryTest, ServerPushSessionAffinity) { |
| 3580 Initialize(); |
| 3581 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 3582 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 3583 |
| 3584 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 3585 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 3586 socket_factory_.AddSocketDataProvider(&socket_data); |
| 3587 |
| 3588 QuicStreamRequest request(factory_.get()); |
| 3589 EXPECT_EQ(ERR_IO_PENDING, |
| 3590 request.Request(host_port_pair_, privacy_mode_, |
| 3591 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 3592 callback_.callback())); |
| 3593 |
| 3594 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 3595 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 3596 EXPECT_TRUE(stream.get()); |
| 3597 |
| 3598 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumPushStreamsCreated(factory_.get())); |
| 3599 |
| 3600 std::string url = "https://www.example.org/"; |
| 3601 |
| 3602 QuicChromiumClientSession* session = |
| 3603 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 3604 |
| 3605 QuicClientPromisedInfo promised(session, kServerDataStreamId1, url); |
| 3606 (*QuicStreamFactoryPeer::GetPushPromiseIndex(factory_.get()) |
| 3607 ->promised_by_url())[url] = &promised; |
| 3608 |
| 3609 QuicStreamRequest request2(factory_.get()); |
| 3610 EXPECT_EQ(OK, request2.Request(host_port_pair_, privacy_mode_, |
| 3611 /*cert_verify_flags=*/0, GURL(url), "GET", |
| 3612 net_log_, callback_.callback())); |
| 3613 |
| 3614 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumPushStreamsCreated(factory_.get())); |
| 3615 } |
| 3616 |
| 3617 TEST_P(QuicStreamFactoryTest, ServerPushPrivacyModeMismatch) { |
| 3618 Initialize(); |
| 3619 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 3620 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 3621 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 3622 |
| 3623 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 3624 |
| 3625 scoped_ptr<QuicEncryptedPacket> client_rst(maker_.MakeRstPacket( |
| 3626 1, true, kServerDataStreamId1, QUIC_STREAM_CANCELLED)); |
| 3627 MockWrite writes[] = { |
| 3628 MockWrite(SYNCHRONOUS, client_rst->data(), client_rst->length(), 1), |
| 3629 }; |
| 3630 |
| 3631 SequencedSocketData socket_data1(reads, arraysize(reads), writes, |
| 3632 arraysize(writes)); |
| 3633 SequencedSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 3634 |
| 3635 socket_factory_.AddSocketDataProvider(&socket_data1); |
| 3636 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 3637 |
| 3638 QuicStreamRequest request(factory_.get()); |
| 3639 EXPECT_EQ(ERR_IO_PENDING, |
| 3640 request.Request(host_port_pair_, privacy_mode_, |
| 3641 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 3642 callback_.callback())); |
| 3643 |
| 3644 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 3645 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 3646 EXPECT_TRUE(stream.get()); |
| 3647 |
| 3648 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumPushStreamsCreated(factory_.get())); |
| 3649 |
| 3650 std::string url = "https://www.example.org/"; |
| 3651 QuicChromiumClientSession* session = |
| 3652 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 3653 |
| 3654 QuicClientPromisedInfo promised(session, kServerDataStreamId1, url); |
| 3655 |
| 3656 QuicClientPushPromiseIndex* index = |
| 3657 QuicStreamFactoryPeer::GetPushPromiseIndex(factory_.get()); |
| 3658 |
| 3659 (*index->promised_by_url())[url] = &promised; |
| 3660 EXPECT_EQ(index->GetPromised(url), &promised); |
| 3661 |
| 3662 // Doing the request should not use the push stream, but rather |
| 3663 // cancel it because the privacy modes do not match. |
| 3664 QuicStreamRequest request2(factory_.get()); |
| 3665 EXPECT_EQ(ERR_IO_PENDING, |
| 3666 request2.Request(host_port_pair_, PRIVACY_MODE_ENABLED, |
| 3667 /*cert_verify_flags=*/0, GURL(url), "GET", |
| 3668 net_log_, callback_.callback())); |
| 3669 |
| 3670 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumPushStreamsCreated(factory_.get())); |
| 3671 EXPECT_EQ(index->GetPromised(url), nullptr); |
| 3672 |
| 3673 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 3674 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 3675 EXPECT_TRUE(stream2.get()); |
| 3676 |
| 3677 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 3678 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 3679 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 3680 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 3681 } |
| 3682 |
| 3565 } // namespace test | 3683 } // namespace test |
| 3566 } // namespace net | 3684 } // namespace net |
| OLD | NEW |