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