| 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" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 } // namespace anonymous | 80 } // namespace anonymous |
| 81 | 81 |
| 82 class QuicStreamFactoryPeer { | 82 class QuicStreamFactoryPeer { |
| 83 public: | 83 public: |
| 84 static QuicCryptoClientConfig* GetCryptoConfig(QuicStreamFactory* factory) { | 84 static QuicCryptoClientConfig* GetCryptoConfig(QuicStreamFactory* factory) { |
| 85 return &factory->crypto_config_; | 85 return &factory->crypto_config_; |
| 86 } | 86 } |
| 87 | 87 |
| 88 static bool HasActiveSession(QuicStreamFactory* factory, | 88 static bool HasActiveSession(QuicStreamFactory* factory, |
| 89 const HostPortPair& host_port_pair, | 89 const HostPortPair& host_port_pair) { |
| 90 bool is_https) { | 90 QuicServerId server_id(host_port_pair, /*is_https=*/true, |
| 91 QuicServerId server_id(host_port_pair, is_https, PRIVACY_MODE_DISABLED); | 91 PRIVACY_MODE_DISABLED); |
| 92 return factory->HasActiveSession(server_id); | 92 return factory->HasActiveSession(server_id); |
| 93 } | 93 } |
| 94 | 94 |
| 95 static QuicChromiumClientSession* GetActiveSession( | 95 static QuicChromiumClientSession* GetActiveSession( |
| 96 QuicStreamFactory* factory, | 96 QuicStreamFactory* factory, |
| 97 const HostPortPair& host_port_pair, | 97 const HostPortPair& host_port_pair) { |
| 98 bool is_https) { | 98 QuicServerId server_id(host_port_pair, /*is_https=*/true, |
| 99 QuicServerId server_id(host_port_pair, is_https, PRIVACY_MODE_DISABLED); | 99 PRIVACY_MODE_DISABLED); |
| 100 DCHECK(factory->HasActiveSession(server_id)); | 100 DCHECK(factory->HasActiveSession(server_id)); |
| 101 return factory->active_sessions_[server_id]; | 101 return factory->active_sessions_[server_id]; |
| 102 } | 102 } |
| 103 | 103 |
| 104 static scoped_ptr<QuicHttpStream> CreateFromSession( | 104 static scoped_ptr<QuicHttpStream> CreateFromSession( |
| 105 QuicStreamFactory* factory, | 105 QuicStreamFactory* factory, |
| 106 QuicChromiumClientSession* session) { | 106 QuicChromiumClientSession* session) { |
| 107 return factory->CreateFromSession(session); | 107 return factory->CreateFromSession(session); |
| 108 } | 108 } |
| 109 | 109 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 /*max_number_of_lossy_connections=*/0, | 292 /*max_number_of_lossy_connections=*/0, |
| 293 /*packet_loss_threshold=*/1.0f, | 293 /*packet_loss_threshold=*/1.0f, |
| 294 /*max_disabled_reasons=*/3, | 294 /*max_disabled_reasons=*/3, |
| 295 /*threshold_timeouts_with_open_streams=*/2, | 295 /*threshold_timeouts_with_open_streams=*/2, |
| 296 /*threshold_pulic_resets_post_handshake=*/2, | 296 /*threshold_pulic_resets_post_handshake=*/2, |
| 297 /*receive_buffer_size=*/0, | 297 /*receive_buffer_size=*/0, |
| 298 /*delay_tcp_race=*/false, | 298 /*delay_tcp_race=*/false, |
| 299 /*store_server_configs_in_properties=*/false, | 299 /*store_server_configs_in_properties=*/false, |
| 300 QuicTagVector()), | 300 QuicTagVector()), |
| 301 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), | 301 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), |
| 302 is_https_(false), | |
| 303 privacy_mode_(PRIVACY_MODE_DISABLED) { | 302 privacy_mode_(PRIVACY_MODE_DISABLED) { |
| 304 factory_.set_require_confirmation(false); | 303 factory_.set_require_confirmation(false); |
| 305 factory_.set_quic_server_info_factory(new MockQuicServerInfoFactory()); | 304 factory_.set_quic_server_info_factory(new MockQuicServerInfoFactory()); |
| 306 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 305 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 307 QuicStreamFactoryPeer::SetEnableConnectionRacing( | 306 QuicStreamFactoryPeer::SetEnableConnectionRacing( |
| 308 &factory_, GetParam().enable_connection_racing); | 307 &factory_, GetParam().enable_connection_racing); |
| 309 } | 308 } |
| 310 | 309 |
| 311 bool HasActiveSession(const HostPortPair& host_port_pair) { | 310 bool HasActiveSession(const HostPortPair& host_port_pair) { |
| 312 return QuicStreamFactoryPeer::HasActiveSession(&factory_, host_port_pair, | 311 return QuicStreamFactoryPeer::HasActiveSession(&factory_, host_port_pair); |
| 313 /*is_https_=*/false); | |
| 314 } | 312 } |
| 315 | 313 |
| 316 scoped_ptr<QuicHttpStream> CreateFromSession( | 314 scoped_ptr<QuicHttpStream> CreateFromSession( |
| 317 const HostPortPair& host_port_pair) { | 315 const HostPortPair& host_port_pair) { |
| 318 QuicChromiumClientSession* session = | 316 QuicChromiumClientSession* session = |
| 319 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair, | 317 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair); |
| 320 /*is_https=*/false); | |
| 321 return QuicStreamFactoryPeer::CreateFromSession(&factory_, session); | 318 return QuicStreamFactoryPeer::CreateFromSession(&factory_, session); |
| 322 } | 319 } |
| 323 | 320 |
| 324 int GetSourcePortForNewSession(const HostPortPair& destination) { | 321 int GetSourcePortForNewSession(const HostPortPair& destination) { |
| 325 return GetSourcePortForNewSessionInner(destination, false); | 322 return GetSourcePortForNewSessionInner(destination, false); |
| 326 } | 323 } |
| 327 | 324 |
| 328 int GetSourcePortForNewSessionAndGoAway( | 325 int GetSourcePortForNewSessionAndGoAway( |
| 329 const HostPortPair& destination) { | 326 const HostPortPair& destination) { |
| 330 return GetSourcePortForNewSessionInner(destination, true); | 327 return GetSourcePortForNewSessionInner(destination, true); |
| 331 } | 328 } |
| 332 | 329 |
| 333 int GetSourcePortForNewSessionInner(const HostPortPair& destination, | 330 int GetSourcePortForNewSessionInner(const HostPortPair& destination, |
| 334 bool goaway_received) { | 331 bool goaway_received) { |
| 335 // Should only be called if there is no active session for this destination. | 332 // Should only be called if there is no active session for this destination. |
| 336 EXPECT_FALSE(HasActiveSession(destination)); | 333 EXPECT_FALSE(HasActiveSession(destination)); |
| 337 size_t socket_count = socket_factory_.udp_client_sockets().size(); | 334 size_t socket_count = socket_factory_.udp_client_sockets().size(); |
| 338 | 335 |
| 339 MockRead reads[] = { | 336 MockRead reads[] = { |
| 340 MockRead(ASYNC, OK, 0) // EOF | 337 MockRead(ASYNC, OK, 0) // EOF |
| 341 }; | 338 }; |
| 342 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 339 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 343 socket_data.StopAfter(1); | 340 socket_data.StopAfter(1); |
| 344 socket_factory_.AddSocketDataProvider(&socket_data); | 341 socket_factory_.AddSocketDataProvider(&socket_data); |
| 345 | 342 |
| 346 QuicStreamRequest request(&factory_); | 343 QuicStreamRequest request(&factory_); |
| 347 EXPECT_EQ(ERR_IO_PENDING, | 344 EXPECT_EQ(ERR_IO_PENDING, |
| 348 request.Request(destination, is_https_, privacy_mode_, | 345 request.Request(destination, privacy_mode_, |
| 349 /*cert_verify_flags=*/0, destination.host(), | 346 /*cert_verify_flags=*/0, destination.host(), |
| 350 "GET", net_log_, callback_.callback())); | 347 "GET", net_log_, callback_.callback())); |
| 351 | 348 |
| 352 EXPECT_EQ(OK, callback_.WaitForResult()); | 349 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 353 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 350 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 354 EXPECT_TRUE(stream.get()); | 351 EXPECT_TRUE(stream.get()); |
| 355 stream.reset(); | 352 stream.reset(); |
| 356 | 353 |
| 357 QuicChromiumClientSession* session = | 354 QuicChromiumClientSession* session = |
| 358 QuicStreamFactoryPeer::GetActiveSession(&factory_, destination, | 355 QuicStreamFactoryPeer::GetActiveSession(&factory_, destination); |
| 359 is_https_); | |
| 360 | 356 |
| 361 if (socket_count + 1 != socket_factory_.udp_client_sockets().size()) { | 357 if (socket_count + 1 != socket_factory_.udp_client_sockets().size()) { |
| 362 EXPECT_TRUE(false); | 358 EXPECT_TRUE(false); |
| 363 return 0; | 359 return 0; |
| 364 } | 360 } |
| 365 | 361 |
| 366 IPEndPoint endpoint; | 362 IPEndPoint endpoint; |
| 367 socket_factory_. | 363 socket_factory_. |
| 368 udp_client_sockets()[socket_count]->GetLocalAddress(&endpoint); | 364 udp_client_sockets()[socket_count]->GetLocalAddress(&endpoint); |
| 369 int port = endpoint.port(); | 365 int port = endpoint.port(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 MockRandom random_generator_; | 405 MockRandom random_generator_; |
| 410 MockClock* clock_; // Owned by factory_. | 406 MockClock* clock_; // Owned by factory_. |
| 411 scoped_refptr<TestTaskRunner> runner_; | 407 scoped_refptr<TestTaskRunner> runner_; |
| 412 QuicTestPacketMaker maker_; | 408 QuicTestPacketMaker maker_; |
| 413 HttpServerPropertiesImpl http_server_properties_; | 409 HttpServerPropertiesImpl http_server_properties_; |
| 414 scoped_ptr<CertVerifier> cert_verifier_; | 410 scoped_ptr<CertVerifier> cert_verifier_; |
| 415 scoped_ptr<ChannelIDService> channel_id_service_; | 411 scoped_ptr<ChannelIDService> channel_id_service_; |
| 416 TransportSecurityState transport_security_state_; | 412 TransportSecurityState transport_security_state_; |
| 417 QuicStreamFactory factory_; | 413 QuicStreamFactory factory_; |
| 418 HostPortPair host_port_pair_; | 414 HostPortPair host_port_pair_; |
| 419 bool is_https_; | |
| 420 PrivacyMode privacy_mode_; | 415 PrivacyMode privacy_mode_; |
| 421 BoundNetLog net_log_; | 416 BoundNetLog net_log_; |
| 422 TestCompletionCallback callback_; | 417 TestCompletionCallback callback_; |
| 423 }; | 418 }; |
| 424 | 419 |
| 425 INSTANTIATE_TEST_CASE_P(Version, | 420 INSTANTIATE_TEST_CASE_P(Version, |
| 426 QuicStreamFactoryTest, | 421 QuicStreamFactoryTest, |
| 427 ::testing::ValuesIn(GetTestParams())); | 422 ::testing::ValuesIn(GetTestParams())); |
| 428 | 423 |
| 429 TEST_P(QuicStreamFactoryTest, Create) { | 424 TEST_P(QuicStreamFactoryTest, Create) { |
| 430 MockRead reads[] = { | 425 MockRead reads[] = { |
| 431 MockRead(ASYNC, OK, 0) // EOF | 426 MockRead(ASYNC, OK, 0) // EOF |
| 432 }; | 427 }; |
| 433 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 428 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 434 socket_factory_.AddSocketDataProvider(&socket_data); | 429 socket_factory_.AddSocketDataProvider(&socket_data); |
| 435 socket_data.StopAfter(1); | 430 socket_data.StopAfter(1); |
| 436 | 431 |
| 437 QuicStreamRequest request(&factory_); | 432 QuicStreamRequest request(&factory_); |
| 438 EXPECT_EQ(ERR_IO_PENDING, | 433 EXPECT_EQ(ERR_IO_PENDING, |
| 439 request.Request(host_port_pair_, is_https_, privacy_mode_, | 434 request.Request(host_port_pair_, privacy_mode_, |
| 440 /*cert_verify_flags=*/0, host_port_pair_.host(), | 435 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 441 "GET", net_log_, callback_.callback())); | 436 "GET", net_log_, callback_.callback())); |
| 442 | 437 |
| 443 EXPECT_EQ(OK, callback_.WaitForResult()); | 438 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 444 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 439 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 445 EXPECT_TRUE(stream.get()); | 440 EXPECT_TRUE(stream.get()); |
| 446 | 441 |
| 447 // Will reset stream 3. | 442 // Will reset stream 3. |
| 448 stream = CreateFromSession(host_port_pair_); | 443 stream = CreateFromSession(host_port_pair_); |
| 449 EXPECT_TRUE(stream.get()); | 444 EXPECT_TRUE(stream.get()); |
| 450 | 445 |
| 451 // TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result | 446 // TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result |
| 452 // in streams on different sessions. | 447 // in streams on different sessions. |
| 453 QuicStreamRequest request2(&factory_); | 448 QuicStreamRequest request2(&factory_); |
| 454 EXPECT_EQ(OK, | 449 EXPECT_EQ(OK, |
| 455 request2.Request(host_port_pair_, is_https_, privacy_mode_, | 450 request2.Request(host_port_pair_, privacy_mode_, |
| 456 /*cert_verify_flags=*/0, host_port_pair_.host(), | 451 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 457 "GET", net_log_, callback_.callback())); | 452 "GET", net_log_, callback_.callback())); |
| 458 stream = request2.ReleaseStream(); // Will reset stream 5. | 453 stream = request2.ReleaseStream(); // Will reset stream 5. |
| 459 stream.reset(); // Will reset stream 7. | 454 stream.reset(); // Will reset stream 7. |
| 460 | 455 |
| 461 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 456 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 462 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 457 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 463 } | 458 } |
| 464 | 459 |
| 465 TEST_P(QuicStreamFactoryTest, CreateZeroRtt) { | 460 TEST_P(QuicStreamFactoryTest, CreateZeroRtt) { |
| 466 MockRead reads[] = { | 461 MockRead reads[] = { |
| 467 MockRead(ASYNC, OK, 0) // EOF | 462 MockRead(ASYNC, OK, 0) // EOF |
| 468 }; | 463 }; |
| 469 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 464 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 470 socket_factory_.AddSocketDataProvider(&socket_data); | 465 socket_factory_.AddSocketDataProvider(&socket_data); |
| 471 socket_data.StopAfter(1); | 466 socket_data.StopAfter(1); |
| 472 | 467 |
| 473 crypto_client_stream_factory_.set_handshake_mode( | 468 crypto_client_stream_factory_.set_handshake_mode( |
| 474 MockCryptoClientStream::ZERO_RTT); | 469 MockCryptoClientStream::ZERO_RTT); |
| 475 host_resolver_.set_synchronous_mode(true); | 470 host_resolver_.set_synchronous_mode(true); |
| 476 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 471 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 477 "192.168.0.1", ""); | 472 "192.168.0.1", ""); |
| 478 | 473 |
| 479 QuicStreamRequest request(&factory_); | 474 QuicStreamRequest request(&factory_); |
| 480 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 475 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 481 /*cert_verify_flags=*/0, host_port_pair_.host(), | 476 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 482 "GET", net_log_, callback_.callback())); | 477 "GET", net_log_, callback_.callback())); |
| 483 | 478 |
| 484 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 479 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 485 EXPECT_TRUE(stream.get()); | 480 EXPECT_TRUE(stream.get()); |
| 486 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 481 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 487 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 482 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 488 } | 483 } |
| 489 | 484 |
| 490 TEST_P(QuicStreamFactoryTest, CreateZeroRttPost) { | 485 TEST_P(QuicStreamFactoryTest, CreateZeroRttPost) { |
| 491 MockRead reads[] = { | 486 MockRead reads[] = { |
| 492 MockRead(ASYNC, OK, 0) // EOF | 487 MockRead(ASYNC, OK, 0) // EOF |
| 493 }; | 488 }; |
| 494 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 489 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 495 socket_factory_.AddSocketDataProvider(&socket_data); | 490 socket_factory_.AddSocketDataProvider(&socket_data); |
| 496 socket_data.StopAfter(1); | 491 socket_data.StopAfter(1); |
| 497 | 492 |
| 498 crypto_client_stream_factory_.set_handshake_mode( | 493 crypto_client_stream_factory_.set_handshake_mode( |
| 499 MockCryptoClientStream::ZERO_RTT); | 494 MockCryptoClientStream::ZERO_RTT); |
| 500 host_resolver_.set_synchronous_mode(true); | 495 host_resolver_.set_synchronous_mode(true); |
| 501 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 496 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 502 "192.168.0.1", ""); | 497 "192.168.0.1", ""); |
| 503 | 498 |
| 504 QuicStreamRequest request(&factory_); | 499 QuicStreamRequest request(&factory_); |
| 505 // Posts require handshake confirmation, so this will return asynchronously. | 500 // Posts require handshake confirmation, so this will return asynchronously. |
| 506 EXPECT_EQ(ERR_IO_PENDING, | 501 EXPECT_EQ(ERR_IO_PENDING, |
| 507 request.Request(host_port_pair_, is_https_, privacy_mode_, | 502 request.Request(host_port_pair_, privacy_mode_, |
| 508 /*cert_verify_flags=*/0, host_port_pair_.host(), | 503 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 509 "POST", net_log_, callback_.callback())); | 504 "POST", net_log_, callback_.callback())); |
| 510 | 505 |
| 511 // Confirm the handshake and verify that the stream is created. | 506 // Confirm the handshake and verify that the stream is created. |
| 512 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( | 507 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( |
| 513 QuicSession::HANDSHAKE_CONFIRMED); | 508 QuicSession::HANDSHAKE_CONFIRMED); |
| 514 | 509 |
| 515 EXPECT_EQ(OK, callback_.WaitForResult()); | 510 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 516 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 511 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 517 EXPECT_TRUE(stream.get()); | 512 EXPECT_TRUE(stream.get()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 528 socket_data.StopAfter(1); | 523 socket_data.StopAfter(1); |
| 529 | 524 |
| 530 crypto_client_stream_factory_.set_handshake_mode( | 525 crypto_client_stream_factory_.set_handshake_mode( |
| 531 MockCryptoClientStream::ZERO_RTT); | 526 MockCryptoClientStream::ZERO_RTT); |
| 532 host_resolver_.set_synchronous_mode(true); | 527 host_resolver_.set_synchronous_mode(true); |
| 533 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 528 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 534 "192.168.0.1", ""); | 529 "192.168.0.1", ""); |
| 535 | 530 |
| 536 QuicStreamRequest request(&factory_); | 531 QuicStreamRequest request(&factory_); |
| 537 int rv = request.Request( | 532 int rv = request.Request( |
| 538 host_port_pair_, is_https_, privacy_mode_, /*cert_verify_flags=*/0, | 533 host_port_pair_, privacy_mode_, /*cert_verify_flags=*/0, |
| 539 "different.host.example.com", "GET", net_log_, callback_.callback()); | 534 "different.host.example.com", "GET", net_log_, callback_.callback()); |
| 540 // If server and origin have different hostnames, then handshake confirmation | 535 // If server and origin have different hostnames, then handshake confirmation |
| 541 // should be required, so Request will return asynchronously. | 536 // should be required, so Request will return asynchronously. |
| 542 EXPECT_EQ(ERR_IO_PENDING, rv); | 537 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 543 // Confirm handshake. | 538 // Confirm handshake. |
| 544 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( | 539 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( |
| 545 QuicSession::HANDSHAKE_CONFIRMED); | 540 QuicSession::HANDSHAKE_CONFIRMED); |
| 546 EXPECT_EQ(OK, callback_.WaitForResult()); | 541 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 547 | 542 |
| 548 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 543 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 549 EXPECT_TRUE(stream.get()); | 544 EXPECT_TRUE(stream.get()); |
| 550 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 545 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 551 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 546 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 552 } | 547 } |
| 553 | 548 |
| 554 TEST_P(QuicStreamFactoryTest, CreateHttpVsHttps) { | |
| 555 MockRead reads[] = { | |
| 556 MockRead(ASYNC, OK, 0) // EOF | |
| 557 }; | |
| 558 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); | |
| 559 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | |
| 560 socket_factory_.AddSocketDataProvider(&socket_data1); | |
| 561 socket_factory_.AddSocketDataProvider(&socket_data2); | |
| 562 socket_data1.StopAfter(1); | |
| 563 socket_data2.StopAfter(1); | |
| 564 | |
| 565 QuicStreamRequest request(&factory_); | |
| 566 EXPECT_EQ(ERR_IO_PENDING, | |
| 567 request.Request(host_port_pair_, is_https_, privacy_mode_, | |
| 568 /*cert_verify_flags=*/0, host_port_pair_.host(), | |
| 569 "GET", net_log_, callback_.callback())); | |
| 570 | |
| 571 EXPECT_EQ(OK, callback_.WaitForResult()); | |
| 572 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | |
| 573 EXPECT_TRUE(stream.get()); | |
| 574 | |
| 575 QuicStreamRequest request2(&factory_); | |
| 576 EXPECT_EQ(ERR_IO_PENDING, | |
| 577 request2.Request(host_port_pair_, !is_https_, privacy_mode_, | |
| 578 /*cert_verify_flags=*/0, host_port_pair_.host(), | |
| 579 "GET", net_log_, callback_.callback())); | |
| 580 EXPECT_EQ(OK, callback_.WaitForResult()); | |
| 581 stream = request2.ReleaseStream(); | |
| 582 EXPECT_TRUE(stream.get()); | |
| 583 stream.reset(); | |
| 584 | |
| 585 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | |
| 586 &factory_, host_port_pair_, is_https_), | |
| 587 QuicStreamFactoryPeer::GetActiveSession( | |
| 588 &factory_, host_port_pair_, !is_https_)); | |
| 589 | |
| 590 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | |
| 591 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | |
| 592 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | |
| 593 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | |
| 594 } | |
| 595 | |
| 596 TEST_P(QuicStreamFactoryTest, GoAway) { | 549 TEST_P(QuicStreamFactoryTest, GoAway) { |
| 597 MockRead reads[] = { | 550 MockRead reads[] = { |
| 598 MockRead(ASYNC, OK, 0) // EOF | 551 MockRead(ASYNC, OK, 0) // EOF |
| 599 }; | 552 }; |
| 600 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 553 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 601 socket_factory_.AddSocketDataProvider(&socket_data); | 554 socket_factory_.AddSocketDataProvider(&socket_data); |
| 602 socket_data.StopAfter(1); | 555 socket_data.StopAfter(1); |
| 603 | 556 |
| 604 QuicStreamRequest request(&factory_); | 557 QuicStreamRequest request(&factory_); |
| 605 EXPECT_EQ(ERR_IO_PENDING, | 558 EXPECT_EQ(ERR_IO_PENDING, |
| 606 request.Request(host_port_pair_, is_https_, privacy_mode_, | 559 request.Request(host_port_pair_, privacy_mode_, |
| 607 /*cert_verify_flags=*/0, host_port_pair_.host(), | 560 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 608 "GET", net_log_, callback_.callback())); | 561 "GET", net_log_, callback_.callback())); |
| 609 | 562 |
| 610 EXPECT_EQ(OK, callback_.WaitForResult()); | 563 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 611 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 564 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 612 EXPECT_TRUE(stream.get()); | 565 EXPECT_TRUE(stream.get()); |
| 613 | 566 |
| 614 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 567 QuicChromiumClientSession* session = |
| 615 &factory_, host_port_pair_, is_https_); | 568 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 616 | 569 |
| 617 session->OnGoAway(QuicGoAwayFrame()); | 570 session->OnGoAway(QuicGoAwayFrame()); |
| 618 | 571 |
| 619 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 572 EXPECT_FALSE( |
| 620 &factory_, host_port_pair_, is_https_)); | 573 QuicStreamFactoryPeer::HasActiveSession(&factory_, host_port_pair_)); |
| 621 | 574 |
| 622 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 575 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 623 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 576 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 624 } | 577 } |
| 625 | 578 |
| 626 TEST_P(QuicStreamFactoryTest, Pooling) { | 579 TEST_P(QuicStreamFactoryTest, Pooling) { |
| 627 MockRead reads[] = { | 580 MockRead reads[] = { |
| 628 MockRead(ASYNC, OK, 0) // EOF | 581 MockRead(ASYNC, OK, 0) // EOF |
| 629 }; | 582 }; |
| 630 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 583 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 631 socket_factory_.AddSocketDataProvider(&socket_data); | 584 socket_factory_.AddSocketDataProvider(&socket_data); |
| 632 socket_data.StopAfter(1); | 585 socket_data.StopAfter(1); |
| 633 | 586 |
| 634 HostPortPair server2("mail.google.com", kDefaultServerPort); | 587 HostPortPair server2("mail.google.com", kDefaultServerPort); |
| 635 host_resolver_.set_synchronous_mode(true); | 588 host_resolver_.set_synchronous_mode(true); |
| 636 host_resolver_.rules()->AddIPLiteralRule( | 589 host_resolver_.rules()->AddIPLiteralRule( |
| 637 kDefaultServerHostName, "192.168.0.1", ""); | 590 kDefaultServerHostName, "192.168.0.1", ""); |
| 638 host_resolver_.rules()->AddIPLiteralRule( | 591 host_resolver_.rules()->AddIPLiteralRule( |
| 639 "mail.google.com", "192.168.0.1", ""); | 592 "mail.google.com", "192.168.0.1", ""); |
| 640 | 593 |
| 641 QuicStreamRequest request(&factory_); | 594 QuicStreamRequest request(&factory_); |
| 642 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 595 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 643 /*cert_verify_flags=*/0, host_port_pair_.host(), | 596 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 644 "GET", net_log_, callback_.callback())); | 597 "GET", net_log_, callback_.callback())); |
| 645 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 598 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 646 EXPECT_TRUE(stream.get()); | 599 EXPECT_TRUE(stream.get()); |
| 647 | 600 |
| 648 TestCompletionCallback callback; | 601 TestCompletionCallback callback; |
| 649 QuicStreamRequest request2(&factory_); | 602 QuicStreamRequest request2(&factory_); |
| 650 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 603 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 651 /*cert_verify_flags=*/0, server2.host(), "GET", | 604 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 652 net_log_, callback.callback())); | 605 net_log_, callback.callback())); |
| 653 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 606 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 654 EXPECT_TRUE(stream2.get()); | 607 EXPECT_TRUE(stream2.get()); |
| 655 | 608 |
| 656 EXPECT_EQ( | 609 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_), |
| 657 QuicStreamFactoryPeer::GetActiveSession( | 610 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2)); |
| 658 &factory_, host_port_pair_, is_https_), | |
| 659 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); | |
| 660 | 611 |
| 661 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 612 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 662 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 613 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 663 } | 614 } |
| 664 | 615 |
| 665 TEST_P(QuicStreamFactoryTest, NoPoolingIfDisabled) { | 616 TEST_P(QuicStreamFactoryTest, NoPoolingIfDisabled) { |
| 666 MockRead reads[] = { | 617 MockRead reads[] = { |
| 667 MockRead(ASYNC, OK, 0) // EOF | 618 MockRead(ASYNC, OK, 0) // EOF |
| 668 }; | 619 }; |
| 669 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); | 620 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); |
| 670 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | 621 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 671 socket_factory_.AddSocketDataProvider(&socket_data1); | 622 socket_factory_.AddSocketDataProvider(&socket_data1); |
| 672 socket_factory_.AddSocketDataProvider(&socket_data2); | 623 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 673 socket_data1.StopAfter(1); | 624 socket_data1.StopAfter(1); |
| 674 socket_data2.StopAfter(1); | 625 socket_data2.StopAfter(1); |
| 675 | 626 |
| 676 HostPortPair server2("mail.google.com", kDefaultServerPort); | 627 HostPortPair server2("mail.google.com", kDefaultServerPort); |
| 677 host_resolver_.set_synchronous_mode(true); | 628 host_resolver_.set_synchronous_mode(true); |
| 678 host_resolver_.rules()->AddIPLiteralRule( | 629 host_resolver_.rules()->AddIPLiteralRule( |
| 679 kDefaultServerHostName, "192.168.0.1", ""); | 630 kDefaultServerHostName, "192.168.0.1", ""); |
| 680 host_resolver_.rules()->AddIPLiteralRule( | 631 host_resolver_.rules()->AddIPLiteralRule( |
| 681 "mail.google.com", "192.168.0.1", ""); | 632 "mail.google.com", "192.168.0.1", ""); |
| 682 | 633 |
| 683 // Disable connection pooling. | 634 // Disable connection pooling. |
| 684 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 635 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 685 | 636 |
| 686 QuicStreamRequest request(&factory_); | 637 QuicStreamRequest request(&factory_); |
| 687 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 638 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 688 /*cert_verify_flags=*/0, host_port_pair_.host(), | 639 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 689 "GET", net_log_, callback_.callback())); | 640 "GET", net_log_, callback_.callback())); |
| 690 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 641 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 691 EXPECT_TRUE(stream.get()); | 642 EXPECT_TRUE(stream.get()); |
| 692 | 643 |
| 693 TestCompletionCallback callback; | 644 TestCompletionCallback callback; |
| 694 QuicStreamRequest request2(&factory_); | 645 QuicStreamRequest request2(&factory_); |
| 695 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 646 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 696 /*cert_verify_flags=*/0, server2.host(), "GET", | 647 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 697 net_log_, callback.callback())); | 648 net_log_, callback.callback())); |
| 698 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 649 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 699 EXPECT_TRUE(stream2.get()); | 650 EXPECT_TRUE(stream2.get()); |
| 700 | 651 |
| 701 EXPECT_NE( | 652 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_), |
| 702 QuicStreamFactoryPeer::GetActiveSession( | 653 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2)); |
| 703 &factory_, host_port_pair_, is_https_), | |
| 704 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); | |
| 705 | 654 |
| 706 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 655 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 707 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 656 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 708 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 657 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 709 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 658 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 710 } | 659 } |
| 711 | 660 |
| 712 TEST_P(QuicStreamFactoryTest, NoPoolingAfterGoAway) { | 661 TEST_P(QuicStreamFactoryTest, NoPoolingAfterGoAway) { |
| 713 MockRead reads[] = { | 662 MockRead reads[] = { |
| 714 MockRead(ASYNC, OK, 0) // EOF | 663 MockRead(ASYNC, OK, 0) // EOF |
| 715 }; | 664 }; |
| 716 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); | 665 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); |
| 717 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | 666 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 718 socket_factory_.AddSocketDataProvider(&socket_data1); | 667 socket_factory_.AddSocketDataProvider(&socket_data1); |
| 719 socket_factory_.AddSocketDataProvider(&socket_data2); | 668 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 720 socket_data1.StopAfter(1); | 669 socket_data1.StopAfter(1); |
| 721 socket_data2.StopAfter(1); | 670 socket_data2.StopAfter(1); |
| 722 | 671 |
| 723 HostPortPair server2("mail.google.com", kDefaultServerPort); | 672 HostPortPair server2("mail.google.com", kDefaultServerPort); |
| 724 host_resolver_.set_synchronous_mode(true); | 673 host_resolver_.set_synchronous_mode(true); |
| 725 host_resolver_.rules()->AddIPLiteralRule( | 674 host_resolver_.rules()->AddIPLiteralRule( |
| 726 kDefaultServerHostName, "192.168.0.1", ""); | 675 kDefaultServerHostName, "192.168.0.1", ""); |
| 727 host_resolver_.rules()->AddIPLiteralRule( | 676 host_resolver_.rules()->AddIPLiteralRule( |
| 728 "mail.google.com", "192.168.0.1", ""); | 677 "mail.google.com", "192.168.0.1", ""); |
| 729 | 678 |
| 730 QuicStreamRequest request(&factory_); | 679 QuicStreamRequest request(&factory_); |
| 731 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 680 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 732 /*cert_verify_flags=*/0, host_port_pair_.host(), | 681 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 733 "GET", net_log_, callback_.callback())); | 682 "GET", net_log_, callback_.callback())); |
| 734 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 683 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 735 EXPECT_TRUE(stream.get()); | 684 EXPECT_TRUE(stream.get()); |
| 736 | 685 |
| 737 TestCompletionCallback callback; | 686 TestCompletionCallback callback; |
| 738 QuicStreamRequest request2(&factory_); | 687 QuicStreamRequest request2(&factory_); |
| 739 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 688 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 740 /*cert_verify_flags=*/0, server2.host(), "GET", | 689 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 741 net_log_, callback.callback())); | 690 net_log_, callback.callback())); |
| 742 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 691 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 743 EXPECT_TRUE(stream2.get()); | 692 EXPECT_TRUE(stream2.get()); |
| 744 | 693 |
| 745 factory_.OnSessionGoingAway(QuicStreamFactoryPeer::GetActiveSession( | 694 factory_.OnSessionGoingAway( |
| 746 &factory_, host_port_pair_, is_https_)); | 695 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_)); |
| 747 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 696 EXPECT_FALSE( |
| 748 &factory_, host_port_pair_, is_https_)); | 697 QuicStreamFactoryPeer::HasActiveSession(&factory_, host_port_pair_)); |
| 749 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 698 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession(&factory_, server2)); |
| 750 &factory_, server2, is_https_)); | |
| 751 | 699 |
| 752 TestCompletionCallback callback3; | 700 TestCompletionCallback callback3; |
| 753 QuicStreamRequest request3(&factory_); | 701 QuicStreamRequest request3(&factory_); |
| 754 EXPECT_EQ(OK, request3.Request(server2, is_https_, privacy_mode_, | 702 EXPECT_EQ(OK, request3.Request(server2, privacy_mode_, |
| 755 /*cert_verify_flags=*/0, server2.host(), "GET", | 703 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 756 net_log_, callback3.callback())); | 704 net_log_, callback3.callback())); |
| 757 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 705 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
| 758 EXPECT_TRUE(stream3.get()); | 706 EXPECT_TRUE(stream3.get()); |
| 759 | 707 |
| 760 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( | 708 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(&factory_, server2)); |
| 761 &factory_, server2, is_https_)); | |
| 762 | 709 |
| 763 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 710 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 764 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 711 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 765 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 712 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 766 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 713 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 767 } | 714 } |
| 768 | 715 |
| 769 TEST_P(QuicStreamFactoryTest, HttpsPooling) { | 716 TEST_P(QuicStreamFactoryTest, HttpsPooling) { |
| 770 MockRead reads[] = { | 717 MockRead reads[] = { |
| 771 MockRead(ASYNC, OK, 0) // EOF | 718 MockRead(ASYNC, OK, 0) // EOF |
| 772 }; | 719 }; |
| 773 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 720 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 774 socket_factory_.AddSocketDataProvider(&socket_data); | 721 socket_factory_.AddSocketDataProvider(&socket_data); |
| 775 socket_data.StopAfter(1); | 722 socket_data.StopAfter(1); |
| 776 | 723 |
| 777 HostPortPair server1("www.example.org", 443); | 724 HostPortPair server1("www.example.org", 443); |
| 778 HostPortPair server2("mail.example.org", 443); | 725 HostPortPair server2("mail.example.org", 443); |
| 779 | 726 |
| 780 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 727 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 781 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 728 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 782 | 729 |
| 783 host_resolver_.set_synchronous_mode(true); | 730 host_resolver_.set_synchronous_mode(true); |
| 784 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 731 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 785 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 732 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 786 | 733 |
| 787 QuicStreamRequest request(&factory_); | 734 QuicStreamRequest request(&factory_); |
| 788 is_https_ = true; | 735 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 789 EXPECT_EQ(OK, request.Request(server1, is_https_, privacy_mode_, | |
| 790 /*cert_verify_flags=*/0, server1.host(), "GET", | 736 /*cert_verify_flags=*/0, server1.host(), "GET", |
| 791 net_log_, callback_.callback())); | 737 net_log_, callback_.callback())); |
| 792 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 738 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 793 EXPECT_TRUE(stream.get()); | 739 EXPECT_TRUE(stream.get()); |
| 794 | 740 |
| 795 TestCompletionCallback callback; | 741 TestCompletionCallback callback; |
| 796 QuicStreamRequest request2(&factory_); | 742 QuicStreamRequest request2(&factory_); |
| 797 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 743 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 798 /*cert_verify_flags=*/0, server2.host(), "GET", | 744 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 799 net_log_, callback_.callback())); | 745 net_log_, callback_.callback())); |
| 800 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 746 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 801 EXPECT_TRUE(stream2.get()); | 747 EXPECT_TRUE(stream2.get()); |
| 802 | 748 |
| 803 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( | 749 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession(&factory_, server1), |
| 804 &factory_, server1, is_https_), | 750 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2)); |
| 805 QuicStreamFactoryPeer::GetActiveSession( | |
| 806 &factory_, server2, is_https_)); | |
| 807 | 751 |
| 808 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 752 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 809 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 753 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 810 } | 754 } |
| 811 | 755 |
| 812 TEST_P(QuicStreamFactoryTest, NoHttpsPoolingIfDisabled) { | 756 TEST_P(QuicStreamFactoryTest, NoHttpsPoolingIfDisabled) { |
| 813 MockRead reads[] = { | 757 MockRead reads[] = { |
| 814 MockRead(ASYNC, OK, 0) // EOF | 758 MockRead(ASYNC, OK, 0) // EOF |
| 815 }; | 759 }; |
| 816 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); | 760 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 827 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 771 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 828 | 772 |
| 829 host_resolver_.set_synchronous_mode(true); | 773 host_resolver_.set_synchronous_mode(true); |
| 830 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 774 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 831 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 775 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 832 | 776 |
| 833 // Disable connection pooling. | 777 // Disable connection pooling. |
| 834 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 778 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 835 | 779 |
| 836 QuicStreamRequest request(&factory_); | 780 QuicStreamRequest request(&factory_); |
| 837 is_https_ = true; | 781 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 838 EXPECT_EQ(OK, request.Request(server1, is_https_, privacy_mode_, | |
| 839 /*cert_verify_flags=*/0, server1.host(), "GET", | 782 /*cert_verify_flags=*/0, server1.host(), "GET", |
| 840 net_log_, callback_.callback())); | 783 net_log_, callback_.callback())); |
| 841 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 784 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 842 EXPECT_TRUE(stream.get()); | 785 EXPECT_TRUE(stream.get()); |
| 843 | 786 |
| 844 TestCompletionCallback callback; | 787 TestCompletionCallback callback; |
| 845 QuicStreamRequest request2(&factory_); | 788 QuicStreamRequest request2(&factory_); |
| 846 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 789 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 847 /*cert_verify_flags=*/0, server2.host(), "GET", | 790 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 848 net_log_, callback_.callback())); | 791 net_log_, callback_.callback())); |
| 849 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 792 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 850 EXPECT_TRUE(stream2.get()); | 793 EXPECT_TRUE(stream2.get()); |
| 851 | 794 |
| 852 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 795 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(&factory_, server1), |
| 853 &factory_, server1, is_https_), | 796 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2)); |
| 854 QuicStreamFactoryPeer::GetActiveSession( | |
| 855 &factory_, server2, is_https_)); | |
| 856 | 797 |
| 857 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 798 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 858 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 799 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 859 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 800 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 860 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 801 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 861 } | 802 } |
| 862 | 803 |
| 863 class QuicAlternativeServiceCertificateValidationPooling | 804 class QuicAlternativeServiceCertificateValidationPooling |
| 864 : public QuicStreamFactoryTest { | 805 : public QuicStreamFactoryTest { |
| 865 public: | 806 public: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 886 verify_details.cert_verify_result.verified_cert->VerifyNameMatch( | 827 verify_details.cert_verify_result.verified_cert->VerifyNameMatch( |
| 887 alternative.host(), &common_name_fallback_used)); | 828 alternative.host(), &common_name_fallback_used)); |
| 888 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 829 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 889 | 830 |
| 890 host_resolver_.set_synchronous_mode(true); | 831 host_resolver_.set_synchronous_mode(true); |
| 891 host_resolver_.rules()->AddIPLiteralRule(alternative.host(), "192.168.0.1", | 832 host_resolver_.rules()->AddIPLiteralRule(alternative.host(), "192.168.0.1", |
| 892 ""); | 833 ""); |
| 893 | 834 |
| 894 // Open first stream to alternative. | 835 // Open first stream to alternative. |
| 895 QuicStreamRequest request1(&factory_); | 836 QuicStreamRequest request1(&factory_); |
| 896 is_https_ = true; | 837 EXPECT_EQ(OK, request1.Request(alternative, privacy_mode_, |
| 897 EXPECT_EQ(OK, request1.Request(alternative, is_https_, privacy_mode_, | |
| 898 /*cert_verify_flags=*/0, alternative.host(), | 838 /*cert_verify_flags=*/0, alternative.host(), |
| 899 "GET", net_log_, callback_.callback())); | 839 "GET", net_log_, callback_.callback())); |
| 900 scoped_ptr<QuicHttpStream> stream1 = request1.ReleaseStream(); | 840 scoped_ptr<QuicHttpStream> stream1 = request1.ReleaseStream(); |
| 901 EXPECT_TRUE(stream1.get()); | 841 EXPECT_TRUE(stream1.get()); |
| 902 | 842 |
| 903 QuicStreamRequest request2(&factory_); | 843 QuicStreamRequest request2(&factory_); |
| 904 int rv = request2.Request(alternative, is_https_, privacy_mode_, | 844 int rv = request2.Request(alternative, privacy_mode_, |
| 905 /*cert_verify_flags=*/0, origin_host, "GET", | 845 /*cert_verify_flags=*/0, origin_host, "GET", |
| 906 net_log_, callback_.callback()); | 846 net_log_, callback_.callback()); |
| 907 if (valid) { | 847 if (valid) { |
| 908 // Alternative service of origin to |alternative| should pool to session | 848 // Alternative service of origin to |alternative| should pool to session |
| 909 // of |stream1| even if origin is different. Since only one | 849 // of |stream1| even if origin is different. Since only one |
| 910 // SocketDataProvider is set up, the second request succeeding means that | 850 // SocketDataProvider is set up, the second request succeeding means that |
| 911 // it pooled to the session opened by the first one. | 851 // it pooled to the session opened by the first one. |
| 912 EXPECT_EQ(OK, rv); | 852 EXPECT_EQ(OK, rv); |
| 913 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 853 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 914 EXPECT_TRUE(stream2.get()); | 854 EXPECT_TRUE(stream2.get()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 891 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 952 verify_details.cert_verify_result.public_key_hashes.push_back( | 892 verify_details.cert_verify_result.public_key_hashes.push_back( |
| 953 test::GetTestHashValue(primary_pin)); | 893 test::GetTestHashValue(primary_pin)); |
| 954 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 894 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 955 | 895 |
| 956 host_resolver_.set_synchronous_mode(true); | 896 host_resolver_.set_synchronous_mode(true); |
| 957 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 897 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 958 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 898 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 959 | 899 |
| 960 QuicStreamRequest request(&factory_); | 900 QuicStreamRequest request(&factory_); |
| 961 is_https_ = true; | 901 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 962 EXPECT_EQ(OK, request.Request(server1, is_https_, privacy_mode_, | |
| 963 /*cert_verify_flags=*/0, server1.host(), "GET", | 902 /*cert_verify_flags=*/0, server1.host(), "GET", |
| 964 net_log_, callback_.callback())); | 903 net_log_, callback_.callback())); |
| 965 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 904 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 966 EXPECT_TRUE(stream.get()); | 905 EXPECT_TRUE(stream.get()); |
| 967 | 906 |
| 968 TestCompletionCallback callback; | 907 TestCompletionCallback callback; |
| 969 QuicStreamRequest request2(&factory_); | 908 QuicStreamRequest request2(&factory_); |
| 970 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 909 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 971 /*cert_verify_flags=*/0, server2.host(), "GET", | 910 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 972 net_log_, callback_.callback())); | 911 net_log_, callback_.callback())); |
| 973 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 912 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 974 EXPECT_TRUE(stream2.get()); | 913 EXPECT_TRUE(stream2.get()); |
| 975 | 914 |
| 976 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( | 915 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession(&factory_, server1), |
| 977 &factory_, server1, is_https_), | 916 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2)); |
| 978 QuicStreamFactoryPeer::GetActiveSession( | |
| 979 &factory_, server2, is_https_)); | |
| 980 | 917 |
| 981 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 918 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 982 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 919 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 983 } | 920 } |
| 984 | 921 |
| 985 TEST_P(QuicStreamFactoryTest, NoHttpsPoolingWithMatchingPinsIfDisabled) { | 922 TEST_P(QuicStreamFactoryTest, NoHttpsPoolingWithMatchingPinsIfDisabled) { |
| 986 MockRead reads[] = { | 923 MockRead reads[] = { |
| 987 MockRead(ASYNC, OK, 0) // EOF | 924 MockRead(ASYNC, OK, 0) // EOF |
| 988 }; | 925 }; |
| 989 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); | 926 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1006 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 943 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1007 | 944 |
| 1008 host_resolver_.set_synchronous_mode(true); | 945 host_resolver_.set_synchronous_mode(true); |
| 1009 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 946 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 1010 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 947 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1011 | 948 |
| 1012 // Disable connection pooling. | 949 // Disable connection pooling. |
| 1013 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 950 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 1014 | 951 |
| 1015 QuicStreamRequest request(&factory_); | 952 QuicStreamRequest request(&factory_); |
| 1016 is_https_ = true; | 953 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 1017 EXPECT_EQ(OK, request.Request(server1, is_https_, privacy_mode_, | |
| 1018 /*cert_verify_flags=*/0, server1.host(), "GET", | 954 /*cert_verify_flags=*/0, server1.host(), "GET", |
| 1019 net_log_, callback_.callback())); | 955 net_log_, callback_.callback())); |
| 1020 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 956 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1021 EXPECT_TRUE(stream.get()); | 957 EXPECT_TRUE(stream.get()); |
| 1022 | 958 |
| 1023 TestCompletionCallback callback; | 959 TestCompletionCallback callback; |
| 1024 QuicStreamRequest request2(&factory_); | 960 QuicStreamRequest request2(&factory_); |
| 1025 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 961 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 1026 /*cert_verify_flags=*/0, server2.host(), "GET", | 962 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 1027 net_log_, callback_.callback())); | 963 net_log_, callback_.callback())); |
| 1028 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 964 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1029 EXPECT_TRUE(stream2.get()); | 965 EXPECT_TRUE(stream2.get()); |
| 1030 | 966 |
| 1031 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 967 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(&factory_, server1), |
| 1032 &factory_, server1, is_https_), | 968 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2)); |
| 1033 QuicStreamFactoryPeer::GetActiveSession( | |
| 1034 &factory_, server2, is_https_)); | |
| 1035 | 969 |
| 1036 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 970 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 1037 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 971 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 1038 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 972 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1039 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 973 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1040 } | 974 } |
| 1041 | 975 |
| 1042 TEST_P(QuicStreamFactoryTest, NoHttpsPoolingWithDifferentPins) { | 976 TEST_P(QuicStreamFactoryTest, NoHttpsPoolingWithDifferentPins) { |
| 1043 MockRead reads[] = { | 977 MockRead reads[] = { |
| 1044 MockRead(ASYNC, OK, 0) // EOF | 978 MockRead(ASYNC, OK, 0) // EOF |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1066 ProofVerifyDetailsChromium verify_details2 = DefaultProofVerifyDetails(); | 1000 ProofVerifyDetailsChromium verify_details2 = DefaultProofVerifyDetails(); |
| 1067 verify_details2.cert_verify_result.public_key_hashes.push_back( | 1001 verify_details2.cert_verify_result.public_key_hashes.push_back( |
| 1068 test::GetTestHashValue(primary_pin)); | 1002 test::GetTestHashValue(primary_pin)); |
| 1069 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); | 1003 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); |
| 1070 | 1004 |
| 1071 host_resolver_.set_synchronous_mode(true); | 1005 host_resolver_.set_synchronous_mode(true); |
| 1072 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 1006 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 1073 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 1007 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1074 | 1008 |
| 1075 QuicStreamRequest request(&factory_); | 1009 QuicStreamRequest request(&factory_); |
| 1076 is_https_ = true; | 1010 EXPECT_EQ(OK, request.Request(server1, privacy_mode_, |
| 1077 EXPECT_EQ(OK, request.Request(server1, is_https_, privacy_mode_, | |
| 1078 /*cert_verify_flags=*/0, server1.host(), "GET", | 1011 /*cert_verify_flags=*/0, server1.host(), "GET", |
| 1079 net_log_, callback_.callback())); | 1012 net_log_, callback_.callback())); |
| 1080 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1013 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1081 EXPECT_TRUE(stream.get()); | 1014 EXPECT_TRUE(stream.get()); |
| 1082 | 1015 |
| 1083 TestCompletionCallback callback; | 1016 TestCompletionCallback callback; |
| 1084 QuicStreamRequest request2(&factory_); | 1017 QuicStreamRequest request2(&factory_); |
| 1085 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 1018 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 1086 /*cert_verify_flags=*/0, server2.host(), "GET", | 1019 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 1087 net_log_, callback_.callback())); | 1020 net_log_, callback_.callback())); |
| 1088 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1021 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1089 EXPECT_TRUE(stream2.get()); | 1022 EXPECT_TRUE(stream2.get()); |
| 1090 | 1023 |
| 1091 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 1024 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession(&factory_, server1), |
| 1092 &factory_, server1, is_https_), | 1025 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2)); |
| 1093 QuicStreamFactoryPeer::GetActiveSession( | |
| 1094 &factory_, server2, is_https_)); | |
| 1095 | 1026 |
| 1096 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 1027 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 1097 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 1028 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 1098 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1029 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1099 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1030 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1100 } | 1031 } |
| 1101 | 1032 |
| 1102 TEST_P(QuicStreamFactoryTest, Goaway) { | 1033 TEST_P(QuicStreamFactoryTest, Goaway) { |
| 1103 MockRead reads[] = { | 1034 MockRead reads[] = { |
| 1104 MockRead(ASYNC, OK, 0) // EOF | 1035 MockRead(ASYNC, OK, 0) // EOF |
| 1105 }; | 1036 }; |
| 1106 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 1037 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 1107 socket_data.StopAfter(1); | 1038 socket_data.StopAfter(1); |
| 1108 socket_factory_.AddSocketDataProvider(&socket_data); | 1039 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1109 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | 1040 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 1110 socket_data2.StopAfter(1); | 1041 socket_data2.StopAfter(1); |
| 1111 socket_factory_.AddSocketDataProvider(&socket_data2); | 1042 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1112 | 1043 |
| 1113 QuicStreamRequest request(&factory_); | 1044 QuicStreamRequest request(&factory_); |
| 1114 EXPECT_EQ(ERR_IO_PENDING, | 1045 EXPECT_EQ(ERR_IO_PENDING, |
| 1115 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1046 request.Request(host_port_pair_, privacy_mode_, |
| 1116 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1047 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1117 "GET", net_log_, callback_.callback())); | 1048 "GET", net_log_, callback_.callback())); |
| 1118 | 1049 |
| 1119 EXPECT_EQ(OK, callback_.WaitForResult()); | 1050 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1120 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1051 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1121 EXPECT_TRUE(stream.get()); | 1052 EXPECT_TRUE(stream.get()); |
| 1122 | 1053 |
| 1123 // Mark the session as going away. Ensure that while it is still alive | 1054 // Mark the session as going away. Ensure that while it is still alive |
| 1124 // that it is no longer active. | 1055 // that it is no longer active. |
| 1125 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1056 QuicChromiumClientSession* session = |
| 1126 &factory_, host_port_pair_, is_https_); | 1057 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 1127 factory_.OnSessionGoingAway(session); | 1058 factory_.OnSessionGoingAway(session); |
| 1128 EXPECT_EQ(true, QuicStreamFactoryPeer::IsLiveSession(&factory_, session)); | 1059 EXPECT_EQ(true, QuicStreamFactoryPeer::IsLiveSession(&factory_, session)); |
| 1129 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 1060 EXPECT_FALSE( |
| 1130 &factory_, host_port_pair_, is_https_)); | 1061 QuicStreamFactoryPeer::HasActiveSession(&factory_, host_port_pair_)); |
| 1131 EXPECT_FALSE(HasActiveSession(host_port_pair_)); | 1062 EXPECT_FALSE(HasActiveSession(host_port_pair_)); |
| 1132 | 1063 |
| 1133 // Create a new request for the same destination and verify that a | 1064 // Create a new request for the same destination and verify that a |
| 1134 // new session is created. | 1065 // new session is created. |
| 1135 QuicStreamRequest request2(&factory_); | 1066 QuicStreamRequest request2(&factory_); |
| 1136 EXPECT_EQ(ERR_IO_PENDING, | 1067 EXPECT_EQ(ERR_IO_PENDING, |
| 1137 request2.Request(host_port_pair_, is_https_, privacy_mode_, | 1068 request2.Request(host_port_pair_, privacy_mode_, |
| 1138 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1069 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1139 "GET", net_log_, callback_.callback())); | 1070 "GET", net_log_, callback_.callback())); |
| 1140 EXPECT_EQ(OK, callback_.WaitForResult()); | 1071 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1141 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1072 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1142 EXPECT_TRUE(stream2.get()); | 1073 EXPECT_TRUE(stream2.get()); |
| 1143 | 1074 |
| 1144 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(&factory_, | 1075 EXPECT_TRUE( |
| 1145 host_port_pair_, | 1076 QuicStreamFactoryPeer::HasActiveSession(&factory_, host_port_pair_)); |
| 1146 is_https_)); | 1077 EXPECT_NE(session, QuicStreamFactoryPeer::GetActiveSession(&factory_, |
| 1147 EXPECT_NE(session, | 1078 host_port_pair_)); |
| 1148 QuicStreamFactoryPeer::GetActiveSession( | |
| 1149 &factory_, host_port_pair_, is_https_)); | |
| 1150 EXPECT_EQ(true, QuicStreamFactoryPeer::IsLiveSession(&factory_, session)); | 1079 EXPECT_EQ(true, QuicStreamFactoryPeer::IsLiveSession(&factory_, session)); |
| 1151 | 1080 |
| 1152 stream2.reset(); | 1081 stream2.reset(); |
| 1153 stream.reset(); | 1082 stream.reset(); |
| 1154 | 1083 |
| 1155 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1084 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1156 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1085 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1157 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1086 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1158 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1087 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1159 } | 1088 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1172 writes, arraysize(writes)); | 1101 writes, arraysize(writes)); |
| 1173 socket_factory_.AddSocketDataProvider(&socket_data); | 1102 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1174 socket_data.StopAfter(1); | 1103 socket_data.StopAfter(1); |
| 1175 | 1104 |
| 1176 HttpRequestInfo request_info; | 1105 HttpRequestInfo request_info; |
| 1177 std::vector<QuicHttpStream*> streams; | 1106 std::vector<QuicHttpStream*> streams; |
| 1178 // The MockCryptoClientStream sets max_open_streams to be | 1107 // The MockCryptoClientStream sets max_open_streams to be |
| 1179 // kDefaultMaxStreamsPerConnection / 2. | 1108 // kDefaultMaxStreamsPerConnection / 2. |
| 1180 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection / 2; i++) { | 1109 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection / 2; i++) { |
| 1181 QuicStreamRequest request(&factory_); | 1110 QuicStreamRequest request(&factory_); |
| 1182 int rv = request.Request(host_port_pair_, is_https_, privacy_mode_, | 1111 int rv = request.Request(host_port_pair_, privacy_mode_, |
| 1183 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1112 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1184 "GET", net_log_, callback_.callback()); | 1113 "GET", net_log_, callback_.callback()); |
| 1185 if (i == 0) { | 1114 if (i == 0) { |
| 1186 EXPECT_EQ(ERR_IO_PENDING, rv); | 1115 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1187 EXPECT_EQ(OK, callback_.WaitForResult()); | 1116 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1188 } else { | 1117 } else { |
| 1189 EXPECT_EQ(OK, rv); | 1118 EXPECT_EQ(OK, rv); |
| 1190 } | 1119 } |
| 1191 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1120 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1192 EXPECT_TRUE(stream); | 1121 EXPECT_TRUE(stream); |
| 1193 EXPECT_EQ(OK, stream->InitializeStream( | 1122 EXPECT_EQ(OK, stream->InitializeStream( |
| 1194 &request_info, DEFAULT_PRIORITY, net_log_, CompletionCallback())); | 1123 &request_info, DEFAULT_PRIORITY, net_log_, CompletionCallback())); |
| 1195 streams.push_back(stream.release()); | 1124 streams.push_back(stream.release()); |
| 1196 } | 1125 } |
| 1197 | 1126 |
| 1198 QuicStreamRequest request(&factory_); | 1127 QuicStreamRequest request(&factory_); |
| 1199 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1128 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 1200 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1129 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1201 "GET", net_log_, CompletionCallback())); | 1130 "GET", net_log_, CompletionCallback())); |
| 1202 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1131 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1203 EXPECT_TRUE(stream); | 1132 EXPECT_TRUE(stream); |
| 1204 EXPECT_EQ(ERR_IO_PENDING, stream->InitializeStream( | 1133 EXPECT_EQ(ERR_IO_PENDING, stream->InitializeStream( |
| 1205 &request_info, DEFAULT_PRIORITY, net_log_, callback_.callback())); | 1134 &request_info, DEFAULT_PRIORITY, net_log_, callback_.callback())); |
| 1206 | 1135 |
| 1207 // Close the first stream. | 1136 // Close the first stream. |
| 1208 streams.front()->Close(false); | 1137 streams.front()->Close(false); |
| 1209 | 1138 |
| 1210 ASSERT_TRUE(callback_.have_result()); | 1139 ASSERT_TRUE(callback_.have_result()); |
| 1211 | 1140 |
| 1212 EXPECT_EQ(OK, callback_.WaitForResult()); | 1141 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1213 | 1142 |
| 1214 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1143 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1215 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1144 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1216 STLDeleteElements(&streams); | 1145 STLDeleteElements(&streams); |
| 1217 } | 1146 } |
| 1218 | 1147 |
| 1219 TEST_P(QuicStreamFactoryTest, ResolutionErrorInCreate) { | 1148 TEST_P(QuicStreamFactoryTest, ResolutionErrorInCreate) { |
| 1220 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); | 1149 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); |
| 1221 socket_factory_.AddSocketDataProvider(&socket_data); | 1150 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1222 | 1151 |
| 1223 host_resolver_.rules()->AddSimulatedFailure(kDefaultServerHostName); | 1152 host_resolver_.rules()->AddSimulatedFailure(kDefaultServerHostName); |
| 1224 | 1153 |
| 1225 QuicStreamRequest request(&factory_); | 1154 QuicStreamRequest request(&factory_); |
| 1226 EXPECT_EQ(ERR_IO_PENDING, | 1155 EXPECT_EQ(ERR_IO_PENDING, |
| 1227 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1156 request.Request(host_port_pair_, privacy_mode_, |
| 1228 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1157 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1229 "GET", net_log_, callback_.callback())); | 1158 "GET", net_log_, callback_.callback())); |
| 1230 | 1159 |
| 1231 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); | 1160 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); |
| 1232 | 1161 |
| 1233 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1162 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1234 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1163 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1235 } | 1164 } |
| 1236 | 1165 |
| 1237 TEST_P(QuicStreamFactoryTest, ConnectErrorInCreate) { | 1166 TEST_P(QuicStreamFactoryTest, ConnectErrorInCreate) { |
| 1238 MockConnect connect(SYNCHRONOUS, ERR_ADDRESS_IN_USE); | 1167 MockConnect connect(SYNCHRONOUS, ERR_ADDRESS_IN_USE); |
| 1239 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); | 1168 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); |
| 1240 socket_data.set_connect_data(connect); | 1169 socket_data.set_connect_data(connect); |
| 1241 socket_factory_.AddSocketDataProvider(&socket_data); | 1170 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1242 socket_data.StopAfter(1); | 1171 socket_data.StopAfter(1); |
| 1243 | 1172 |
| 1244 QuicStreamRequest request(&factory_); | 1173 QuicStreamRequest request(&factory_); |
| 1245 EXPECT_EQ(ERR_IO_PENDING, | 1174 EXPECT_EQ(ERR_IO_PENDING, |
| 1246 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1175 request.Request(host_port_pair_, privacy_mode_, |
| 1247 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1176 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1248 "GET", net_log_, callback_.callback())); | 1177 "GET", net_log_, callback_.callback())); |
| 1249 | 1178 |
| 1250 EXPECT_EQ(ERR_ADDRESS_IN_USE, callback_.WaitForResult()); | 1179 EXPECT_EQ(ERR_ADDRESS_IN_USE, callback_.WaitForResult()); |
| 1251 | 1180 |
| 1252 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1181 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1253 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1182 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1254 } | 1183 } |
| 1255 | 1184 |
| 1256 TEST_P(QuicStreamFactoryTest, CancelCreate) { | 1185 TEST_P(QuicStreamFactoryTest, CancelCreate) { |
| 1257 MockRead reads[] = { | 1186 MockRead reads[] = { |
| 1258 MockRead(ASYNC, OK, 0) // EOF | 1187 MockRead(ASYNC, OK, 0) // EOF |
| 1259 }; | 1188 }; |
| 1260 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 1189 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 1261 socket_factory_.AddSocketDataProvider(&socket_data); | 1190 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1262 { | 1191 { |
| 1263 QuicStreamRequest request(&factory_); | 1192 QuicStreamRequest request(&factory_); |
| 1264 EXPECT_EQ(ERR_IO_PENDING, | 1193 EXPECT_EQ(ERR_IO_PENDING, |
| 1265 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1194 request.Request(host_port_pair_, privacy_mode_, |
| 1266 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1195 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1267 "GET", net_log_, callback_.callback())); | 1196 "GET", net_log_, callback_.callback())); |
| 1268 } | 1197 } |
| 1269 | 1198 |
| 1270 socket_data.StopAfter(1); | 1199 socket_data.StopAfter(1); |
| 1271 base::RunLoop run_loop; | 1200 base::RunLoop run_loop; |
| 1272 run_loop.RunUntilIdle(); | 1201 run_loop.RunUntilIdle(); |
| 1273 | 1202 |
| 1274 scoped_ptr<QuicHttpStream> stream(CreateFromSession(host_port_pair_)); | 1203 scoped_ptr<QuicHttpStream> stream(CreateFromSession(host_port_pair_)); |
| 1275 EXPECT_TRUE(stream.get()); | 1204 EXPECT_TRUE(stream.get()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1247 |
| 1319 MockRead reads2[] = { | 1248 MockRead reads2[] = { |
| 1320 MockRead(ASYNC, 0, 0) // EOF | 1249 MockRead(ASYNC, 0, 0) // EOF |
| 1321 }; | 1250 }; |
| 1322 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1251 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1323 socket_factory_.AddSocketDataProvider(&socket_data2); | 1252 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1324 socket_data2.StopAfter(1); | 1253 socket_data2.StopAfter(1); |
| 1325 | 1254 |
| 1326 QuicStreamRequest request(&factory_); | 1255 QuicStreamRequest request(&factory_); |
| 1327 EXPECT_EQ(ERR_IO_PENDING, | 1256 EXPECT_EQ(ERR_IO_PENDING, |
| 1328 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1257 request.Request(host_port_pair_, privacy_mode_, |
| 1329 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1258 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1330 "GET", net_log_, callback_.callback())); | 1259 "GET", net_log_, callback_.callback())); |
| 1331 | 1260 |
| 1332 EXPECT_EQ(OK, callback_.WaitForResult()); | 1261 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1333 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1262 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1334 HttpRequestInfo request_info; | 1263 HttpRequestInfo request_info; |
| 1335 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1264 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1336 DEFAULT_PRIORITY, | 1265 DEFAULT_PRIORITY, |
| 1337 net_log_, CompletionCallback())); | 1266 net_log_, CompletionCallback())); |
| 1338 | 1267 |
| 1339 // Close the session and verify that stream saw the error. | 1268 // Close the session and verify that stream saw the error. |
| 1340 factory_.CloseAllSessions(ERR_INTERNET_DISCONNECTED); | 1269 factory_.CloseAllSessions(ERR_INTERNET_DISCONNECTED); |
| 1341 EXPECT_EQ(ERR_INTERNET_DISCONNECTED, | 1270 EXPECT_EQ(ERR_INTERNET_DISCONNECTED, |
| 1342 stream->ReadResponseHeaders(callback_.callback())); | 1271 stream->ReadResponseHeaders(callback_.callback())); |
| 1343 | 1272 |
| 1344 // Now attempting to request a stream to the same origin should create | 1273 // Now attempting to request a stream to the same origin should create |
| 1345 // a new session. | 1274 // a new session. |
| 1346 | 1275 |
| 1347 QuicStreamRequest request2(&factory_); | 1276 QuicStreamRequest request2(&factory_); |
| 1348 EXPECT_EQ(ERR_IO_PENDING, | 1277 EXPECT_EQ(ERR_IO_PENDING, |
| 1349 request2.Request(host_port_pair_, is_https_, privacy_mode_, | 1278 request2.Request(host_port_pair_, privacy_mode_, |
| 1350 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1279 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1351 "GET", net_log_, callback_.callback())); | 1280 "GET", net_log_, callback_.callback())); |
| 1352 | 1281 |
| 1353 EXPECT_EQ(OK, callback_.WaitForResult()); | 1282 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1354 stream = request2.ReleaseStream(); | 1283 stream = request2.ReleaseStream(); |
| 1355 stream.reset(); // Will reset stream 3. | 1284 stream.reset(); // Will reset stream 3. |
| 1356 | 1285 |
| 1357 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1286 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1358 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1287 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1359 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1288 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1375 | 1304 |
| 1376 MockRead reads2[] = { | 1305 MockRead reads2[] = { |
| 1377 MockRead(ASYNC, 0, 0) // EOF | 1306 MockRead(ASYNC, 0, 0) // EOF |
| 1378 }; | 1307 }; |
| 1379 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1308 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1380 socket_factory_.AddSocketDataProvider(&socket_data2); | 1309 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1381 socket_data2.StopAfter(1); | 1310 socket_data2.StopAfter(1); |
| 1382 | 1311 |
| 1383 QuicStreamRequest request(&factory_); | 1312 QuicStreamRequest request(&factory_); |
| 1384 EXPECT_EQ(ERR_IO_PENDING, | 1313 EXPECT_EQ(ERR_IO_PENDING, |
| 1385 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1314 request.Request(host_port_pair_, privacy_mode_, |
| 1386 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1315 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1387 "GET", net_log_, callback_.callback())); | 1316 "GET", net_log_, callback_.callback())); |
| 1388 | 1317 |
| 1389 EXPECT_EQ(OK, callback_.WaitForResult()); | 1318 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1390 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1319 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1391 HttpRequestInfo request_info; | 1320 HttpRequestInfo request_info; |
| 1392 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1321 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1393 DEFAULT_PRIORITY, | 1322 DEFAULT_PRIORITY, |
| 1394 net_log_, CompletionCallback())); | 1323 net_log_, CompletionCallback())); |
| 1395 | 1324 |
| 1396 // Change the IP address and verify that stream saw the error. | 1325 // Change the IP address and verify that stream saw the error. |
| 1397 factory_.OnIPAddressChanged(); | 1326 factory_.OnIPAddressChanged(); |
| 1398 EXPECT_EQ(ERR_NETWORK_CHANGED, | 1327 EXPECT_EQ(ERR_NETWORK_CHANGED, |
| 1399 stream->ReadResponseHeaders(callback_.callback())); | 1328 stream->ReadResponseHeaders(callback_.callback())); |
| 1400 EXPECT_TRUE(factory_.require_confirmation()); | 1329 EXPECT_TRUE(factory_.require_confirmation()); |
| 1401 | 1330 |
| 1402 // Now attempting to request a stream to the same origin should create | 1331 // Now attempting to request a stream to the same origin should create |
| 1403 // a new session. | 1332 // a new session. |
| 1404 | 1333 |
| 1405 QuicStreamRequest request2(&factory_); | 1334 QuicStreamRequest request2(&factory_); |
| 1406 EXPECT_EQ(ERR_IO_PENDING, | 1335 EXPECT_EQ(ERR_IO_PENDING, |
| 1407 request2.Request(host_port_pair_, is_https_, privacy_mode_, | 1336 request2.Request(host_port_pair_, privacy_mode_, |
| 1408 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1337 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1409 "GET", net_log_, callback_.callback())); | 1338 "GET", net_log_, callback_.callback())); |
| 1410 | 1339 |
| 1411 EXPECT_EQ(OK, callback_.WaitForResult()); | 1340 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1412 stream = request2.ReleaseStream(); | 1341 stream = request2.ReleaseStream(); |
| 1413 stream.reset(); // Will reset stream 3. | 1342 stream.reset(); // Will reset stream 3. |
| 1414 | 1343 |
| 1415 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1344 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1416 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1345 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1417 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1346 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1433 | 1362 |
| 1434 MockRead reads2[] = { | 1363 MockRead reads2[] = { |
| 1435 MockRead(ASYNC, 0, 0) // EOF | 1364 MockRead(ASYNC, 0, 0) // EOF |
| 1436 }; | 1365 }; |
| 1437 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1366 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1438 socket_factory_.AddSocketDataProvider(&socket_data2); | 1367 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1439 socket_data2.StopAfter(1); | 1368 socket_data2.StopAfter(1); |
| 1440 | 1369 |
| 1441 QuicStreamRequest request(&factory_); | 1370 QuicStreamRequest request(&factory_); |
| 1442 EXPECT_EQ(ERR_IO_PENDING, | 1371 EXPECT_EQ(ERR_IO_PENDING, |
| 1443 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1372 request.Request(host_port_pair_, privacy_mode_, |
| 1444 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1373 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1445 "GET", net_log_, callback_.callback())); | 1374 "GET", net_log_, callback_.callback())); |
| 1446 | 1375 |
| 1447 EXPECT_EQ(OK, callback_.WaitForResult()); | 1376 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1448 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1377 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1449 HttpRequestInfo request_info; | 1378 HttpRequestInfo request_info; |
| 1450 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1379 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1451 net_log_, CompletionCallback())); | 1380 net_log_, CompletionCallback())); |
| 1452 | 1381 |
| 1453 factory_.OnSSLConfigChanged(); | 1382 factory_.OnSSLConfigChanged(); |
| 1454 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 1383 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 1455 stream->ReadResponseHeaders(callback_.callback())); | 1384 stream->ReadResponseHeaders(callback_.callback())); |
| 1456 EXPECT_FALSE(factory_.require_confirmation()); | 1385 EXPECT_FALSE(factory_.require_confirmation()); |
| 1457 | 1386 |
| 1458 // Now attempting to request a stream to the same origin should create | 1387 // Now attempting to request a stream to the same origin should create |
| 1459 // a new session. | 1388 // a new session. |
| 1460 | 1389 |
| 1461 QuicStreamRequest request2(&factory_); | 1390 QuicStreamRequest request2(&factory_); |
| 1462 EXPECT_EQ(ERR_IO_PENDING, | 1391 EXPECT_EQ(ERR_IO_PENDING, |
| 1463 request2.Request(host_port_pair_, is_https_, privacy_mode_, | 1392 request2.Request(host_port_pair_, privacy_mode_, |
| 1464 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1393 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1465 "GET", net_log_, callback_.callback())); | 1394 "GET", net_log_, callback_.callback())); |
| 1466 | 1395 |
| 1467 EXPECT_EQ(OK, callback_.WaitForResult()); | 1396 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1468 stream = request2.ReleaseStream(); | 1397 stream = request2.ReleaseStream(); |
| 1469 stream.reset(); // Will reset stream 3. | 1398 stream.reset(); // Will reset stream 3. |
| 1470 | 1399 |
| 1471 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1400 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1472 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1401 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1473 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1402 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1489 | 1418 |
| 1490 MockRead reads2[] = { | 1419 MockRead reads2[] = { |
| 1491 MockRead(ASYNC, 0, 0) // EOF | 1420 MockRead(ASYNC, 0, 0) // EOF |
| 1492 }; | 1421 }; |
| 1493 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1422 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1494 socket_factory_.AddSocketDataProvider(&socket_data2); | 1423 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1495 socket_data2.StopAfter(1); | 1424 socket_data2.StopAfter(1); |
| 1496 | 1425 |
| 1497 QuicStreamRequest request(&factory_); | 1426 QuicStreamRequest request(&factory_); |
| 1498 EXPECT_EQ(ERR_IO_PENDING, | 1427 EXPECT_EQ(ERR_IO_PENDING, |
| 1499 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1428 request.Request(host_port_pair_, privacy_mode_, |
| 1500 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1429 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1501 "GET", net_log_, callback_.callback())); | 1430 "GET", net_log_, callback_.callback())); |
| 1502 | 1431 |
| 1503 EXPECT_EQ(OK, callback_.WaitForResult()); | 1432 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1504 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1433 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1505 HttpRequestInfo request_info; | 1434 HttpRequestInfo request_info; |
| 1506 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1435 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1507 DEFAULT_PRIORITY, | 1436 DEFAULT_PRIORITY, |
| 1508 net_log_, CompletionCallback())); | 1437 net_log_, CompletionCallback())); |
| 1509 | 1438 |
| 1510 // Add a cert and verify that stream saw the event. | 1439 // Add a cert and verify that stream saw the event. |
| 1511 factory_.OnCertAdded(nullptr); | 1440 factory_.OnCertAdded(nullptr); |
| 1512 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 1441 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 1513 stream->ReadResponseHeaders(callback_.callback())); | 1442 stream->ReadResponseHeaders(callback_.callback())); |
| 1514 EXPECT_FALSE(factory_.require_confirmation()); | 1443 EXPECT_FALSE(factory_.require_confirmation()); |
| 1515 | 1444 |
| 1516 // Now attempting to request a stream to the same origin should create | 1445 // Now attempting to request a stream to the same origin should create |
| 1517 // a new session. | 1446 // a new session. |
| 1518 | 1447 |
| 1519 QuicStreamRequest request2(&factory_); | 1448 QuicStreamRequest request2(&factory_); |
| 1520 EXPECT_EQ(ERR_IO_PENDING, | 1449 EXPECT_EQ(ERR_IO_PENDING, |
| 1521 request2.Request(host_port_pair_, is_https_, privacy_mode_, | 1450 request2.Request(host_port_pair_, privacy_mode_, |
| 1522 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1451 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1523 "GET", net_log_, callback_.callback())); | 1452 "GET", net_log_, callback_.callback())); |
| 1524 | 1453 |
| 1525 EXPECT_EQ(OK, callback_.WaitForResult()); | 1454 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1526 stream = request2.ReleaseStream(); | 1455 stream = request2.ReleaseStream(); |
| 1527 stream.reset(); // Will reset stream 3. | 1456 stream.reset(); // Will reset stream 3. |
| 1528 | 1457 |
| 1529 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1458 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1530 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1459 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1531 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1460 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1547 | 1476 |
| 1548 MockRead reads2[] = { | 1477 MockRead reads2[] = { |
| 1549 MockRead(ASYNC, 0, 0) // EOF | 1478 MockRead(ASYNC, 0, 0) // EOF |
| 1550 }; | 1479 }; |
| 1551 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1480 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1552 socket_factory_.AddSocketDataProvider(&socket_data2); | 1481 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1553 socket_data2.StopAfter(1); | 1482 socket_data2.StopAfter(1); |
| 1554 | 1483 |
| 1555 QuicStreamRequest request(&factory_); | 1484 QuicStreamRequest request(&factory_); |
| 1556 EXPECT_EQ(ERR_IO_PENDING, | 1485 EXPECT_EQ(ERR_IO_PENDING, |
| 1557 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1486 request.Request(host_port_pair_, privacy_mode_, |
| 1558 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1487 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1559 "GET", net_log_, callback_.callback())); | 1488 "GET", net_log_, callback_.callback())); |
| 1560 | 1489 |
| 1561 EXPECT_EQ(OK, callback_.WaitForResult()); | 1490 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1562 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1491 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1563 HttpRequestInfo request_info; | 1492 HttpRequestInfo request_info; |
| 1564 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1493 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1565 DEFAULT_PRIORITY, | 1494 DEFAULT_PRIORITY, |
| 1566 net_log_, CompletionCallback())); | 1495 net_log_, CompletionCallback())); |
| 1567 | 1496 |
| 1568 // Change the CA cert and verify that stream saw the event. | 1497 // Change the CA cert and verify that stream saw the event. |
| 1569 factory_.OnCACertChanged(nullptr); | 1498 factory_.OnCACertChanged(nullptr); |
| 1570 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 1499 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 1571 stream->ReadResponseHeaders(callback_.callback())); | 1500 stream->ReadResponseHeaders(callback_.callback())); |
| 1572 EXPECT_FALSE(factory_.require_confirmation()); | 1501 EXPECT_FALSE(factory_.require_confirmation()); |
| 1573 | 1502 |
| 1574 // Now attempting to request a stream to the same origin should create | 1503 // Now attempting to request a stream to the same origin should create |
| 1575 // a new session. | 1504 // a new session. |
| 1576 | 1505 |
| 1577 QuicStreamRequest request2(&factory_); | 1506 QuicStreamRequest request2(&factory_); |
| 1578 EXPECT_EQ(ERR_IO_PENDING, | 1507 EXPECT_EQ(ERR_IO_PENDING, |
| 1579 request2.Request(host_port_pair_, is_https_, privacy_mode_, | 1508 request2.Request(host_port_pair_, privacy_mode_, |
| 1580 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1509 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1581 "GET", net_log_, callback_.callback())); | 1510 "GET", net_log_, callback_.callback())); |
| 1582 | 1511 |
| 1583 EXPECT_EQ(OK, callback_.WaitForResult()); | 1512 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1584 stream = request2.ReleaseStream(); | 1513 stream = request2.ReleaseStream(); |
| 1585 stream.reset(); // Will reset stream 3. | 1514 stream.reset(); // Will reset stream 3. |
| 1586 | 1515 |
| 1587 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1516 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1588 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1517 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1589 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1518 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1590 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1519 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1591 } | 1520 } |
| 1592 | 1521 |
| 1593 TEST_P(QuicStreamFactoryTest, SharedCryptoConfig) { | 1522 TEST_P(QuicStreamFactoryTest, SharedCryptoConfig) { |
| 1594 vector<string> cannoncial_suffixes; | 1523 vector<string> cannoncial_suffixes; |
| 1595 cannoncial_suffixes.push_back(string(".c.youtube.com")); | 1524 cannoncial_suffixes.push_back(string(".c.youtube.com")); |
| 1596 cannoncial_suffixes.push_back(string(".googlevideo.com")); | 1525 cannoncial_suffixes.push_back(string(".googlevideo.com")); |
| 1597 | 1526 |
| 1598 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { | 1527 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { |
| 1599 string r1_host_name("r1"); | 1528 string r1_host_name("r1"); |
| 1600 string r2_host_name("r2"); | 1529 string r2_host_name("r2"); |
| 1601 r1_host_name.append(cannoncial_suffixes[i]); | 1530 r1_host_name.append(cannoncial_suffixes[i]); |
| 1602 r2_host_name.append(cannoncial_suffixes[i]); | 1531 r2_host_name.append(cannoncial_suffixes[i]); |
| 1603 | 1532 |
| 1604 HostPortPair host_port_pair1(r1_host_name, 80); | 1533 HostPortPair host_port_pair1(r1_host_name, 80); |
| 1605 QuicCryptoClientConfig* crypto_config = | 1534 QuicCryptoClientConfig* crypto_config = |
| 1606 QuicStreamFactoryPeer::GetCryptoConfig(&factory_); | 1535 QuicStreamFactoryPeer::GetCryptoConfig(&factory_); |
| 1607 QuicServerId server_id1(host_port_pair1, is_https_, privacy_mode_); | 1536 QuicServerId server_id1(host_port_pair1, /*is_https=*/true, privacy_mode_); |
| 1608 QuicCryptoClientConfig::CachedState* cached1 = | 1537 QuicCryptoClientConfig::CachedState* cached1 = |
| 1609 crypto_config->LookupOrCreate(server_id1); | 1538 crypto_config->LookupOrCreate(server_id1); |
| 1610 EXPECT_FALSE(cached1->proof_valid()); | 1539 EXPECT_FALSE(cached1->proof_valid()); |
| 1611 EXPECT_TRUE(cached1->source_address_token().empty()); | 1540 EXPECT_TRUE(cached1->source_address_token().empty()); |
| 1612 | 1541 |
| 1613 // Mutate the cached1 to have different data. | 1542 // Mutate the cached1 to have different data. |
| 1614 // TODO(rtenneti): mutate other members of CachedState. | 1543 // TODO(rtenneti): mutate other members of CachedState. |
| 1615 cached1->set_source_address_token(r1_host_name); | 1544 cached1->set_source_address_token(r1_host_name); |
| 1616 cached1->SetProofValid(); | 1545 cached1->SetProofValid(); |
| 1617 | 1546 |
| 1618 HostPortPair host_port_pair2(r2_host_name, 80); | 1547 HostPortPair host_port_pair2(r2_host_name, 80); |
| 1619 QuicServerId server_id2(host_port_pair2, is_https_, privacy_mode_); | 1548 QuicServerId server_id2(host_port_pair2, /*is_https=*/true, privacy_mode_); |
| 1620 QuicCryptoClientConfig::CachedState* cached2 = | 1549 QuicCryptoClientConfig::CachedState* cached2 = |
| 1621 crypto_config->LookupOrCreate(server_id2); | 1550 crypto_config->LookupOrCreate(server_id2); |
| 1622 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); | 1551 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); |
| 1623 EXPECT_TRUE(cached2->proof_valid()); | 1552 EXPECT_TRUE(cached2->proof_valid()); |
| 1624 } | 1553 } |
| 1625 } | 1554 } |
| 1626 | 1555 |
| 1627 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { | 1556 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { |
| 1628 vector<string> cannoncial_suffixes; | 1557 vector<string> cannoncial_suffixes; |
| 1629 cannoncial_suffixes.push_back(string(".c.youtube.com")); | 1558 cannoncial_suffixes.push_back(string(".c.youtube.com")); |
| 1630 cannoncial_suffixes.push_back(string(".googlevideo.com")); | 1559 cannoncial_suffixes.push_back(string(".googlevideo.com")); |
| 1631 | 1560 |
| 1632 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { | 1561 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { |
| 1633 string r3_host_name("r3"); | 1562 string r3_host_name("r3"); |
| 1634 string r4_host_name("r4"); | 1563 string r4_host_name("r4"); |
| 1635 r3_host_name.append(cannoncial_suffixes[i]); | 1564 r3_host_name.append(cannoncial_suffixes[i]); |
| 1636 r4_host_name.append(cannoncial_suffixes[i]); | 1565 r4_host_name.append(cannoncial_suffixes[i]); |
| 1637 | 1566 |
| 1638 HostPortPair host_port_pair1(r3_host_name, 80); | 1567 HostPortPair host_port_pair1(r3_host_name, 80); |
| 1639 QuicCryptoClientConfig* crypto_config = | 1568 QuicCryptoClientConfig* crypto_config = |
| 1640 QuicStreamFactoryPeer::GetCryptoConfig(&factory_); | 1569 QuicStreamFactoryPeer::GetCryptoConfig(&factory_); |
| 1641 QuicServerId server_id1(host_port_pair1, is_https_, privacy_mode_); | 1570 QuicServerId server_id1(host_port_pair1, /*is_https=*/true, privacy_mode_); |
| 1642 QuicCryptoClientConfig::CachedState* cached1 = | 1571 QuicCryptoClientConfig::CachedState* cached1 = |
| 1643 crypto_config->LookupOrCreate(server_id1); | 1572 crypto_config->LookupOrCreate(server_id1); |
| 1644 EXPECT_FALSE(cached1->proof_valid()); | 1573 EXPECT_FALSE(cached1->proof_valid()); |
| 1645 EXPECT_TRUE(cached1->source_address_token().empty()); | 1574 EXPECT_TRUE(cached1->source_address_token().empty()); |
| 1646 | 1575 |
| 1647 // Mutate the cached1 to have different data. | 1576 // Mutate the cached1 to have different data. |
| 1648 // TODO(rtenneti): mutate other members of CachedState. | 1577 // TODO(rtenneti): mutate other members of CachedState. |
| 1649 cached1->set_source_address_token(r3_host_name); | 1578 cached1->set_source_address_token(r3_host_name); |
| 1650 cached1->SetProofInvalid(); | 1579 cached1->SetProofInvalid(); |
| 1651 | 1580 |
| 1652 HostPortPair host_port_pair2(r4_host_name, 80); | 1581 HostPortPair host_port_pair2(r4_host_name, 80); |
| 1653 QuicServerId server_id2(host_port_pair2, is_https_, privacy_mode_); | 1582 QuicServerId server_id2(host_port_pair2, /*is_https=*/true, privacy_mode_); |
| 1654 QuicCryptoClientConfig::CachedState* cached2 = | 1583 QuicCryptoClientConfig::CachedState* cached2 = |
| 1655 crypto_config->LookupOrCreate(server_id2); | 1584 crypto_config->LookupOrCreate(server_id2); |
| 1656 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); | 1585 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); |
| 1657 EXPECT_TRUE(cached2->source_address_token().empty()); | 1586 EXPECT_TRUE(cached2->source_address_token().empty()); |
| 1658 EXPECT_FALSE(cached2->proof_valid()); | 1587 EXPECT_FALSE(cached2->proof_valid()); |
| 1659 } | 1588 } |
| 1660 } | 1589 } |
| 1661 | 1590 |
| 1662 TEST_P(QuicStreamFactoryTest, RacingConnections) { | 1591 TEST_P(QuicStreamFactoryTest, RacingConnections) { |
| 1663 if (!GetParam().enable_connection_racing) | 1592 if (!GetParam().enable_connection_racing) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1689 http_server_properties_.SetAlternativeServices( | 1618 http_server_properties_.SetAlternativeServices( |
| 1690 host_port_pair_, alternative_service_info_vector); | 1619 host_port_pair_, alternative_service_info_vector); |
| 1691 | 1620 |
| 1692 crypto_client_stream_factory_.set_handshake_mode( | 1621 crypto_client_stream_factory_.set_handshake_mode( |
| 1693 MockCryptoClientStream::ZERO_RTT); | 1622 MockCryptoClientStream::ZERO_RTT); |
| 1694 host_resolver_.set_synchronous_mode(true); | 1623 host_resolver_.set_synchronous_mode(true); |
| 1695 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1624 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1696 "192.168.0.1", ""); | 1625 "192.168.0.1", ""); |
| 1697 | 1626 |
| 1698 QuicStreamRequest request(&factory_); | 1627 QuicStreamRequest request(&factory_); |
| 1699 QuicServerId server_id(host_port_pair_, is_https_, privacy_mode_); | 1628 QuicServerId server_id(host_port_pair_, /*is_https=*/true, privacy_mode_); |
| 1700 EXPECT_EQ(ERR_IO_PENDING, | 1629 EXPECT_EQ(ERR_IO_PENDING, |
| 1701 request.Request(host_port_pair_, is_https_, privacy_mode_, | 1630 request.Request(host_port_pair_, privacy_mode_, |
| 1702 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1631 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1703 "GET", net_log_, callback_.callback())); | 1632 "GET", net_log_, callback_.callback())); |
| 1704 EXPECT_EQ(2u, | 1633 EXPECT_EQ(2u, |
| 1705 QuicStreamFactoryPeer::GetNumberOfActiveJobs(&factory_, server_id)); | 1634 QuicStreamFactoryPeer::GetNumberOfActiveJobs(&factory_, server_id)); |
| 1706 | 1635 |
| 1707 runner_->RunNextTask(); | 1636 runner_->RunNextTask(); |
| 1708 | 1637 |
| 1709 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1638 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1710 EXPECT_TRUE(stream.get()); | 1639 EXPECT_TRUE(stream.get()); |
| 1711 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1640 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1725 socket_factory_.AddSocketDataProvider(&socket_data); | 1654 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1726 socket_data.StopAfter(1); | 1655 socket_data.StopAfter(1); |
| 1727 | 1656 |
| 1728 crypto_client_stream_factory_.set_handshake_mode( | 1657 crypto_client_stream_factory_.set_handshake_mode( |
| 1729 MockCryptoClientStream::ZERO_RTT); | 1658 MockCryptoClientStream::ZERO_RTT); |
| 1730 host_resolver_.set_synchronous_mode(true); | 1659 host_resolver_.set_synchronous_mode(true); |
| 1731 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1660 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1732 "192.168.0.1", ""); | 1661 "192.168.0.1", ""); |
| 1733 | 1662 |
| 1734 QuicStreamRequest request(&factory_); | 1663 QuicStreamRequest request(&factory_); |
| 1735 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1664 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 1736 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1665 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1737 "GET", net_log_, callback_.callback())); | 1666 "GET", net_log_, callback_.callback())); |
| 1738 | 1667 |
| 1739 // If we are waiting for disk cache, we would have posted a task. Verify that | 1668 // If we are waiting for disk cache, we would have posted a task. Verify that |
| 1740 // the CancelWaitForDataReady task hasn't been posted. | 1669 // the CancelWaitForDataReady task hasn't been posted. |
| 1741 ASSERT_EQ(0u, runner_->GetPostedTasks().size()); | 1670 ASSERT_EQ(0u, runner_->GetPostedTasks().size()); |
| 1742 | 1671 |
| 1743 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1672 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1744 EXPECT_TRUE(stream.get()); | 1673 EXPECT_TRUE(stream.get()); |
| 1745 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1674 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 crypto_client_stream_factory_.set_handshake_mode( | 1710 crypto_client_stream_factory_.set_handshake_mode( |
| 1782 MockCryptoClientStream::ZERO_RTT); | 1711 MockCryptoClientStream::ZERO_RTT); |
| 1783 host_resolver_.set_synchronous_mode(true); | 1712 host_resolver_.set_synchronous_mode(true); |
| 1784 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1713 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1785 "192.168.0.1", ""); | 1714 "192.168.0.1", ""); |
| 1786 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 1715 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1787 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 1716 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 1788 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); | 1717 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); |
| 1789 | 1718 |
| 1790 QuicStreamRequest request(&factory_); | 1719 QuicStreamRequest request(&factory_); |
| 1791 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1720 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 1792 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1721 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1793 "GET", net_log_, callback_.callback())); | 1722 "GET", net_log_, callback_.callback())); |
| 1794 | 1723 |
| 1795 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1724 QuicChromiumClientSession* session = |
| 1796 &factory_, host_port_pair_, is_https_); | 1725 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 1797 | 1726 |
| 1798 DVLOG(1) << "Create 1st session and test packet loss"; | 1727 DVLOG(1) << "Create 1st session and test packet loss"; |
| 1799 | 1728 |
| 1800 // Set packet_loss_rate to a lower value than packet_loss_threshold. | 1729 // Set packet_loss_rate to a lower value than packet_loss_threshold. |
| 1801 EXPECT_FALSE( | 1730 EXPECT_FALSE( |
| 1802 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); | 1731 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); |
| 1803 EXPECT_TRUE(session->connection()->connected()); | 1732 EXPECT_TRUE(session->connection()->connected()); |
| 1804 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( | 1733 EXPECT_TRUE( |
| 1805 &factory_, host_port_pair_, is_https_)); | 1734 QuicStreamFactoryPeer::HasActiveSession(&factory_, host_port_pair_)); |
| 1806 EXPECT_FALSE( | 1735 EXPECT_FALSE( |
| 1807 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 1736 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 1808 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1737 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1809 &factory_, host_port_pair_.port())); | 1738 &factory_, host_port_pair_.port())); |
| 1810 | 1739 |
| 1811 // Set packet_loss_rate to a higher value than packet_loss_threshold only once | 1740 // Set packet_loss_rate to a higher value than packet_loss_threshold only once |
| 1812 // and that shouldn't close the session and it shouldn't disable QUIC. | 1741 // and that shouldn't close the session and it shouldn't disable QUIC. |
| 1813 EXPECT_FALSE( | 1742 EXPECT_FALSE( |
| 1814 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/1.0f)); | 1743 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/1.0f)); |
| 1815 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1744 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1816 &factory_, host_port_pair_.port())); | 1745 &factory_, host_port_pair_.port())); |
| 1817 EXPECT_TRUE(session->connection()->connected()); | 1746 EXPECT_TRUE(session->connection()->connected()); |
| 1818 EXPECT_FALSE( | 1747 EXPECT_FALSE( |
| 1819 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 1748 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 1820 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( | 1749 EXPECT_TRUE( |
| 1821 &factory_, host_port_pair_, is_https_)); | 1750 QuicStreamFactoryPeer::HasActiveSession(&factory_, host_port_pair_)); |
| 1822 | 1751 |
| 1823 // Test N-in-a-row high packet loss connections. | 1752 // Test N-in-a-row high packet loss connections. |
| 1824 | 1753 |
| 1825 DVLOG(1) << "Create 2nd session and test packet loss"; | 1754 DVLOG(1) << "Create 2nd session and test packet loss"; |
| 1826 | 1755 |
| 1827 TestCompletionCallback callback2; | 1756 TestCompletionCallback callback2; |
| 1828 QuicStreamRequest request2(&factory_); | 1757 QuicStreamRequest request2(&factory_); |
| 1829 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 1758 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 1830 /*cert_verify_flags=*/0, server2.host(), "GET", | 1759 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 1831 net_log_, callback2.callback())); | 1760 net_log_, callback2.callback())); |
| 1832 QuicChromiumClientSession* session2 = | 1761 QuicChromiumClientSession* session2 = |
| 1833 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 1762 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2); |
| 1834 | 1763 |
| 1835 // If there is no packet loss during handshake confirmation, number of lossy | 1764 // If there is no packet loss during handshake confirmation, number of lossy |
| 1836 // connections for the port should be 0. | 1765 // connections for the port should be 0. |
| 1837 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1766 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1838 &factory_, server2.port())); | 1767 &factory_, server2.port())); |
| 1839 EXPECT_FALSE( | 1768 EXPECT_FALSE( |
| 1840 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); | 1769 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); |
| 1841 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1770 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1842 &factory_, server2.port())); | 1771 &factory_, server2.port())); |
| 1843 EXPECT_FALSE( | 1772 EXPECT_FALSE( |
| 1844 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); | 1773 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); |
| 1845 | 1774 |
| 1846 // Set packet_loss_rate to a higher value than packet_loss_threshold only once | 1775 // Set packet_loss_rate to a higher value than packet_loss_threshold only once |
| 1847 // and that shouldn't close the session and it shouldn't disable QUIC. | 1776 // and that shouldn't close the session and it shouldn't disable QUIC. |
| 1848 EXPECT_FALSE( | 1777 EXPECT_FALSE( |
| 1849 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/1.0f)); | 1778 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/1.0f)); |
| 1850 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1779 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1851 &factory_, server2.port())); | 1780 &factory_, server2.port())); |
| 1852 EXPECT_TRUE(session2->connection()->connected()); | 1781 EXPECT_TRUE(session2->connection()->connected()); |
| 1853 EXPECT_FALSE( | 1782 EXPECT_FALSE( |
| 1854 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); | 1783 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); |
| 1855 EXPECT_TRUE( | 1784 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(&factory_, server2)); |
| 1856 QuicStreamFactoryPeer::HasActiveSession(&factory_, server2, is_https_)); | |
| 1857 | 1785 |
| 1858 DVLOG(1) << "Create 3rd session which also has packet loss"; | 1786 DVLOG(1) << "Create 3rd session which also has packet loss"; |
| 1859 | 1787 |
| 1860 TestCompletionCallback callback3; | 1788 TestCompletionCallback callback3; |
| 1861 QuicStreamRequest request3(&factory_); | 1789 QuicStreamRequest request3(&factory_); |
| 1862 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, | 1790 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 1863 /*cert_verify_flags=*/0, server3.host(), "GET", | 1791 /*cert_verify_flags=*/0, server3.host(), "GET", |
| 1864 net_log_, callback3.callback())); | 1792 net_log_, callback3.callback())); |
| 1865 QuicChromiumClientSession* session3 = | 1793 QuicChromiumClientSession* session3 = |
| 1866 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); | 1794 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3); |
| 1867 | 1795 |
| 1868 DVLOG(1) << "Create 4th session with packet loss and test IsQuicDisabled()"; | 1796 DVLOG(1) << "Create 4th session with packet loss and test IsQuicDisabled()"; |
| 1869 TestCompletionCallback callback4; | 1797 TestCompletionCallback callback4; |
| 1870 QuicStreamRequest request4(&factory_); | 1798 QuicStreamRequest request4(&factory_); |
| 1871 EXPECT_EQ(OK, request4.Request(server4, is_https_, privacy_mode_, | 1799 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, |
| 1872 /*cert_verify_flags=*/0, server4.host(), "GET", | 1800 /*cert_verify_flags=*/0, server4.host(), "GET", |
| 1873 net_log_, callback4.callback())); | 1801 net_log_, callback4.callback())); |
| 1874 QuicChromiumClientSession* session4 = | 1802 QuicChromiumClientSession* session4 = |
| 1875 QuicStreamFactoryPeer::GetActiveSession(&factory_, server4, is_https_); | 1803 QuicStreamFactoryPeer::GetActiveSession(&factory_, server4); |
| 1876 | 1804 |
| 1877 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in | 1805 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in |
| 1878 // a row and that should close the session and disable QUIC. | 1806 // a row and that should close the session and disable QUIC. |
| 1879 EXPECT_TRUE( | 1807 EXPECT_TRUE( |
| 1880 factory_.OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); | 1808 factory_.OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); |
| 1881 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1809 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1882 &factory_, server3.port())); | 1810 &factory_, server3.port())); |
| 1883 EXPECT_FALSE(session3->connection()->connected()); | 1811 EXPECT_FALSE(session3->connection()->connected()); |
| 1884 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server3.port())); | 1812 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server3.port())); |
| 1885 EXPECT_FALSE( | 1813 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession(&factory_, server3)); |
| 1886 QuicStreamFactoryPeer::HasActiveSession(&factory_, server3, is_https_)); | |
| 1887 EXPECT_FALSE(HasActiveSession(server3)); | 1814 EXPECT_FALSE(HasActiveSession(server3)); |
| 1888 | 1815 |
| 1889 // Set packet_loss_rate to higher value than packet_loss_threshold 3rd time in | 1816 // Set packet_loss_rate to higher value than packet_loss_threshold 3rd time in |
| 1890 // a row and IsQuicDisabled() should close the session. | 1817 // a row and IsQuicDisabled() should close the session. |
| 1891 EXPECT_TRUE( | 1818 EXPECT_TRUE( |
| 1892 factory_.OnHandshakeConfirmed(session4, /*packet_loss_rate=*/1.0f)); | 1819 factory_.OnHandshakeConfirmed(session4, /*packet_loss_rate=*/1.0f)); |
| 1893 EXPECT_EQ(3, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1820 EXPECT_EQ(3, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1894 &factory_, server4.port())); | 1821 &factory_, server4.port())); |
| 1895 EXPECT_FALSE(session4->connection()->connected()); | 1822 EXPECT_FALSE(session4->connection()->connected()); |
| 1896 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server4.port())); | 1823 EXPECT_TRUE(QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server4.port())); |
| 1897 EXPECT_FALSE( | 1824 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession(&factory_, server4)); |
| 1898 QuicStreamFactoryPeer::HasActiveSession(&factory_, server4, is_https_)); | |
| 1899 EXPECT_FALSE(HasActiveSession(server4)); | 1825 EXPECT_FALSE(HasActiveSession(server4)); |
| 1900 | 1826 |
| 1901 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1827 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1902 EXPECT_TRUE(stream.get()); | 1828 EXPECT_TRUE(stream.get()); |
| 1903 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1829 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1904 EXPECT_TRUE(stream2.get()); | 1830 EXPECT_TRUE(stream2.get()); |
| 1905 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 1831 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
| 1906 EXPECT_TRUE(stream3.get()); | 1832 EXPECT_TRUE(stream3.get()); |
| 1907 scoped_ptr<QuicHttpStream> stream4 = request4.ReleaseStream(); | 1833 scoped_ptr<QuicHttpStream> stream4 = request4.ReleaseStream(); |
| 1908 EXPECT_TRUE(stream4.get()); | 1834 EXPECT_TRUE(stream4.get()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1939 HostPortPair server2("mail.example.org", kDefaultServerPort); | 1865 HostPortPair server2("mail.example.org", kDefaultServerPort); |
| 1940 | 1866 |
| 1941 crypto_client_stream_factory_.set_handshake_mode( | 1867 crypto_client_stream_factory_.set_handshake_mode( |
| 1942 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 1868 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 1943 host_resolver_.set_synchronous_mode(true); | 1869 host_resolver_.set_synchronous_mode(true); |
| 1944 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1870 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1945 "192.168.0.1", ""); | 1871 "192.168.0.1", ""); |
| 1946 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 1872 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1947 | 1873 |
| 1948 QuicStreamRequest request(&factory_); | 1874 QuicStreamRequest request(&factory_); |
| 1949 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1875 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 1950 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1876 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1951 "GET", net_log_, callback_.callback())); | 1877 "GET", net_log_, callback_.callback())); |
| 1952 | 1878 |
| 1953 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1879 QuicChromiumClientSession* session = |
| 1954 &factory_, host_port_pair_, is_https_); | 1880 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 1955 | 1881 |
| 1956 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; | 1882 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; |
| 1957 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); | 1883 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); |
| 1958 // Need to spin the loop now to ensure that | 1884 // Need to spin the loop now to ensure that |
| 1959 // QuicStreamFactory::OnSessionClosed() runs. | 1885 // QuicStreamFactory::OnSessionClosed() runs. |
| 1960 base::RunLoop run_loop; | 1886 base::RunLoop run_loop; |
| 1961 run_loop.RunUntilIdle(); | 1887 run_loop.RunUntilIdle(); |
| 1962 | 1888 |
| 1963 EXPECT_EQ(1, | 1889 EXPECT_EQ(1, |
| 1964 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 1890 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 1965 EXPECT_FALSE( | 1891 EXPECT_FALSE( |
| 1966 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 1892 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 1967 | 1893 |
| 1968 // Test two-in-a-row public reset post handshakes.. | 1894 // Test two-in-a-row public reset post handshakes.. |
| 1969 DVLOG(1) << "Create 2nd session and trigger public reset post handshake"; | 1895 DVLOG(1) << "Create 2nd session and trigger public reset post handshake"; |
| 1970 TestCompletionCallback callback2; | 1896 TestCompletionCallback callback2; |
| 1971 QuicStreamRequest request2(&factory_); | 1897 QuicStreamRequest request2(&factory_); |
| 1972 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 1898 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 1973 /*cert_verify_flags=*/0, server2.host(), "GET", | 1899 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 1974 net_log_, callback2.callback())); | 1900 net_log_, callback2.callback())); |
| 1975 QuicChromiumClientSession* session2 = | 1901 QuicChromiumClientSession* session2 = |
| 1976 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 1902 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2); |
| 1977 | 1903 |
| 1978 session2->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); | 1904 session2->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); |
| 1979 // Need to spin the loop now to ensure that | 1905 // Need to spin the loop now to ensure that |
| 1980 // QuicStreamFactory::OnSessionClosed() runs. | 1906 // QuicStreamFactory::OnSessionClosed() runs. |
| 1981 base::RunLoop run_loop2; | 1907 base::RunLoop run_loop2; |
| 1982 run_loop2.RunUntilIdle(); | 1908 run_loop2.RunUntilIdle(); |
| 1983 EXPECT_EQ(2, | 1909 EXPECT_EQ(2, |
| 1984 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 1910 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 1985 EXPECT_TRUE( | 1911 EXPECT_TRUE( |
| 1986 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 1912 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 HostPortPair server2("mail.example.org", kDefaultServerPort); | 1947 HostPortPair server2("mail.example.org", kDefaultServerPort); |
| 2022 | 1948 |
| 2023 crypto_client_stream_factory_.set_handshake_mode( | 1949 crypto_client_stream_factory_.set_handshake_mode( |
| 2024 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 1950 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2025 host_resolver_.set_synchronous_mode(true); | 1951 host_resolver_.set_synchronous_mode(true); |
| 2026 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1952 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2027 "192.168.0.1", ""); | 1953 "192.168.0.1", ""); |
| 2028 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 1954 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2029 | 1955 |
| 2030 QuicStreamRequest request(&factory_); | 1956 QuicStreamRequest request(&factory_); |
| 2031 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1957 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2032 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1958 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2033 "GET", net_log_, callback_.callback())); | 1959 "GET", net_log_, callback_.callback())); |
| 2034 | 1960 |
| 2035 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1961 QuicChromiumClientSession* session = |
| 2036 &factory_, host_port_pair_, is_https_); | 1962 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 2037 | 1963 |
| 2038 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1964 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2039 EXPECT_TRUE(stream.get()); | 1965 EXPECT_TRUE(stream.get()); |
| 2040 HttpRequestInfo request_info; | 1966 HttpRequestInfo request_info; |
| 2041 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1967 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2042 net_log_, CompletionCallback())); | 1968 net_log_, CompletionCallback())); |
| 2043 | 1969 |
| 2044 DVLOG(1) | 1970 DVLOG(1) |
| 2045 << "Created 1st session and initialized a stream. Now trigger timeout"; | 1971 << "Created 1st session and initialized a stream. Now trigger timeout"; |
| 2046 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 1972 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); |
| 2047 // Need to spin the loop now to ensure that | 1973 // Need to spin the loop now to ensure that |
| 2048 // QuicStreamFactory::OnSessionClosed() runs. | 1974 // QuicStreamFactory::OnSessionClosed() runs. |
| 2049 base::RunLoop run_loop; | 1975 base::RunLoop run_loop; |
| 2050 run_loop.RunUntilIdle(); | 1976 run_loop.RunUntilIdle(); |
| 2051 | 1977 |
| 2052 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); | 1978 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); |
| 2053 EXPECT_FALSE( | 1979 EXPECT_FALSE( |
| 2054 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 1980 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2055 | 1981 |
| 2056 // Test two-in-a-row timeouts with open streams. | 1982 // Test two-in-a-row timeouts with open streams. |
| 2057 DVLOG(1) << "Create 2nd session and timeout with open stream"; | 1983 DVLOG(1) << "Create 2nd session and timeout with open stream"; |
| 2058 TestCompletionCallback callback2; | 1984 TestCompletionCallback callback2; |
| 2059 QuicStreamRequest request2(&factory_); | 1985 QuicStreamRequest request2(&factory_); |
| 2060 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 1986 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2061 /*cert_verify_flags=*/0, server2.host(), "GET", | 1987 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 2062 net_log_, callback2.callback())); | 1988 net_log_, callback2.callback())); |
| 2063 QuicChromiumClientSession* session2 = | 1989 QuicChromiumClientSession* session2 = |
| 2064 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 1990 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2); |
| 2065 | 1991 |
| 2066 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1992 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 2067 EXPECT_TRUE(stream2.get()); | 1993 EXPECT_TRUE(stream2.get()); |
| 2068 EXPECT_EQ(OK, stream2->InitializeStream(&request_info, DEFAULT_PRIORITY, | 1994 EXPECT_EQ(OK, stream2->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2069 net_log_, CompletionCallback())); | 1995 net_log_, CompletionCallback())); |
| 2070 | 1996 |
| 2071 session2->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 1997 session2->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); |
| 2072 // Need to spin the loop now to ensure that | 1998 // Need to spin the loop now to ensure that |
| 2073 // QuicStreamFactory::OnSessionClosed() runs. | 1999 // QuicStreamFactory::OnSessionClosed() runs. |
| 2074 base::RunLoop run_loop2; | 2000 base::RunLoop run_loop2; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 crypto_client_stream_factory_.set_handshake_mode( | 2040 crypto_client_stream_factory_.set_handshake_mode( |
| 2115 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2041 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2116 host_resolver_.set_synchronous_mode(true); | 2042 host_resolver_.set_synchronous_mode(true); |
| 2117 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2043 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2118 "192.168.0.1", ""); | 2044 "192.168.0.1", ""); |
| 2119 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2045 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2120 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 2046 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 2121 | 2047 |
| 2122 // Test first and third out of three public reset post handshakes. | 2048 // Test first and third out of three public reset post handshakes. |
| 2123 QuicStreamRequest request(&factory_); | 2049 QuicStreamRequest request(&factory_); |
| 2124 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 2050 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2125 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2051 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2126 "GET", net_log_, callback_.callback())); | 2052 "GET", net_log_, callback_.callback())); |
| 2127 | 2053 |
| 2128 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 2054 QuicChromiumClientSession* session = |
| 2129 &factory_, host_port_pair_, is_https_); | 2055 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 2130 | 2056 |
| 2131 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; | 2057 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; |
| 2132 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); | 2058 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); |
| 2133 // Need to spin the loop now to ensure that | 2059 // Need to spin the loop now to ensure that |
| 2134 // QuicStreamFactory::OnSessionClosed() runs. | 2060 // QuicStreamFactory::OnSessionClosed() runs. |
| 2135 base::RunLoop run_loop; | 2061 base::RunLoop run_loop; |
| 2136 run_loop.RunUntilIdle(); | 2062 run_loop.RunUntilIdle(); |
| 2137 | 2063 |
| 2138 EXPECT_EQ(1, | 2064 EXPECT_EQ(1, |
| 2139 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 2065 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 2140 EXPECT_FALSE( | 2066 EXPECT_FALSE( |
| 2141 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2067 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2142 | 2068 |
| 2143 DVLOG(1) << "Create 2nd session without disable trigger"; | 2069 DVLOG(1) << "Create 2nd session without disable trigger"; |
| 2144 TestCompletionCallback callback2; | 2070 TestCompletionCallback callback2; |
| 2145 QuicStreamRequest request2(&factory_); | 2071 QuicStreamRequest request2(&factory_); |
| 2146 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 2072 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2147 /*cert_verify_flags=*/0, server2.host(), "GET", | 2073 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 2148 net_log_, callback2.callback())); | 2074 net_log_, callback2.callback())); |
| 2149 QuicChromiumClientSession* session2 = | 2075 QuicChromiumClientSession* session2 = |
| 2150 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 2076 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2); |
| 2151 | 2077 |
| 2152 session2->connection()->CloseConnection(QUIC_NO_ERROR, false); | 2078 session2->connection()->CloseConnection(QUIC_NO_ERROR, false); |
| 2153 // Need to spin the loop now to ensure that | 2079 // Need to spin the loop now to ensure that |
| 2154 // QuicStreamFactory::OnSessionClosed() runs. | 2080 // QuicStreamFactory::OnSessionClosed() runs. |
| 2155 base::RunLoop run_loop2; | 2081 base::RunLoop run_loop2; |
| 2156 run_loop2.RunUntilIdle(); | 2082 run_loop2.RunUntilIdle(); |
| 2157 EXPECT_EQ(1, | 2083 EXPECT_EQ(1, |
| 2158 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 2084 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 2159 EXPECT_FALSE( | 2085 EXPECT_FALSE( |
| 2160 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2086 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2161 | 2087 |
| 2162 DVLOG(1) << "Create 3rd session with public reset post handshake," | 2088 DVLOG(1) << "Create 3rd session with public reset post handshake," |
| 2163 << " will disable QUIC"; | 2089 << " will disable QUIC"; |
| 2164 TestCompletionCallback callback3; | 2090 TestCompletionCallback callback3; |
| 2165 QuicStreamRequest request3(&factory_); | 2091 QuicStreamRequest request3(&factory_); |
| 2166 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, | 2092 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 2167 /*cert_verify_flags=*/0, server3.host(), "GET", | 2093 /*cert_verify_flags=*/0, server3.host(), "GET", |
| 2168 net_log_, callback3.callback())); | 2094 net_log_, callback3.callback())); |
| 2169 QuicChromiumClientSession* session3 = | 2095 QuicChromiumClientSession* session3 = |
| 2170 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); | 2096 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3); |
| 2171 | 2097 |
| 2172 session3->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); | 2098 session3->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); |
| 2173 // Need to spin the loop now to ensure that | 2099 // Need to spin the loop now to ensure that |
| 2174 // QuicStreamFactory::OnSessionClosed() runs. | 2100 // QuicStreamFactory::OnSessionClosed() runs. |
| 2175 base::RunLoop run_loop3; | 2101 base::RunLoop run_loop3; |
| 2176 run_loop3.RunUntilIdle(); | 2102 run_loop3.RunUntilIdle(); |
| 2177 EXPECT_EQ(2, | 2103 EXPECT_EQ(2, |
| 2178 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 2104 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 2179 EXPECT_TRUE( | 2105 EXPECT_TRUE( |
| 2180 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2106 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 crypto_client_stream_factory_.set_handshake_mode( | 2154 crypto_client_stream_factory_.set_handshake_mode( |
| 2229 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2155 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2230 host_resolver_.set_synchronous_mode(true); | 2156 host_resolver_.set_synchronous_mode(true); |
| 2231 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2157 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2232 "192.168.0.1", ""); | 2158 "192.168.0.1", ""); |
| 2233 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2159 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2234 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 2160 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 2235 | 2161 |
| 2236 // Test first and third out of three timeouts with open streams. | 2162 // Test first and third out of three timeouts with open streams. |
| 2237 QuicStreamRequest request(&factory_); | 2163 QuicStreamRequest request(&factory_); |
| 2238 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 2164 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2239 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2165 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2240 "GET", net_log_, callback_.callback())); | 2166 "GET", net_log_, callback_.callback())); |
| 2241 | 2167 |
| 2242 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 2168 QuicChromiumClientSession* session = |
| 2243 &factory_, host_port_pair_, is_https_); | 2169 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 2244 | 2170 |
| 2245 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2171 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2246 EXPECT_TRUE(stream.get()); | 2172 EXPECT_TRUE(stream.get()); |
| 2247 HttpRequestInfo request_info; | 2173 HttpRequestInfo request_info; |
| 2248 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2174 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2249 net_log_, CompletionCallback())); | 2175 net_log_, CompletionCallback())); |
| 2250 | 2176 |
| 2251 DVLOG(1) | 2177 DVLOG(1) |
| 2252 << "Created 1st session and initialized a stream. Now trigger timeout"; | 2178 << "Created 1st session and initialized a stream. Now trigger timeout"; |
| 2253 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2179 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); |
| 2254 // Need to spin the loop now to ensure that | 2180 // Need to spin the loop now to ensure that |
| 2255 // QuicStreamFactory::OnSessionClosed() runs. | 2181 // QuicStreamFactory::OnSessionClosed() runs. |
| 2256 base::RunLoop run_loop; | 2182 base::RunLoop run_loop; |
| 2257 run_loop.RunUntilIdle(); | 2183 run_loop.RunUntilIdle(); |
| 2258 | 2184 |
| 2259 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); | 2185 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); |
| 2260 EXPECT_FALSE( | 2186 EXPECT_FALSE( |
| 2261 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2187 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2262 | 2188 |
| 2263 // Test two-in-a-row timeouts with open streams. | 2189 // Test two-in-a-row timeouts with open streams. |
| 2264 DVLOG(1) << "Create 2nd session without timeout"; | 2190 DVLOG(1) << "Create 2nd session without timeout"; |
| 2265 TestCompletionCallback callback2; | 2191 TestCompletionCallback callback2; |
| 2266 QuicStreamRequest request2(&factory_); | 2192 QuicStreamRequest request2(&factory_); |
| 2267 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 2193 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2268 /*cert_verify_flags=*/0, server2.host(), "GET", | 2194 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 2269 net_log_, callback2.callback())); | 2195 net_log_, callback2.callback())); |
| 2270 QuicChromiumClientSession* session2 = | 2196 QuicChromiumClientSession* session2 = |
| 2271 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 2197 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2); |
| 2272 | 2198 |
| 2273 session2->connection()->CloseConnection(QUIC_NO_ERROR, true); | 2199 session2->connection()->CloseConnection(QUIC_NO_ERROR, true); |
| 2274 // Need to spin the loop now to ensure that | 2200 // Need to spin the loop now to ensure that |
| 2275 // QuicStreamFactory::OnSessionClosed() runs. | 2201 // QuicStreamFactory::OnSessionClosed() runs. |
| 2276 base::RunLoop run_loop2; | 2202 base::RunLoop run_loop2; |
| 2277 run_loop2.RunUntilIdle(); | 2203 run_loop2.RunUntilIdle(); |
| 2278 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); | 2204 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); |
| 2279 EXPECT_FALSE( | 2205 EXPECT_FALSE( |
| 2280 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2206 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2281 | 2207 |
| 2282 DVLOG(1) << "Create 3rd session with timeout with open streams," | 2208 DVLOG(1) << "Create 3rd session with timeout with open streams," |
| 2283 << " will disable QUIC"; | 2209 << " will disable QUIC"; |
| 2284 | 2210 |
| 2285 TestCompletionCallback callback3; | 2211 TestCompletionCallback callback3; |
| 2286 QuicStreamRequest request3(&factory_); | 2212 QuicStreamRequest request3(&factory_); |
| 2287 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, | 2213 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 2288 /*cert_verify_flags=*/0, server3.host(), "GET", | 2214 /*cert_verify_flags=*/0, server3.host(), "GET", |
| 2289 net_log_, callback3.callback())); | 2215 net_log_, callback3.callback())); |
| 2290 QuicChromiumClientSession* session3 = | 2216 QuicChromiumClientSession* session3 = |
| 2291 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); | 2217 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3); |
| 2292 | 2218 |
| 2293 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 2219 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
| 2294 EXPECT_TRUE(stream3.get()); | 2220 EXPECT_TRUE(stream3.get()); |
| 2295 EXPECT_EQ(OK, stream3->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2221 EXPECT_EQ(OK, stream3->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2296 net_log_, CompletionCallback())); | 2222 net_log_, CompletionCallback())); |
| 2297 session3->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2223 session3->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); |
| 2298 // Need to spin the loop now to ensure that | 2224 // Need to spin the loop now to ensure that |
| 2299 // QuicStreamFactory::OnSessionClosed() runs. | 2225 // QuicStreamFactory::OnSessionClosed() runs. |
| 2300 base::RunLoop run_loop3; | 2226 base::RunLoop run_loop3; |
| 2301 run_loop3.RunUntilIdle(); | 2227 run_loop3.RunUntilIdle(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2351 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2277 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2352 host_resolver_.set_synchronous_mode(true); | 2278 host_resolver_.set_synchronous_mode(true); |
| 2353 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2279 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2354 "192.168.0.1", ""); | 2280 "192.168.0.1", ""); |
| 2355 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2281 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2356 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 2282 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 2357 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); | 2283 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); |
| 2358 | 2284 |
| 2359 // Test first and fourth out of four public reset post handshakes. | 2285 // Test first and fourth out of four public reset post handshakes. |
| 2360 QuicStreamRequest request(&factory_); | 2286 QuicStreamRequest request(&factory_); |
| 2361 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 2287 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2362 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2288 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2363 "GET", net_log_, callback_.callback())); | 2289 "GET", net_log_, callback_.callback())); |
| 2364 | 2290 |
| 2365 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 2291 QuicChromiumClientSession* session = |
| 2366 &factory_, host_port_pair_, is_https_); | 2292 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 2367 | 2293 |
| 2368 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; | 2294 DVLOG(1) << "Created 1st session. Now trigger public reset post handshake"; |
| 2369 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); | 2295 session->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); |
| 2370 // Need to spin the loop now to ensure that | 2296 // Need to spin the loop now to ensure that |
| 2371 // QuicStreamFactory::OnSessionClosed() runs. | 2297 // QuicStreamFactory::OnSessionClosed() runs. |
| 2372 base::RunLoop run_loop; | 2298 base::RunLoop run_loop; |
| 2373 run_loop.RunUntilIdle(); | 2299 run_loop.RunUntilIdle(); |
| 2374 | 2300 |
| 2375 EXPECT_EQ(1, | 2301 EXPECT_EQ(1, |
| 2376 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 2302 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 2377 EXPECT_FALSE( | 2303 EXPECT_FALSE( |
| 2378 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2304 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2379 | 2305 |
| 2380 DVLOG(1) << "Create 2nd and 3rd sessions without disable trigger"; | 2306 DVLOG(1) << "Create 2nd and 3rd sessions without disable trigger"; |
| 2381 TestCompletionCallback callback2; | 2307 TestCompletionCallback callback2; |
| 2382 QuicStreamRequest request2(&factory_); | 2308 QuicStreamRequest request2(&factory_); |
| 2383 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 2309 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2384 /*cert_verify_flags=*/0, server2.host(), "GET", | 2310 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 2385 net_log_, callback2.callback())); | 2311 net_log_, callback2.callback())); |
| 2386 QuicChromiumClientSession* session2 = | 2312 QuicChromiumClientSession* session2 = |
| 2387 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 2313 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2); |
| 2388 | 2314 |
| 2389 session2->connection()->CloseConnection(QUIC_NO_ERROR, false); | 2315 session2->connection()->CloseConnection(QUIC_NO_ERROR, false); |
| 2390 // Need to spin the loop now to ensure that | 2316 // Need to spin the loop now to ensure that |
| 2391 // QuicStreamFactory::OnSessionClosed() runs. | 2317 // QuicStreamFactory::OnSessionClosed() runs. |
| 2392 base::RunLoop run_loop2; | 2318 base::RunLoop run_loop2; |
| 2393 run_loop2.RunUntilIdle(); | 2319 run_loop2.RunUntilIdle(); |
| 2394 EXPECT_EQ(1, | 2320 EXPECT_EQ(1, |
| 2395 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 2321 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 2396 EXPECT_FALSE( | 2322 EXPECT_FALSE( |
| 2397 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2323 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2398 | 2324 |
| 2399 TestCompletionCallback callback3; | 2325 TestCompletionCallback callback3; |
| 2400 QuicStreamRequest request3(&factory_); | 2326 QuicStreamRequest request3(&factory_); |
| 2401 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, | 2327 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 2402 /*cert_verify_flags=*/0, server3.host(), "GET", | 2328 /*cert_verify_flags=*/0, server3.host(), "GET", |
| 2403 net_log_, callback3.callback())); | 2329 net_log_, callback3.callback())); |
| 2404 QuicChromiumClientSession* session3 = | 2330 QuicChromiumClientSession* session3 = |
| 2405 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); | 2331 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3); |
| 2406 | 2332 |
| 2407 session3->connection()->CloseConnection(QUIC_NO_ERROR, false); | 2333 session3->connection()->CloseConnection(QUIC_NO_ERROR, false); |
| 2408 // Need to spin the loop now to ensure that | 2334 // Need to spin the loop now to ensure that |
| 2409 // QuicStreamFactory::OnSessionClosed() runs. | 2335 // QuicStreamFactory::OnSessionClosed() runs. |
| 2410 base::RunLoop run_loop3; | 2336 base::RunLoop run_loop3; |
| 2411 run_loop3.RunUntilIdle(); | 2337 run_loop3.RunUntilIdle(); |
| 2412 EXPECT_EQ(1, | 2338 EXPECT_EQ(1, |
| 2413 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 2339 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 2414 EXPECT_FALSE( | 2340 EXPECT_FALSE( |
| 2415 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2341 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2416 | 2342 |
| 2417 DVLOG(1) << "Create 4rd session with public reset post handshake," | 2343 DVLOG(1) << "Create 4rd session with public reset post handshake," |
| 2418 << " will not disable QUIC"; | 2344 << " will not disable QUIC"; |
| 2419 TestCompletionCallback callback4; | 2345 TestCompletionCallback callback4; |
| 2420 QuicStreamRequest request4(&factory_); | 2346 QuicStreamRequest request4(&factory_); |
| 2421 EXPECT_EQ(OK, request4.Request(server4, is_https_, privacy_mode_, | 2347 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, |
| 2422 /*cert_verify_flags=*/0, server4.host(), "GET", | 2348 /*cert_verify_flags=*/0, server4.host(), "GET", |
| 2423 net_log_, callback4.callback())); | 2349 net_log_, callback4.callback())); |
| 2424 QuicChromiumClientSession* session4 = | 2350 QuicChromiumClientSession* session4 = |
| 2425 QuicStreamFactoryPeer::GetActiveSession(&factory_, server4, is_https_); | 2351 QuicStreamFactoryPeer::GetActiveSession(&factory_, server4); |
| 2426 | 2352 |
| 2427 session4->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); | 2353 session4->connection()->CloseConnection(QUIC_PUBLIC_RESET, true); |
| 2428 // Need to spin the loop now to ensure that | 2354 // Need to spin the loop now to ensure that |
| 2429 // QuicStreamFactory::OnSessionClosed() runs. | 2355 // QuicStreamFactory::OnSessionClosed() runs. |
| 2430 base::RunLoop run_loop4; | 2356 base::RunLoop run_loop4; |
| 2431 run_loop4.RunUntilIdle(); | 2357 run_loop4.RunUntilIdle(); |
| 2432 EXPECT_EQ(1, | 2358 EXPECT_EQ(1, |
| 2433 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); | 2359 QuicStreamFactoryPeer::GetNumPublicResetsPostHandshake(&factory_)); |
| 2434 EXPECT_FALSE( | 2360 EXPECT_FALSE( |
| 2435 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2361 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2490 MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2416 MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2491 host_resolver_.set_synchronous_mode(true); | 2417 host_resolver_.set_synchronous_mode(true); |
| 2492 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2418 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2493 "192.168.0.1", ""); | 2419 "192.168.0.1", ""); |
| 2494 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 2420 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 2495 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 2421 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 2496 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); | 2422 host_resolver_.rules()->AddIPLiteralRule(server4.host(), "192.168.0.1", ""); |
| 2497 | 2423 |
| 2498 // Test first and fourth out of three timeouts with open streams. | 2424 // Test first and fourth out of three timeouts with open streams. |
| 2499 QuicStreamRequest request(&factory_); | 2425 QuicStreamRequest request(&factory_); |
| 2500 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 2426 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2501 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2427 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2502 "GET", net_log_, callback_.callback())); | 2428 "GET", net_log_, callback_.callback())); |
| 2503 | 2429 |
| 2504 QuicChromiumClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 2430 QuicChromiumClientSession* session = |
| 2505 &factory_, host_port_pair_, is_https_); | 2431 QuicStreamFactoryPeer::GetActiveSession(&factory_, host_port_pair_); |
| 2506 | 2432 |
| 2507 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2433 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2508 EXPECT_TRUE(stream.get()); | 2434 EXPECT_TRUE(stream.get()); |
| 2509 HttpRequestInfo request_info; | 2435 HttpRequestInfo request_info; |
| 2510 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2436 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2511 net_log_, CompletionCallback())); | 2437 net_log_, CompletionCallback())); |
| 2512 | 2438 |
| 2513 DVLOG(1) | 2439 DVLOG(1) |
| 2514 << "Created 1st session and initialized a stream. Now trigger timeout"; | 2440 << "Created 1st session and initialized a stream. Now trigger timeout"; |
| 2515 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2441 session->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); |
| 2516 // Need to spin the loop now to ensure that | 2442 // Need to spin the loop now to ensure that |
| 2517 // QuicStreamFactory::OnSessionClosed() runs. | 2443 // QuicStreamFactory::OnSessionClosed() runs. |
| 2518 base::RunLoop run_loop; | 2444 base::RunLoop run_loop; |
| 2519 run_loop.RunUntilIdle(); | 2445 run_loop.RunUntilIdle(); |
| 2520 | 2446 |
| 2521 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); | 2447 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); |
| 2522 EXPECT_FALSE( | 2448 EXPECT_FALSE( |
| 2523 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2449 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2524 | 2450 |
| 2525 DVLOG(1) << "Create 2nd and 3rd sessions without timeout"; | 2451 DVLOG(1) << "Create 2nd and 3rd sessions without timeout"; |
| 2526 TestCompletionCallback callback2; | 2452 TestCompletionCallback callback2; |
| 2527 QuicStreamRequest request2(&factory_); | 2453 QuicStreamRequest request2(&factory_); |
| 2528 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, | 2454 EXPECT_EQ(OK, request2.Request(server2, privacy_mode_, |
| 2529 /*cert_verify_flags=*/0, server2.host(), "GET", | 2455 /*cert_verify_flags=*/0, server2.host(), "GET", |
| 2530 net_log_, callback2.callback())); | 2456 net_log_, callback2.callback())); |
| 2531 QuicChromiumClientSession* session2 = | 2457 QuicChromiumClientSession* session2 = |
| 2532 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 2458 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2); |
| 2533 | 2459 |
| 2534 session2->connection()->CloseConnection(QUIC_NO_ERROR, true); | 2460 session2->connection()->CloseConnection(QUIC_NO_ERROR, true); |
| 2535 // Need to spin the loop now to ensure that | 2461 // Need to spin the loop now to ensure that |
| 2536 // QuicStreamFactory::OnSessionClosed() runs. | 2462 // QuicStreamFactory::OnSessionClosed() runs. |
| 2537 base::RunLoop run_loop2; | 2463 base::RunLoop run_loop2; |
| 2538 run_loop2.RunUntilIdle(); | 2464 run_loop2.RunUntilIdle(); |
| 2539 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); | 2465 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); |
| 2540 EXPECT_FALSE( | 2466 EXPECT_FALSE( |
| 2541 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2467 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2542 | 2468 |
| 2543 TestCompletionCallback callback3; | 2469 TestCompletionCallback callback3; |
| 2544 QuicStreamRequest request3(&factory_); | 2470 QuicStreamRequest request3(&factory_); |
| 2545 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, | 2471 EXPECT_EQ(OK, request3.Request(server3, privacy_mode_, |
| 2546 /*cert_verify_flags=*/0, server3.host(), "GET", | 2472 /*cert_verify_flags=*/0, server3.host(), "GET", |
| 2547 net_log_, callback3.callback())); | 2473 net_log_, callback3.callback())); |
| 2548 QuicChromiumClientSession* session3 = | 2474 QuicChromiumClientSession* session3 = |
| 2549 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); | 2475 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3); |
| 2550 | 2476 |
| 2551 session3->connection()->CloseConnection(QUIC_NO_ERROR, true); | 2477 session3->connection()->CloseConnection(QUIC_NO_ERROR, true); |
| 2552 // Need to spin the loop now to ensure that | 2478 // Need to spin the loop now to ensure that |
| 2553 // QuicStreamFactory::OnSessionClosed() runs. | 2479 // QuicStreamFactory::OnSessionClosed() runs. |
| 2554 base::RunLoop run_loop3; | 2480 base::RunLoop run_loop3; |
| 2555 run_loop3.RunUntilIdle(); | 2481 run_loop3.RunUntilIdle(); |
| 2556 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); | 2482 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumTimeoutsWithOpenStreams(&factory_)); |
| 2557 EXPECT_FALSE( | 2483 EXPECT_FALSE( |
| 2558 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); | 2484 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, host_port_pair_.port())); |
| 2559 | 2485 |
| 2560 DVLOG(1) << "Create 4th session with timeout with open streams," | 2486 DVLOG(1) << "Create 4th session with timeout with open streams," |
| 2561 << " will not disable QUIC"; | 2487 << " will not disable QUIC"; |
| 2562 | 2488 |
| 2563 TestCompletionCallback callback4; | 2489 TestCompletionCallback callback4; |
| 2564 QuicStreamRequest request4(&factory_); | 2490 QuicStreamRequest request4(&factory_); |
| 2565 EXPECT_EQ(OK, request4.Request(server4, is_https_, privacy_mode_, | 2491 EXPECT_EQ(OK, request4.Request(server4, privacy_mode_, |
| 2566 /*cert_verify_flags=*/0, server4.host(), "GET", | 2492 /*cert_verify_flags=*/0, server4.host(), "GET", |
| 2567 net_log_, callback4.callback())); | 2493 net_log_, callback4.callback())); |
| 2568 QuicChromiumClientSession* session4 = | 2494 QuicChromiumClientSession* session4 = |
| 2569 QuicStreamFactoryPeer::GetActiveSession(&factory_, server4, is_https_); | 2495 QuicStreamFactoryPeer::GetActiveSession(&factory_, server4); |
| 2570 | 2496 |
| 2571 scoped_ptr<QuicHttpStream> stream4 = request4.ReleaseStream(); | 2497 scoped_ptr<QuicHttpStream> stream4 = request4.ReleaseStream(); |
| 2572 EXPECT_TRUE(stream4.get()); | 2498 EXPECT_TRUE(stream4.get()); |
| 2573 EXPECT_EQ(OK, stream4->InitializeStream(&request_info, DEFAULT_PRIORITY, | 2499 EXPECT_EQ(OK, stream4->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2574 net_log_, CompletionCallback())); | 2500 net_log_, CompletionCallback())); |
| 2575 session4->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); | 2501 session4->connection()->CloseConnection(QUIC_CONNECTION_TIMED_OUT, false); |
| 2576 // Need to spin the loop now to ensure that | 2502 // Need to spin the loop now to ensure that |
| 2577 // QuicStreamFactory::OnSessionClosed() runs. | 2503 // QuicStreamFactory::OnSessionClosed() runs. |
| 2578 base::RunLoop run_loop4; | 2504 base::RunLoop run_loop4; |
| 2579 run_loop4.RunUntilIdle(); | 2505 run_loop4.RunUntilIdle(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2610 http_server_properties_.SetServerNetworkStats(host_port_pair_, stats1); | 2536 http_server_properties_.SetServerNetworkStats(host_port_pair_, stats1); |
| 2611 | 2537 |
| 2612 crypto_client_stream_factory_.set_handshake_mode( | 2538 crypto_client_stream_factory_.set_handshake_mode( |
| 2613 MockCryptoClientStream::ZERO_RTT); | 2539 MockCryptoClientStream::ZERO_RTT); |
| 2614 host_resolver_.set_synchronous_mode(true); | 2540 host_resolver_.set_synchronous_mode(true); |
| 2615 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2541 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2616 "192.168.0.1", ""); | 2542 "192.168.0.1", ""); |
| 2617 | 2543 |
| 2618 QuicStreamRequest request(&factory_); | 2544 QuicStreamRequest request(&factory_); |
| 2619 EXPECT_EQ(ERR_IO_PENDING, | 2545 EXPECT_EQ(ERR_IO_PENDING, |
| 2620 request.Request(host_port_pair_, is_https_, privacy_mode_, | 2546 request.Request(host_port_pair_, privacy_mode_, |
| 2621 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2547 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2622 "POST", net_log_, callback_.callback())); | 2548 "POST", net_log_, callback_.callback())); |
| 2623 | 2549 |
| 2624 // If we don't delay TCP connection, then time delay should be 0. | 2550 // If we don't delay TCP connection, then time delay should be 0. |
| 2625 EXPECT_FALSE(factory_.delay_tcp_race()); | 2551 EXPECT_FALSE(factory_.delay_tcp_race()); |
| 2626 EXPECT_EQ(base::TimeDelta(), request.GetTimeDelayForWaitingJob()); | 2552 EXPECT_EQ(base::TimeDelta(), request.GetTimeDelayForWaitingJob()); |
| 2627 | 2553 |
| 2628 // Enable |delay_tcp_race_| param and verify delay is one RTT and that | 2554 // Enable |delay_tcp_race_| param and verify delay is one RTT and that |
| 2629 // server supports QUIC. | 2555 // server supports QUIC. |
| 2630 QuicStreamFactoryPeer::SetDelayTcpRace(&factory_, true); | 2556 QuicStreamFactoryPeer::SetDelayTcpRace(&factory_, true); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 host_resolver_.set_synchronous_mode(true); | 2662 host_resolver_.set_synchronous_mode(true); |
| 2737 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2663 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2738 "192.168.0.1", ""); | 2664 "192.168.0.1", ""); |
| 2739 | 2665 |
| 2740 // Set up the TaskObserver to verify QuicPacketReader::StartReading posts a | 2666 // Set up the TaskObserver to verify QuicPacketReader::StartReading posts a |
| 2741 // task. | 2667 // task. |
| 2742 // TODO(rtenneti): Change SpdySessionTestTaskObserver to NetTestTaskObserver?? | 2668 // TODO(rtenneti): Change SpdySessionTestTaskObserver to NetTestTaskObserver?? |
| 2743 SpdySessionTestTaskObserver observer("quic_packet_reader.cc", "StartReading"); | 2669 SpdySessionTestTaskObserver observer("quic_packet_reader.cc", "StartReading"); |
| 2744 | 2670 |
| 2745 QuicStreamRequest request(&factory_); | 2671 QuicStreamRequest request(&factory_); |
| 2746 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 2672 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2747 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2673 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2748 "GET", net_log_, callback_.callback())); | 2674 "GET", net_log_, callback_.callback())); |
| 2749 | 2675 |
| 2750 // Call run_loop so that QuicPacketReader::OnReadComplete() gets called. | 2676 // Call run_loop so that QuicPacketReader::OnReadComplete() gets called. |
| 2751 base::RunLoop run_loop; | 2677 base::RunLoop run_loop; |
| 2752 run_loop.RunUntilIdle(); | 2678 run_loop.RunUntilIdle(); |
| 2753 | 2679 |
| 2754 // Verify task that the observer's executed_count is 1, which indicates | 2680 // Verify task that the observer's executed_count is 1, which indicates |
| 2755 // QuicPacketReader::StartReading() has posted only one task and yielded the | 2681 // QuicPacketReader::StartReading() has posted only one task and yielded the |
| 2756 // read. | 2682 // read. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2781 host_resolver_.set_synchronous_mode(true); | 2707 host_resolver_.set_synchronous_mode(true); |
| 2782 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 2708 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 2783 "192.168.0.1", ""); | 2709 "192.168.0.1", ""); |
| 2784 | 2710 |
| 2785 // Set up the TaskObserver to verify QuicPacketReader::StartReading posts a | 2711 // Set up the TaskObserver to verify QuicPacketReader::StartReading posts a |
| 2786 // task. | 2712 // task. |
| 2787 // TODO(rtenneti): Change SpdySessionTestTaskObserver to NetTestTaskObserver?? | 2713 // TODO(rtenneti): Change SpdySessionTestTaskObserver to NetTestTaskObserver?? |
| 2788 SpdySessionTestTaskObserver observer("quic_packet_reader.cc", "StartReading"); | 2714 SpdySessionTestTaskObserver observer("quic_packet_reader.cc", "StartReading"); |
| 2789 | 2715 |
| 2790 QuicStreamRequest request(&factory_); | 2716 QuicStreamRequest request(&factory_); |
| 2791 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 2717 EXPECT_EQ(OK, request.Request(host_port_pair_, privacy_mode_, |
| 2792 /*cert_verify_flags=*/0, host_port_pair_.host(), | 2718 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2793 "GET", net_log_, callback_.callback())); | 2719 "GET", net_log_, callback_.callback())); |
| 2794 | 2720 |
| 2795 // Call run_loop so that QuicPacketReader::OnReadComplete() gets called. | 2721 // Call run_loop so that QuicPacketReader::OnReadComplete() gets called. |
| 2796 base::RunLoop run_loop; | 2722 base::RunLoop run_loop; |
| 2797 run_loop.RunUntilIdle(); | 2723 run_loop.RunUntilIdle(); |
| 2798 | 2724 |
| 2799 // Verify task that the observer's executed_count is 1, which indicates | 2725 // Verify task that the observer's executed_count is 1, which indicates |
| 2800 // QuicPacketReader::StartReading() has posted only one task and yielded the | 2726 // QuicPacketReader::StartReading() has posted only one task and yielded the |
| 2801 // read. | 2727 // read. |
| 2802 EXPECT_EQ(1u, observer.executed_count()); | 2728 EXPECT_EQ(1u, observer.executed_count()); |
| 2803 | 2729 |
| 2804 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2730 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2805 EXPECT_TRUE(stream.get()); | 2731 EXPECT_TRUE(stream.get()); |
| 2806 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2732 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 2807 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2733 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 2808 } | 2734 } |
| 2809 | 2735 |
| 2810 } // namespace test | 2736 } // namespace test |
| 2811 } // namespace net | 2737 } // namespace net |
| OLD | NEW |