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