Chromium Code Reviews| 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 "net/base/test_data_directory.h" | 9 #include "net/base/test_data_directory.h" |
| 10 #include "net/cert/cert_verifier.h" | 10 #include "net/cert/cert_verifier.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 | 258 |
| 259 MockRead reads[] = { | 259 MockRead reads[] = { |
| 260 MockRead(ASYNC, OK, 0) // EOF | 260 MockRead(ASYNC, OK, 0) // EOF |
| 261 }; | 261 }; |
| 262 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 262 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 263 socket_data.StopAfter(1); | 263 socket_data.StopAfter(1); |
| 264 socket_factory_.AddSocketDataProvider(&socket_data); | 264 socket_factory_.AddSocketDataProvider(&socket_data); |
| 265 | 265 |
| 266 QuicStreamRequest request(&factory_); | 266 QuicStreamRequest request(&factory_); |
| 267 EXPECT_EQ(ERR_IO_PENDING, | 267 EXPECT_EQ(ERR_IO_PENDING, |
| 268 request.Request(destination, | 268 request.Request(destination, is_https_, privacy_mode_, |
| 269 is_https_, | 269 destination.host(), "GET", net_log_, |
| 270 privacy_mode_, | |
| 271 "GET", | |
| 272 net_log_, | |
| 273 callback_.callback())); | 270 callback_.callback())); |
| 274 | 271 |
| 275 EXPECT_EQ(OK, callback_.WaitForResult()); | 272 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 276 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 273 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 277 EXPECT_TRUE(stream.get()); | 274 EXPECT_TRUE(stream.get()); |
| 278 stream.reset(); | 275 stream.reset(); |
| 279 | 276 |
| 280 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 277 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( |
| 281 &factory_, destination, is_https_); | 278 &factory_, destination, is_https_); |
| 282 | 279 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 TEST_P(QuicStreamFactoryTest, Create) { | 335 TEST_P(QuicStreamFactoryTest, Create) { |
| 339 MockRead reads[] = { | 336 MockRead reads[] = { |
| 340 MockRead(ASYNC, OK, 0) // EOF | 337 MockRead(ASYNC, OK, 0) // EOF |
| 341 }; | 338 }; |
| 342 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 339 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 343 socket_factory_.AddSocketDataProvider(&socket_data); | 340 socket_factory_.AddSocketDataProvider(&socket_data); |
| 344 socket_data.StopAfter(1); | 341 socket_data.StopAfter(1); |
| 345 | 342 |
| 346 QuicStreamRequest request(&factory_); | 343 QuicStreamRequest request(&factory_); |
| 347 EXPECT_EQ(ERR_IO_PENDING, | 344 EXPECT_EQ(ERR_IO_PENDING, |
| 348 request.Request(host_port_pair_, | 345 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 349 is_https_, | 346 host_port_pair_.host(), "GET", net_log_, |
| 350 privacy_mode_, | |
| 351 "GET", | |
| 352 net_log_, | |
| 353 callback_.callback())); | 347 callback_.callback())); |
| 354 | 348 |
| 355 EXPECT_EQ(OK, callback_.WaitForResult()); | 349 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 356 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 350 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 357 EXPECT_TRUE(stream.get()); | 351 EXPECT_TRUE(stream.get()); |
| 358 | 352 |
| 359 // Will reset stream 3. | 353 // Will reset stream 3. |
| 360 stream = CreateIfSessionExists(host_port_pair_, net_log_); | 354 stream = CreateIfSessionExists(host_port_pair_, net_log_); |
| 361 EXPECT_TRUE(stream.get()); | 355 EXPECT_TRUE(stream.get()); |
| 362 | 356 |
| 363 // TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result | 357 // TODO(rtenneti): We should probably have a tests that HTTP and HTTPS result |
| 364 // in streams on different sessions. | 358 // in streams on different sessions. |
| 365 QuicStreamRequest request2(&factory_); | 359 QuicStreamRequest request2(&factory_); |
| 366 EXPECT_EQ(OK, | 360 EXPECT_EQ(OK, request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 367 request2.Request(host_port_pair_, | 361 host_port_pair_.host(), "GET", net_log_, |
| 368 is_https_, | 362 callback_.callback())); |
| 369 privacy_mode_, | |
| 370 "GET", | |
| 371 net_log_, | |
| 372 callback_.callback())); | |
| 373 stream = request2.ReleaseStream(); // Will reset stream 5. | 363 stream = request2.ReleaseStream(); // Will reset stream 5. |
| 374 stream.reset(); // Will reset stream 7. | 364 stream.reset(); // Will reset stream 7. |
| 375 | 365 |
| 376 EXPECT_TRUE(socket_data.at_read_eof()); | 366 EXPECT_TRUE(socket_data.at_read_eof()); |
| 377 EXPECT_TRUE(socket_data.at_write_eof()); | 367 EXPECT_TRUE(socket_data.at_write_eof()); |
| 378 } | 368 } |
| 379 | 369 |
| 380 TEST_P(QuicStreamFactoryTest, CreateZeroRtt) { | 370 TEST_P(QuicStreamFactoryTest, CreateZeroRtt) { |
| 381 MockRead reads[] = { | 371 MockRead reads[] = { |
| 382 MockRead(ASYNC, OK, 0) // EOF | 372 MockRead(ASYNC, OK, 0) // EOF |
| 383 }; | 373 }; |
| 384 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 374 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 385 socket_factory_.AddSocketDataProvider(&socket_data); | 375 socket_factory_.AddSocketDataProvider(&socket_data); |
| 386 socket_data.StopAfter(1); | 376 socket_data.StopAfter(1); |
| 387 | 377 |
| 388 crypto_client_stream_factory_.set_handshake_mode( | 378 crypto_client_stream_factory_.set_handshake_mode( |
| 389 MockCryptoClientStream::ZERO_RTT); | 379 MockCryptoClientStream::ZERO_RTT); |
| 390 host_resolver_.set_synchronous_mode(true); | 380 host_resolver_.set_synchronous_mode(true); |
| 391 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 381 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 392 "192.168.0.1", ""); | 382 "192.168.0.1", ""); |
| 393 | 383 |
| 394 QuicStreamRequest request(&factory_); | 384 QuicStreamRequest request(&factory_); |
| 395 EXPECT_EQ(OK, | 385 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 396 request.Request(host_port_pair_, | 386 host_port_pair_.host(), "GET", net_log_, |
| 397 is_https_, | 387 callback_.callback())); |
| 398 privacy_mode_, | |
| 399 "GET", | |
| 400 net_log_, | |
| 401 callback_.callback())); | |
| 402 | 388 |
| 403 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 389 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 404 EXPECT_TRUE(stream.get()); | 390 EXPECT_TRUE(stream.get()); |
| 405 EXPECT_TRUE(socket_data.at_read_eof()); | 391 EXPECT_TRUE(socket_data.at_read_eof()); |
| 406 EXPECT_TRUE(socket_data.at_write_eof()); | 392 EXPECT_TRUE(socket_data.at_write_eof()); |
| 407 } | 393 } |
| 408 | 394 |
| 409 TEST_P(QuicStreamFactoryTest, CreateZeroRttPost) { | 395 TEST_P(QuicStreamFactoryTest, CreateZeroRttPost) { |
| 410 MockRead reads[] = { | 396 MockRead reads[] = { |
| 411 MockRead(ASYNC, OK, 0) // EOF | 397 MockRead(ASYNC, OK, 0) // EOF |
| 412 }; | 398 }; |
| 413 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 399 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 414 socket_factory_.AddSocketDataProvider(&socket_data); | 400 socket_factory_.AddSocketDataProvider(&socket_data); |
| 415 socket_data.StopAfter(1); | 401 socket_data.StopAfter(1); |
| 416 | 402 |
| 417 crypto_client_stream_factory_.set_handshake_mode( | 403 crypto_client_stream_factory_.set_handshake_mode( |
| 418 MockCryptoClientStream::ZERO_RTT); | 404 MockCryptoClientStream::ZERO_RTT); |
| 419 host_resolver_.set_synchronous_mode(true); | 405 host_resolver_.set_synchronous_mode(true); |
| 420 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 406 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 421 "192.168.0.1", ""); | 407 "192.168.0.1", ""); |
| 422 | 408 |
| 423 QuicStreamRequest request(&factory_); | 409 QuicStreamRequest request(&factory_); |
| 424 // Posts require handshake confirmation, so this will return asynchronously. | 410 // Posts require handshake confirmation, so this will return asynchronously. |
| 425 EXPECT_EQ(ERR_IO_PENDING, | 411 EXPECT_EQ(ERR_IO_PENDING, |
| 426 request.Request(host_port_pair_, | 412 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 427 is_https_, | 413 host_port_pair_.host(), "POST", net_log_, |
| 428 privacy_mode_, | |
| 429 "POST", | |
| 430 net_log_, | |
| 431 callback_.callback())); | 414 callback_.callback())); |
| 432 | 415 |
| 433 // Confirm the handshake and verify that the stream is created. | 416 // Confirm the handshake and verify that the stream is created. |
| 434 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( | 417 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( |
| 435 QuicSession::HANDSHAKE_CONFIRMED); | 418 QuicSession::HANDSHAKE_CONFIRMED); |
| 436 | 419 |
| 437 EXPECT_EQ(OK, callback_.WaitForResult()); | 420 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 438 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 421 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 439 EXPECT_TRUE(stream.get()); | 422 EXPECT_TRUE(stream.get()); |
| 440 EXPECT_TRUE(socket_data.at_read_eof()); | 423 EXPECT_TRUE(socket_data.at_read_eof()); |
| 441 EXPECT_TRUE(socket_data.at_write_eof()); | 424 EXPECT_TRUE(socket_data.at_write_eof()); |
| 442 } | 425 } |
| 443 | 426 |
| 427 class ZeroRttDependsOnWhetherSameHostTest : public QuicStreamFactoryTest { | |
| 428 public: | |
| 429 void Run(bool same_host) { | |
| 430 MockRead reads[] = { | |
| 431 MockRead(ASYNC, OK, 0), | |
| 432 }; | |
| 433 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | |
| 434 socket_factory_.AddSocketDataProvider(&socket_data); | |
| 435 socket_data.StopAfter(1); | |
| 436 | |
| 437 crypto_client_stream_factory_.set_handshake_mode( | |
| 438 MockCryptoClientStream::ZERO_RTT); | |
| 439 host_resolver_.set_synchronous_mode(true); | |
| 440 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | |
| 441 "192.168.0.1", ""); | |
| 442 | |
| 443 std::string origin_host = | |
| 444 same_host ? host_port_pair_.host() : "different.host.example.com"; | |
| 445 QuicStreamRequest request(&factory_); | |
| 446 int rv = | |
| 447 request.Request(host_port_pair_, is_https_, privacy_mode_, origin_host, | |
| 448 "GET", net_log_, callback_.callback()); | |
| 449 if (same_host) { | |
| 450 EXPECT_EQ(OK, rv); | |
| 451 } else { | |
| 452 // If server and origin have different hostnames, handshake confirmation | |
| 453 // should be required, so this will return asynchronously. | |
| 454 EXPECT_EQ(ERR_IO_PENDING, rv); | |
| 455 // Confirm handshake. | |
| 456 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( | |
| 457 QuicSession::HANDSHAKE_CONFIRMED); | |
| 458 EXPECT_EQ(OK, callback_.WaitForResult()); | |
| 459 } | |
| 460 | |
| 461 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | |
| 462 EXPECT_TRUE(stream.get()); | |
| 463 EXPECT_TRUE(socket_data.at_read_eof()); | |
| 464 EXPECT_TRUE(socket_data.at_write_eof()); | |
| 465 } | |
| 466 }; | |
| 467 | |
| 468 INSTANTIATE_TEST_CASE_P(Version, | |
| 469 ZeroRttDependsOnWhetherSameHostTest, | |
| 470 ::testing::ValuesIn(GetTestParams())); | |
| 471 | |
| 472 TEST_P(ZeroRttDependsOnWhetherSameHostTest, SameHostEnabled) { | |
| 473 Run(true); | |
|
Ryan Hamilton
2015/05/18 14:29:52
How does this test differ from CreateZeroRtt? (I t
Bence
2015/05/18 15:17:55
I agree, it doesn't.
| |
| 474 } | |
| 475 | |
| 476 TEST_P(ZeroRttDependsOnWhetherSameHostTest, DifferentHostDisabled) { | |
| 477 Run(false); | |
|
Ryan Hamilton
2015/05/18 14:29:52
Just inline the run method.
Bence
2015/05/18 15:17:55
How about removing the CreateZeroRtt test and keep
Ryan Hamilton
2015/05/18 16:21:55
In general, it's preferable to avoid logic in test
Bence
2015/05/18 18:12:02
Fair enough. I sometimes have difficulties findin
| |
| 478 } | |
| 479 | |
| 444 TEST_P(QuicStreamFactoryTest, CreateHttpVsHttps) { | 480 TEST_P(QuicStreamFactoryTest, CreateHttpVsHttps) { |
| 445 MockRead reads[] = { | 481 MockRead reads[] = { |
| 446 MockRead(ASYNC, OK, 0) // EOF | 482 MockRead(ASYNC, OK, 0) // EOF |
| 447 }; | 483 }; |
| 448 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); | 484 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); |
| 449 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | 485 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 450 socket_factory_.AddSocketDataProvider(&socket_data1); | 486 socket_factory_.AddSocketDataProvider(&socket_data1); |
| 451 socket_factory_.AddSocketDataProvider(&socket_data2); | 487 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 452 socket_data1.StopAfter(1); | 488 socket_data1.StopAfter(1); |
| 453 socket_data2.StopAfter(1); | 489 socket_data2.StopAfter(1); |
| 454 | 490 |
| 455 QuicStreamRequest request(&factory_); | 491 QuicStreamRequest request(&factory_); |
| 456 EXPECT_EQ(ERR_IO_PENDING, | 492 EXPECT_EQ(ERR_IO_PENDING, |
| 457 request.Request(host_port_pair_, | 493 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 458 is_https_, | 494 host_port_pair_.host(), "GET", net_log_, |
| 459 privacy_mode_, | |
| 460 "GET", | |
| 461 net_log_, | |
| 462 callback_.callback())); | 495 callback_.callback())); |
| 463 | 496 |
| 464 EXPECT_EQ(OK, callback_.WaitForResult()); | 497 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 465 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 498 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 466 EXPECT_TRUE(stream.get()); | 499 EXPECT_TRUE(stream.get()); |
| 467 | 500 |
| 468 QuicStreamRequest request2(&factory_); | 501 QuicStreamRequest request2(&factory_); |
| 469 EXPECT_EQ(ERR_IO_PENDING, | 502 EXPECT_EQ(ERR_IO_PENDING, |
| 470 request2.Request(host_port_pair_, | 503 request2.Request(host_port_pair_, !is_https_, privacy_mode_, |
| 471 !is_https_, | 504 host_port_pair_.host(), "GET", net_log_, |
| 472 privacy_mode_, | |
| 473 "GET", | |
| 474 net_log_, | |
| 475 callback_.callback())); | 505 callback_.callback())); |
| 476 EXPECT_EQ(OK, callback_.WaitForResult()); | 506 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 477 stream = request2.ReleaseStream(); | 507 stream = request2.ReleaseStream(); |
| 478 EXPECT_TRUE(stream.get()); | 508 EXPECT_TRUE(stream.get()); |
| 479 stream.reset(); | 509 stream.reset(); |
| 480 | 510 |
| 481 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 511 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 482 &factory_, host_port_pair_, is_https_), | 512 &factory_, host_port_pair_, is_https_), |
| 483 QuicStreamFactoryPeer::GetActiveSession( | 513 QuicStreamFactoryPeer::GetActiveSession( |
| 484 &factory_, host_port_pair_, !is_https_)); | 514 &factory_, host_port_pair_, !is_https_)); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 498 socket_data.StopAfter(1); | 528 socket_data.StopAfter(1); |
| 499 | 529 |
| 500 HostPortPair server2("mail.google.com", kDefaultServerPort); | 530 HostPortPair server2("mail.google.com", kDefaultServerPort); |
| 501 host_resolver_.set_synchronous_mode(true); | 531 host_resolver_.set_synchronous_mode(true); |
| 502 host_resolver_.rules()->AddIPLiteralRule( | 532 host_resolver_.rules()->AddIPLiteralRule( |
| 503 kDefaultServerHostName, "192.168.0.1", ""); | 533 kDefaultServerHostName, "192.168.0.1", ""); |
| 504 host_resolver_.rules()->AddIPLiteralRule( | 534 host_resolver_.rules()->AddIPLiteralRule( |
| 505 "mail.google.com", "192.168.0.1", ""); | 535 "mail.google.com", "192.168.0.1", ""); |
| 506 | 536 |
| 507 QuicStreamRequest request(&factory_); | 537 QuicStreamRequest request(&factory_); |
| 508 EXPECT_EQ(OK, | 538 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 509 request.Request(host_port_pair_, | 539 host_port_pair_.host(), "GET", net_log_, |
| 510 is_https_, | 540 callback_.callback())); |
| 511 privacy_mode_, | |
| 512 "GET", | |
| 513 net_log_, | |
| 514 callback_.callback())); | |
| 515 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 541 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 516 EXPECT_TRUE(stream.get()); | 542 EXPECT_TRUE(stream.get()); |
| 517 | 543 |
| 518 TestCompletionCallback callback; | 544 TestCompletionCallback callback; |
| 519 QuicStreamRequest request2(&factory_); | 545 QuicStreamRequest request2(&factory_); |
| 520 EXPECT_EQ(OK, | 546 EXPECT_EQ(OK, |
| 521 request2.Request(server2, | 547 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 522 is_https_, | 548 "GET", net_log_, callback.callback())); |
| 523 privacy_mode_, | |
| 524 "GET", | |
| 525 net_log_, | |
| 526 callback.callback())); | |
| 527 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 549 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 528 EXPECT_TRUE(stream2.get()); | 550 EXPECT_TRUE(stream2.get()); |
| 529 | 551 |
| 530 EXPECT_EQ( | 552 EXPECT_EQ( |
| 531 QuicStreamFactoryPeer::GetActiveSession( | 553 QuicStreamFactoryPeer::GetActiveSession( |
| 532 &factory_, host_port_pair_, is_https_), | 554 &factory_, host_port_pair_, is_https_), |
| 533 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); | 555 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); |
| 534 | 556 |
| 535 EXPECT_TRUE(socket_data.at_read_eof()); | 557 EXPECT_TRUE(socket_data.at_read_eof()); |
| 536 EXPECT_TRUE(socket_data.at_write_eof()); | 558 EXPECT_TRUE(socket_data.at_write_eof()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 551 host_resolver_.set_synchronous_mode(true); | 573 host_resolver_.set_synchronous_mode(true); |
| 552 host_resolver_.rules()->AddIPLiteralRule( | 574 host_resolver_.rules()->AddIPLiteralRule( |
| 553 kDefaultServerHostName, "192.168.0.1", ""); | 575 kDefaultServerHostName, "192.168.0.1", ""); |
| 554 host_resolver_.rules()->AddIPLiteralRule( | 576 host_resolver_.rules()->AddIPLiteralRule( |
| 555 "mail.google.com", "192.168.0.1", ""); | 577 "mail.google.com", "192.168.0.1", ""); |
| 556 | 578 |
| 557 // Disable connection pooling. | 579 // Disable connection pooling. |
| 558 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 580 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 559 | 581 |
| 560 QuicStreamRequest request(&factory_); | 582 QuicStreamRequest request(&factory_); |
| 561 EXPECT_EQ(OK, | 583 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 562 request.Request(host_port_pair_, | 584 host_port_pair_.host(), "GET", net_log_, |
| 563 is_https_, | 585 callback_.callback())); |
| 564 privacy_mode_, | |
| 565 "GET", | |
| 566 net_log_, | |
| 567 callback_.callback())); | |
| 568 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 586 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 569 EXPECT_TRUE(stream.get()); | 587 EXPECT_TRUE(stream.get()); |
| 570 | 588 |
| 571 TestCompletionCallback callback; | 589 TestCompletionCallback callback; |
| 572 QuicStreamRequest request2(&factory_); | 590 QuicStreamRequest request2(&factory_); |
| 573 EXPECT_EQ(OK, | 591 EXPECT_EQ(OK, |
| 574 request2.Request(server2, | 592 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 575 is_https_, | 593 "GET", net_log_, callback.callback())); |
| 576 privacy_mode_, | |
| 577 "GET", | |
| 578 net_log_, | |
| 579 callback.callback())); | |
| 580 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 594 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 581 EXPECT_TRUE(stream2.get()); | 595 EXPECT_TRUE(stream2.get()); |
| 582 | 596 |
| 583 EXPECT_NE( | 597 EXPECT_NE( |
| 584 QuicStreamFactoryPeer::GetActiveSession( | 598 QuicStreamFactoryPeer::GetActiveSession( |
| 585 &factory_, host_port_pair_, is_https_), | 599 &factory_, host_port_pair_, is_https_), |
| 586 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); | 600 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); |
| 587 | 601 |
| 588 EXPECT_TRUE(socket_data1.at_read_eof()); | 602 EXPECT_TRUE(socket_data1.at_read_eof()); |
| 589 EXPECT_TRUE(socket_data1.at_write_eof()); | 603 EXPECT_TRUE(socket_data1.at_write_eof()); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 603 socket_data2.StopAfter(1); | 617 socket_data2.StopAfter(1); |
| 604 | 618 |
| 605 HostPortPair server2("mail.google.com", kDefaultServerPort); | 619 HostPortPair server2("mail.google.com", kDefaultServerPort); |
| 606 host_resolver_.set_synchronous_mode(true); | 620 host_resolver_.set_synchronous_mode(true); |
| 607 host_resolver_.rules()->AddIPLiteralRule( | 621 host_resolver_.rules()->AddIPLiteralRule( |
| 608 kDefaultServerHostName, "192.168.0.1", ""); | 622 kDefaultServerHostName, "192.168.0.1", ""); |
| 609 host_resolver_.rules()->AddIPLiteralRule( | 623 host_resolver_.rules()->AddIPLiteralRule( |
| 610 "mail.google.com", "192.168.0.1", ""); | 624 "mail.google.com", "192.168.0.1", ""); |
| 611 | 625 |
| 612 QuicStreamRequest request(&factory_); | 626 QuicStreamRequest request(&factory_); |
| 613 EXPECT_EQ(OK, | 627 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 614 request.Request(host_port_pair_, | 628 host_port_pair_.host(), "GET", net_log_, |
| 615 is_https_, | 629 callback_.callback())); |
| 616 privacy_mode_, | |
| 617 "GET", | |
| 618 net_log_, | |
| 619 callback_.callback())); | |
| 620 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 630 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 621 EXPECT_TRUE(stream.get()); | 631 EXPECT_TRUE(stream.get()); |
| 622 | 632 |
| 623 TestCompletionCallback callback; | 633 TestCompletionCallback callback; |
| 624 QuicStreamRequest request2(&factory_); | 634 QuicStreamRequest request2(&factory_); |
| 625 EXPECT_EQ(OK, | 635 EXPECT_EQ(OK, |
| 626 request2.Request(server2, | 636 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 627 is_https_, | 637 "GET", net_log_, callback.callback())); |
| 628 privacy_mode_, | |
| 629 "GET", | |
| 630 net_log_, | |
| 631 callback.callback())); | |
| 632 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 638 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 633 EXPECT_TRUE(stream2.get()); | 639 EXPECT_TRUE(stream2.get()); |
| 634 | 640 |
| 635 factory_.OnSessionGoingAway(QuicStreamFactoryPeer::GetActiveSession( | 641 factory_.OnSessionGoingAway(QuicStreamFactoryPeer::GetActiveSession( |
| 636 &factory_, host_port_pair_, is_https_)); | 642 &factory_, host_port_pair_, is_https_)); |
| 637 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 643 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( |
| 638 &factory_, host_port_pair_, is_https_)); | 644 &factory_, host_port_pair_, is_https_)); |
| 639 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 645 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( |
| 640 &factory_, server2, is_https_)); | 646 &factory_, server2, is_https_)); |
| 641 | 647 |
| 642 TestCompletionCallback callback3; | 648 TestCompletionCallback callback3; |
| 643 QuicStreamRequest request3(&factory_); | 649 QuicStreamRequest request3(&factory_); |
| 644 EXPECT_EQ(OK, | 650 EXPECT_EQ(OK, |
| 645 request3.Request(server2, | 651 request3.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 646 is_https_, | 652 "GET", net_log_, callback3.callback())); |
| 647 privacy_mode_, | |
| 648 "GET", | |
| 649 net_log_, | |
| 650 callback3.callback())); | |
| 651 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 653 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
| 652 EXPECT_TRUE(stream3.get()); | 654 EXPECT_TRUE(stream3.get()); |
| 653 | 655 |
| 654 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( | 656 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( |
| 655 &factory_, server2, is_https_)); | 657 &factory_, server2, is_https_)); |
| 656 | 658 |
| 657 EXPECT_TRUE(socket_data1.at_read_eof()); | 659 EXPECT_TRUE(socket_data1.at_read_eof()); |
| 658 EXPECT_TRUE(socket_data1.at_write_eof()); | 660 EXPECT_TRUE(socket_data1.at_write_eof()); |
| 659 EXPECT_TRUE(socket_data2.at_read_eof()); | 661 EXPECT_TRUE(socket_data2.at_read_eof()); |
| 660 EXPECT_TRUE(socket_data2.at_write_eof()); | 662 EXPECT_TRUE(socket_data2.at_write_eof()); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 684 verify_details.cert_verify_result.is_issued_by_known_root = true; | 686 verify_details.cert_verify_result.is_issued_by_known_root = true; |
| 685 crypto_client_stream_factory_.set_proof_verify_details(&verify_details); | 687 crypto_client_stream_factory_.set_proof_verify_details(&verify_details); |
| 686 | 688 |
| 687 host_resolver_.set_synchronous_mode(true); | 689 host_resolver_.set_synchronous_mode(true); |
| 688 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 690 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 689 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 691 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 690 | 692 |
| 691 QuicStreamRequest request(&factory_); | 693 QuicStreamRequest request(&factory_); |
| 692 is_https_ = true; | 694 is_https_ = true; |
| 693 EXPECT_EQ(OK, | 695 EXPECT_EQ(OK, |
| 694 request.Request(server1, | 696 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 695 is_https_, | 697 "GET", net_log_, callback_.callback())); |
| 696 privacy_mode_, | |
| 697 "GET", | |
| 698 net_log_, | |
| 699 callback_.callback())); | |
| 700 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 698 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 701 EXPECT_TRUE(stream.get()); | 699 EXPECT_TRUE(stream.get()); |
| 702 | 700 |
| 703 TestCompletionCallback callback; | 701 TestCompletionCallback callback; |
| 704 QuicStreamRequest request2(&factory_); | 702 QuicStreamRequest request2(&factory_); |
| 705 EXPECT_EQ(OK, | 703 EXPECT_EQ(OK, |
| 706 request2.Request(server2, | 704 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 707 is_https_, | 705 "GET", net_log_, callback_.callback())); |
| 708 privacy_mode_, | |
| 709 "GET", | |
| 710 net_log_, | |
| 711 callback_.callback())); | |
| 712 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 706 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 713 EXPECT_TRUE(stream2.get()); | 707 EXPECT_TRUE(stream2.get()); |
| 714 | 708 |
| 715 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( | 709 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( |
| 716 &factory_, server1, is_https_), | 710 &factory_, server1, is_https_), |
| 717 QuicStreamFactoryPeer::GetActiveSession( | 711 QuicStreamFactoryPeer::GetActiveSession( |
| 718 &factory_, server2, is_https_)); | 712 &factory_, server2, is_https_)); |
| 719 | 713 |
| 720 EXPECT_TRUE(socket_data.at_read_eof()); | 714 EXPECT_TRUE(socket_data.at_read_eof()); |
| 721 EXPECT_TRUE(socket_data.at_write_eof()); | 715 EXPECT_TRUE(socket_data.at_write_eof()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 751 host_resolver_.set_synchronous_mode(true); | 745 host_resolver_.set_synchronous_mode(true); |
| 752 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 746 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 753 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 747 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 754 | 748 |
| 755 // Disable connection pooling. | 749 // Disable connection pooling. |
| 756 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 750 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 757 | 751 |
| 758 QuicStreamRequest request(&factory_); | 752 QuicStreamRequest request(&factory_); |
| 759 is_https_ = true; | 753 is_https_ = true; |
| 760 EXPECT_EQ(OK, | 754 EXPECT_EQ(OK, |
| 761 request.Request(server1, | 755 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 762 is_https_, | 756 "GET", net_log_, callback_.callback())); |
| 763 privacy_mode_, | |
| 764 "GET", | |
| 765 net_log_, | |
| 766 callback_.callback())); | |
| 767 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 757 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 768 EXPECT_TRUE(stream.get()); | 758 EXPECT_TRUE(stream.get()); |
| 769 | 759 |
| 770 TestCompletionCallback callback; | 760 TestCompletionCallback callback; |
| 771 QuicStreamRequest request2(&factory_); | 761 QuicStreamRequest request2(&factory_); |
| 772 EXPECT_EQ(OK, | 762 EXPECT_EQ(OK, |
| 773 request2.Request(server2, | 763 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 774 is_https_, | 764 "GET", net_log_, callback_.callback())); |
| 775 privacy_mode_, | |
| 776 "GET", | |
| 777 net_log_, | |
| 778 callback_.callback())); | |
| 779 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 765 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 780 EXPECT_TRUE(stream2.get()); | 766 EXPECT_TRUE(stream2.get()); |
| 781 | 767 |
| 782 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 768 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 783 &factory_, server1, is_https_), | 769 &factory_, server1, is_https_), |
| 784 QuicStreamFactoryPeer::GetActiveSession( | 770 QuicStreamFactoryPeer::GetActiveSession( |
| 785 &factory_, server2, is_https_)); | 771 &factory_, server2, is_https_)); |
| 786 | 772 |
| 787 EXPECT_TRUE(socket_data1.at_read_eof()); | 773 EXPECT_TRUE(socket_data1.at_read_eof()); |
| 788 EXPECT_TRUE(socket_data1.at_write_eof()); | 774 EXPECT_TRUE(socket_data1.at_write_eof()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 818 crypto_client_stream_factory_.set_proof_verify_details(&verify_details); | 804 crypto_client_stream_factory_.set_proof_verify_details(&verify_details); |
| 819 | 805 |
| 820 | 806 |
| 821 host_resolver_.set_synchronous_mode(true); | 807 host_resolver_.set_synchronous_mode(true); |
| 822 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 808 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 823 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 809 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 824 | 810 |
| 825 QuicStreamRequest request(&factory_); | 811 QuicStreamRequest request(&factory_); |
| 826 is_https_ = true; | 812 is_https_ = true; |
| 827 EXPECT_EQ(OK, | 813 EXPECT_EQ(OK, |
| 828 request.Request(server1, | 814 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 829 is_https_, | 815 "GET", net_log_, callback_.callback())); |
| 830 privacy_mode_, | |
| 831 "GET", | |
| 832 net_log_, | |
| 833 callback_.callback())); | |
| 834 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 816 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 835 EXPECT_TRUE(stream.get()); | 817 EXPECT_TRUE(stream.get()); |
| 836 | 818 |
| 837 TestCompletionCallback callback; | 819 TestCompletionCallback callback; |
| 838 QuicStreamRequest request2(&factory_); | 820 QuicStreamRequest request2(&factory_); |
| 839 EXPECT_EQ(OK, | 821 EXPECT_EQ(OK, |
| 840 request2.Request(server2, | 822 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 841 is_https_, | 823 "GET", net_log_, callback_.callback())); |
| 842 privacy_mode_, | |
| 843 "GET", | |
| 844 net_log_, | |
| 845 callback_.callback())); | |
| 846 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 824 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 847 EXPECT_TRUE(stream2.get()); | 825 EXPECT_TRUE(stream2.get()); |
| 848 | 826 |
| 849 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 827 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 850 &factory_, server1, is_https_), | 828 &factory_, server1, is_https_), |
| 851 QuicStreamFactoryPeer::GetActiveSession( | 829 QuicStreamFactoryPeer::GetActiveSession( |
| 852 &factory_, server2, is_https_)); | 830 &factory_, server2, is_https_)); |
| 853 | 831 |
| 854 EXPECT_TRUE(socket_data1.at_read_eof()); | 832 EXPECT_TRUE(socket_data1.at_read_eof()); |
| 855 EXPECT_TRUE(socket_data1.at_write_eof()); | 833 EXPECT_TRUE(socket_data1.at_write_eof()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 crypto_client_stream_factory_.set_proof_verify_details(&verify_details); | 865 crypto_client_stream_factory_.set_proof_verify_details(&verify_details); |
| 888 | 866 |
| 889 | 867 |
| 890 host_resolver_.set_synchronous_mode(true); | 868 host_resolver_.set_synchronous_mode(true); |
| 891 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 869 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 892 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 870 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 893 | 871 |
| 894 QuicStreamRequest request(&factory_); | 872 QuicStreamRequest request(&factory_); |
| 895 is_https_ = true; | 873 is_https_ = true; |
| 896 EXPECT_EQ(OK, | 874 EXPECT_EQ(OK, |
| 897 request.Request(server1, | 875 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 898 is_https_, | 876 "GET", net_log_, callback_.callback())); |
| 899 privacy_mode_, | |
| 900 "GET", | |
| 901 net_log_, | |
| 902 callback_.callback())); | |
| 903 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 877 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 904 EXPECT_TRUE(stream.get()); | 878 EXPECT_TRUE(stream.get()); |
| 905 | 879 |
| 906 TestCompletionCallback callback; | 880 TestCompletionCallback callback; |
| 907 QuicStreamRequest request2(&factory_); | 881 QuicStreamRequest request2(&factory_); |
| 908 EXPECT_EQ(OK, | 882 EXPECT_EQ(OK, |
| 909 request2.Request(server2, | 883 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 910 is_https_, | 884 "GET", net_log_, callback_.callback())); |
| 911 privacy_mode_, | |
| 912 "GET", | |
| 913 net_log_, | |
| 914 callback_.callback())); | |
| 915 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 885 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 916 EXPECT_TRUE(stream2.get()); | 886 EXPECT_TRUE(stream2.get()); |
| 917 | 887 |
| 918 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( | 888 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( |
| 919 &factory_, server1, is_https_), | 889 &factory_, server1, is_https_), |
| 920 QuicStreamFactoryPeer::GetActiveSession( | 890 QuicStreamFactoryPeer::GetActiveSession( |
| 921 &factory_, server2, is_https_)); | 891 &factory_, server2, is_https_)); |
| 922 | 892 |
| 923 EXPECT_TRUE(socket_data.at_read_eof()); | 893 EXPECT_TRUE(socket_data.at_read_eof()); |
| 924 EXPECT_TRUE(socket_data.at_write_eof()); | 894 EXPECT_TRUE(socket_data.at_write_eof()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 960 host_resolver_.set_synchronous_mode(true); | 930 host_resolver_.set_synchronous_mode(true); |
| 961 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 931 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 962 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 932 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 963 | 933 |
| 964 // Disable connection pooling. | 934 // Disable connection pooling. |
| 965 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 935 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 966 | 936 |
| 967 QuicStreamRequest request(&factory_); | 937 QuicStreamRequest request(&factory_); |
| 968 is_https_ = true; | 938 is_https_ = true; |
| 969 EXPECT_EQ(OK, | 939 EXPECT_EQ(OK, |
| 970 request.Request(server1, | 940 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 971 is_https_, | 941 "GET", net_log_, callback_.callback())); |
| 972 privacy_mode_, | |
| 973 "GET", | |
| 974 net_log_, | |
| 975 callback_.callback())); | |
| 976 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 942 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 977 EXPECT_TRUE(stream.get()); | 943 EXPECT_TRUE(stream.get()); |
| 978 | 944 |
| 979 TestCompletionCallback callback; | 945 TestCompletionCallback callback; |
| 980 QuicStreamRequest request2(&factory_); | 946 QuicStreamRequest request2(&factory_); |
| 981 EXPECT_EQ(OK, | 947 EXPECT_EQ(OK, |
| 982 request2.Request(server2, | 948 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 983 is_https_, | 949 "GET", net_log_, callback_.callback())); |
| 984 privacy_mode_, | |
| 985 "GET", | |
| 986 net_log_, | |
| 987 callback_.callback())); | |
| 988 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 950 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 989 EXPECT_TRUE(stream2.get()); | 951 EXPECT_TRUE(stream2.get()); |
| 990 | 952 |
| 991 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 953 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 992 &factory_, server1, is_https_), | 954 &factory_, server1, is_https_), |
| 993 QuicStreamFactoryPeer::GetActiveSession( | 955 QuicStreamFactoryPeer::GetActiveSession( |
| 994 &factory_, server2, is_https_)); | 956 &factory_, server2, is_https_)); |
| 995 | 957 |
| 996 EXPECT_TRUE(socket_data1.at_read_eof()); | 958 EXPECT_TRUE(socket_data1.at_read_eof()); |
| 997 EXPECT_TRUE(socket_data1.at_write_eof()); | 959 EXPECT_TRUE(socket_data1.at_write_eof()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 crypto_client_stream_factory_.set_proof_verify_details(&verify_details); | 995 crypto_client_stream_factory_.set_proof_verify_details(&verify_details); |
| 1034 | 996 |
| 1035 | 997 |
| 1036 host_resolver_.set_synchronous_mode(true); | 998 host_resolver_.set_synchronous_mode(true); |
| 1037 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 999 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 1038 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 1000 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1039 | 1001 |
| 1040 QuicStreamRequest request(&factory_); | 1002 QuicStreamRequest request(&factory_); |
| 1041 is_https_ = true; | 1003 is_https_ = true; |
| 1042 EXPECT_EQ(OK, | 1004 EXPECT_EQ(OK, |
| 1043 request.Request(server1, | 1005 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 1044 is_https_, | 1006 "GET", net_log_, callback_.callback())); |
| 1045 privacy_mode_, | |
| 1046 "GET", | |
| 1047 net_log_, | |
| 1048 callback_.callback())); | |
| 1049 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1007 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1050 EXPECT_TRUE(stream.get()); | 1008 EXPECT_TRUE(stream.get()); |
| 1051 | 1009 |
| 1052 TestCompletionCallback callback; | 1010 TestCompletionCallback callback; |
| 1053 QuicStreamRequest request2(&factory_); | 1011 QuicStreamRequest request2(&factory_); |
| 1054 EXPECT_EQ(OK, | 1012 EXPECT_EQ(OK, |
| 1055 request2.Request(server2, | 1013 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 1056 is_https_, | 1014 "GET", net_log_, callback_.callback())); |
| 1057 privacy_mode_, | |
| 1058 "GET", | |
| 1059 net_log_, | |
| 1060 callback_.callback())); | |
| 1061 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1015 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1062 EXPECT_TRUE(stream2.get()); | 1016 EXPECT_TRUE(stream2.get()); |
| 1063 | 1017 |
| 1064 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 1018 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 1065 &factory_, server1, is_https_), | 1019 &factory_, server1, is_https_), |
| 1066 QuicStreamFactoryPeer::GetActiveSession( | 1020 QuicStreamFactoryPeer::GetActiveSession( |
| 1067 &factory_, server2, is_https_)); | 1021 &factory_, server2, is_https_)); |
| 1068 | 1022 |
| 1069 EXPECT_TRUE(socket_data1.at_read_eof()); | 1023 EXPECT_TRUE(socket_data1.at_read_eof()); |
| 1070 EXPECT_TRUE(socket_data1.at_write_eof()); | 1024 EXPECT_TRUE(socket_data1.at_write_eof()); |
| 1071 EXPECT_TRUE(socket_data2.at_read_eof()); | 1025 EXPECT_TRUE(socket_data2.at_read_eof()); |
| 1072 EXPECT_TRUE(socket_data2.at_write_eof()); | 1026 EXPECT_TRUE(socket_data2.at_write_eof()); |
| 1073 } | 1027 } |
| 1074 | 1028 |
| 1075 TEST_P(QuicStreamFactoryTest, Goaway) { | 1029 TEST_P(QuicStreamFactoryTest, Goaway) { |
| 1076 MockRead reads[] = { | 1030 MockRead reads[] = { |
| 1077 MockRead(ASYNC, OK, 0) // EOF | 1031 MockRead(ASYNC, OK, 0) // EOF |
| 1078 }; | 1032 }; |
| 1079 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 1033 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 1080 socket_data.StopAfter(1); | 1034 socket_data.StopAfter(1); |
| 1081 socket_factory_.AddSocketDataProvider(&socket_data); | 1035 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1082 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | 1036 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 1083 socket_data2.StopAfter(1); | 1037 socket_data2.StopAfter(1); |
| 1084 socket_factory_.AddSocketDataProvider(&socket_data2); | 1038 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1085 | 1039 |
| 1086 QuicStreamRequest request(&factory_); | 1040 QuicStreamRequest request(&factory_); |
| 1087 EXPECT_EQ(ERR_IO_PENDING, | 1041 EXPECT_EQ(ERR_IO_PENDING, |
| 1088 request.Request(host_port_pair_, | 1042 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1089 is_https_, | 1043 host_port_pair_.host(), "GET", net_log_, |
| 1090 privacy_mode_, | |
| 1091 "GET", | |
| 1092 net_log_, | |
| 1093 callback_.callback())); | 1044 callback_.callback())); |
| 1094 | 1045 |
| 1095 EXPECT_EQ(OK, callback_.WaitForResult()); | 1046 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1096 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1047 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1097 EXPECT_TRUE(stream.get()); | 1048 EXPECT_TRUE(stream.get()); |
| 1098 | 1049 |
| 1099 // Mark the session as going away. Ensure that while it is still alive | 1050 // Mark the session as going away. Ensure that while it is still alive |
| 1100 // that it is no longer active. | 1051 // that it is no longer active. |
| 1101 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1052 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( |
| 1102 &factory_, host_port_pair_, is_https_); | 1053 &factory_, host_port_pair_, is_https_); |
| 1103 factory_.OnSessionGoingAway(session); | 1054 factory_.OnSessionGoingAway(session); |
| 1104 EXPECT_EQ(true, QuicStreamFactoryPeer::IsLiveSession(&factory_, session)); | 1055 EXPECT_EQ(true, QuicStreamFactoryPeer::IsLiveSession(&factory_, session)); |
| 1105 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 1056 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( |
| 1106 &factory_, host_port_pair_, is_https_)); | 1057 &factory_, host_port_pair_, is_https_)); |
| 1107 EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get()); | 1058 EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get()); |
| 1108 | 1059 |
| 1109 // Create a new request for the same destination and verify that a | 1060 // Create a new request for the same destination and verify that a |
| 1110 // new session is created. | 1061 // new session is created. |
| 1111 QuicStreamRequest request2(&factory_); | 1062 QuicStreamRequest request2(&factory_); |
| 1112 EXPECT_EQ(ERR_IO_PENDING, | 1063 EXPECT_EQ(ERR_IO_PENDING, |
| 1113 request2.Request(host_port_pair_, | 1064 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1114 is_https_, | 1065 host_port_pair_.host(), "GET", net_log_, |
| 1115 privacy_mode_, | |
| 1116 "GET", | |
| 1117 net_log_, | |
| 1118 callback_.callback())); | 1066 callback_.callback())); |
| 1119 EXPECT_EQ(OK, callback_.WaitForResult()); | 1067 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1120 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1068 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1121 EXPECT_TRUE(stream2.get()); | 1069 EXPECT_TRUE(stream2.get()); |
| 1122 | 1070 |
| 1123 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(&factory_, | 1071 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(&factory_, |
| 1124 host_port_pair_, | 1072 host_port_pair_, |
| 1125 is_https_)); | 1073 is_https_)); |
| 1126 EXPECT_NE(session, | 1074 EXPECT_NE(session, |
| 1127 QuicStreamFactoryPeer::GetActiveSession( | 1075 QuicStreamFactoryPeer::GetActiveSession( |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1151 writes, arraysize(writes)); | 1099 writes, arraysize(writes)); |
| 1152 socket_factory_.AddSocketDataProvider(&socket_data); | 1100 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1153 socket_data.StopAfter(1); | 1101 socket_data.StopAfter(1); |
| 1154 | 1102 |
| 1155 HttpRequestInfo request_info; | 1103 HttpRequestInfo request_info; |
| 1156 std::vector<QuicHttpStream*> streams; | 1104 std::vector<QuicHttpStream*> streams; |
| 1157 // The MockCryptoClientStream sets max_open_streams to be | 1105 // The MockCryptoClientStream sets max_open_streams to be |
| 1158 // kDefaultMaxStreamsPerConnection / 2. | 1106 // kDefaultMaxStreamsPerConnection / 2. |
| 1159 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection / 2; i++) { | 1107 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection / 2; i++) { |
| 1160 QuicStreamRequest request(&factory_); | 1108 QuicStreamRequest request(&factory_); |
| 1161 int rv = request.Request(host_port_pair_, | 1109 int rv = request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1162 is_https_, | 1110 host_port_pair_.host(), "GET", net_log_, |
| 1163 privacy_mode_, | |
| 1164 "GET", | |
| 1165 net_log_, | |
| 1166 callback_.callback()); | 1111 callback_.callback()); |
| 1167 if (i == 0) { | 1112 if (i == 0) { |
| 1168 EXPECT_EQ(ERR_IO_PENDING, rv); | 1113 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1169 EXPECT_EQ(OK, callback_.WaitForResult()); | 1114 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1170 } else { | 1115 } else { |
| 1171 EXPECT_EQ(OK, rv); | 1116 EXPECT_EQ(OK, rv); |
| 1172 } | 1117 } |
| 1173 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1118 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1174 EXPECT_TRUE(stream); | 1119 EXPECT_TRUE(stream); |
| 1175 EXPECT_EQ(OK, stream->InitializeStream( | 1120 EXPECT_EQ(OK, stream->InitializeStream( |
| 1176 &request_info, DEFAULT_PRIORITY, net_log_, CompletionCallback())); | 1121 &request_info, DEFAULT_PRIORITY, net_log_, CompletionCallback())); |
| 1177 streams.push_back(stream.release()); | 1122 streams.push_back(stream.release()); |
| 1178 } | 1123 } |
| 1179 | 1124 |
| 1180 QuicStreamRequest request(&factory_); | 1125 QuicStreamRequest request(&factory_); |
| 1181 EXPECT_EQ(OK, | 1126 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1182 request.Request(host_port_pair_, | 1127 host_port_pair_.host(), "GET", net_log_, |
| 1183 is_https_, | 1128 CompletionCallback())); |
| 1184 privacy_mode_, | |
| 1185 "GET", | |
| 1186 net_log_, | |
| 1187 CompletionCallback())); | |
| 1188 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1129 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1189 EXPECT_TRUE(stream); | 1130 EXPECT_TRUE(stream); |
| 1190 EXPECT_EQ(ERR_IO_PENDING, stream->InitializeStream( | 1131 EXPECT_EQ(ERR_IO_PENDING, stream->InitializeStream( |
| 1191 &request_info, DEFAULT_PRIORITY, net_log_, callback_.callback())); | 1132 &request_info, DEFAULT_PRIORITY, net_log_, callback_.callback())); |
| 1192 | 1133 |
| 1193 // Close the first stream. | 1134 // Close the first stream. |
| 1194 streams.front()->Close(false); | 1135 streams.front()->Close(false); |
| 1195 | 1136 |
| 1196 ASSERT_TRUE(callback_.have_result()); | 1137 ASSERT_TRUE(callback_.have_result()); |
| 1197 | 1138 |
| 1198 EXPECT_EQ(OK, callback_.WaitForResult()); | 1139 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1199 | 1140 |
| 1200 EXPECT_TRUE(socket_data.at_read_eof()); | 1141 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1201 EXPECT_TRUE(socket_data.at_write_eof()); | 1142 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1202 STLDeleteElements(&streams); | 1143 STLDeleteElements(&streams); |
| 1203 } | 1144 } |
| 1204 | 1145 |
| 1205 TEST_P(QuicStreamFactoryTest, ResolutionErrorInCreate) { | 1146 TEST_P(QuicStreamFactoryTest, ResolutionErrorInCreate) { |
| 1206 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); | 1147 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); |
| 1207 socket_factory_.AddSocketDataProvider(&socket_data); | 1148 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1208 | 1149 |
| 1209 host_resolver_.rules()->AddSimulatedFailure(kDefaultServerHostName); | 1150 host_resolver_.rules()->AddSimulatedFailure(kDefaultServerHostName); |
| 1210 | 1151 |
| 1211 QuicStreamRequest request(&factory_); | 1152 QuicStreamRequest request(&factory_); |
| 1212 EXPECT_EQ(ERR_IO_PENDING, | 1153 EXPECT_EQ(ERR_IO_PENDING, |
| 1213 request.Request(host_port_pair_, | 1154 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1214 is_https_, | 1155 host_port_pair_.host(), "GET", net_log_, |
| 1215 privacy_mode_, | |
| 1216 "GET", | |
| 1217 net_log_, | |
| 1218 callback_.callback())); | 1156 callback_.callback())); |
| 1219 | 1157 |
| 1220 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); | 1158 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); |
| 1221 | 1159 |
| 1222 EXPECT_TRUE(socket_data.at_read_eof()); | 1160 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1223 EXPECT_TRUE(socket_data.at_write_eof()); | 1161 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1224 } | 1162 } |
| 1225 | 1163 |
| 1226 TEST_P(QuicStreamFactoryTest, ConnectErrorInCreate) { | 1164 TEST_P(QuicStreamFactoryTest, ConnectErrorInCreate) { |
| 1227 MockConnect connect(SYNCHRONOUS, ERR_ADDRESS_IN_USE); | 1165 MockConnect connect(SYNCHRONOUS, ERR_ADDRESS_IN_USE); |
| 1228 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); | 1166 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); |
| 1229 socket_data.set_connect_data(connect); | 1167 socket_data.set_connect_data(connect); |
| 1230 socket_factory_.AddSocketDataProvider(&socket_data); | 1168 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1231 socket_data.StopAfter(1); | 1169 socket_data.StopAfter(1); |
| 1232 | 1170 |
| 1233 QuicStreamRequest request(&factory_); | 1171 QuicStreamRequest request(&factory_); |
| 1234 EXPECT_EQ(ERR_IO_PENDING, | 1172 EXPECT_EQ(ERR_IO_PENDING, |
| 1235 request.Request(host_port_pair_, | 1173 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1236 is_https_, | 1174 host_port_pair_.host(), "GET", net_log_, |
| 1237 privacy_mode_, | |
| 1238 "GET", | |
| 1239 net_log_, | |
| 1240 callback_.callback())); | 1175 callback_.callback())); |
| 1241 | 1176 |
| 1242 EXPECT_EQ(ERR_ADDRESS_IN_USE, callback_.WaitForResult()); | 1177 EXPECT_EQ(ERR_ADDRESS_IN_USE, callback_.WaitForResult()); |
| 1243 | 1178 |
| 1244 EXPECT_TRUE(socket_data.at_read_eof()); | 1179 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1245 EXPECT_TRUE(socket_data.at_write_eof()); | 1180 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1246 } | 1181 } |
| 1247 | 1182 |
| 1248 TEST_P(QuicStreamFactoryTest, CancelCreate) { | 1183 TEST_P(QuicStreamFactoryTest, CancelCreate) { |
| 1249 MockRead reads[] = { | 1184 MockRead reads[] = { |
| 1250 MockRead(ASYNC, OK, 0) // EOF | 1185 MockRead(ASYNC, OK, 0) // EOF |
| 1251 }; | 1186 }; |
| 1252 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 1187 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 1253 socket_factory_.AddSocketDataProvider(&socket_data); | 1188 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1254 { | 1189 { |
| 1255 QuicStreamRequest request(&factory_); | 1190 QuicStreamRequest request(&factory_); |
| 1256 EXPECT_EQ(ERR_IO_PENDING, | 1191 EXPECT_EQ(ERR_IO_PENDING, |
| 1257 request.Request(host_port_pair_, | 1192 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1258 is_https_, | 1193 host_port_pair_.host(), "GET", net_log_, |
| 1259 privacy_mode_, | |
| 1260 "GET", | |
| 1261 net_log_, | |
| 1262 callback_.callback())); | 1194 callback_.callback())); |
| 1263 } | 1195 } |
| 1264 | 1196 |
| 1265 socket_data.StopAfter(1); | 1197 socket_data.StopAfter(1); |
| 1266 base::RunLoop run_loop; | 1198 base::RunLoop run_loop; |
| 1267 run_loop.RunUntilIdle(); | 1199 run_loop.RunUntilIdle(); |
| 1268 | 1200 |
| 1269 scoped_ptr<QuicHttpStream> stream( | 1201 scoped_ptr<QuicHttpStream> stream( |
| 1270 CreateIfSessionExists(host_port_pair_, net_log_)); | 1202 CreateIfSessionExists(host_port_pair_, net_log_)); |
| 1271 EXPECT_TRUE(stream.get()); | 1203 EXPECT_TRUE(stream.get()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1314 | 1246 |
| 1315 MockRead reads2[] = { | 1247 MockRead reads2[] = { |
| 1316 MockRead(ASYNC, 0, 0) // EOF | 1248 MockRead(ASYNC, 0, 0) // EOF |
| 1317 }; | 1249 }; |
| 1318 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1250 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1319 socket_factory_.AddSocketDataProvider(&socket_data2); | 1251 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1320 socket_data2.StopAfter(1); | 1252 socket_data2.StopAfter(1); |
| 1321 | 1253 |
| 1322 QuicStreamRequest request(&factory_); | 1254 QuicStreamRequest request(&factory_); |
| 1323 EXPECT_EQ(ERR_IO_PENDING, | 1255 EXPECT_EQ(ERR_IO_PENDING, |
| 1324 request.Request(host_port_pair_, | 1256 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1325 is_https_, | 1257 host_port_pair_.host(), "GET", net_log_, |
| 1326 privacy_mode_, | |
| 1327 "GET", | |
| 1328 net_log_, | |
| 1329 callback_.callback())); | 1258 callback_.callback())); |
| 1330 | 1259 |
| 1331 EXPECT_EQ(OK, callback_.WaitForResult()); | 1260 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1332 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1261 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1333 HttpRequestInfo request_info; | 1262 HttpRequestInfo request_info; |
| 1334 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1263 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1335 DEFAULT_PRIORITY, | 1264 DEFAULT_PRIORITY, |
| 1336 net_log_, CompletionCallback())); | 1265 net_log_, CompletionCallback())); |
| 1337 | 1266 |
| 1338 // Close the session and verify that stream saw the error. | 1267 // Close the session and verify that stream saw the error. |
| 1339 factory_.CloseAllSessions(ERR_INTERNET_DISCONNECTED); | 1268 factory_.CloseAllSessions(ERR_INTERNET_DISCONNECTED); |
| 1340 EXPECT_EQ(ERR_INTERNET_DISCONNECTED, | 1269 EXPECT_EQ(ERR_INTERNET_DISCONNECTED, |
| 1341 stream->ReadResponseHeaders(callback_.callback())); | 1270 stream->ReadResponseHeaders(callback_.callback())); |
| 1342 | 1271 |
| 1343 // Now attempting to request a stream to the same origin should create | 1272 // Now attempting to request a stream to the same origin should create |
| 1344 // a new session. | 1273 // a new session. |
| 1345 | 1274 |
| 1346 QuicStreamRequest request2(&factory_); | 1275 QuicStreamRequest request2(&factory_); |
| 1347 EXPECT_EQ(ERR_IO_PENDING, | 1276 EXPECT_EQ(ERR_IO_PENDING, |
| 1348 request2.Request(host_port_pair_, | 1277 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1349 is_https_, | 1278 host_port_pair_.host(), "GET", net_log_, |
| 1350 privacy_mode_, | |
| 1351 "GET", | |
| 1352 net_log_, | |
| 1353 callback_.callback())); | 1279 callback_.callback())); |
| 1354 | 1280 |
| 1355 EXPECT_EQ(OK, callback_.WaitForResult()); | 1281 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1356 stream = request2.ReleaseStream(); | 1282 stream = request2.ReleaseStream(); |
| 1357 stream.reset(); // Will reset stream 3. | 1283 stream.reset(); // Will reset stream 3. |
| 1358 | 1284 |
| 1359 EXPECT_TRUE(socket_data.at_read_eof()); | 1285 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1360 EXPECT_TRUE(socket_data.at_write_eof()); | 1286 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1361 EXPECT_TRUE(socket_data2.at_read_eof()); | 1287 EXPECT_TRUE(socket_data2.at_read_eof()); |
| 1362 EXPECT_TRUE(socket_data2.at_write_eof()); | 1288 EXPECT_TRUE(socket_data2.at_write_eof()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1377 | 1303 |
| 1378 MockRead reads2[] = { | 1304 MockRead reads2[] = { |
| 1379 MockRead(ASYNC, 0, 0) // EOF | 1305 MockRead(ASYNC, 0, 0) // EOF |
| 1380 }; | 1306 }; |
| 1381 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1307 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1382 socket_factory_.AddSocketDataProvider(&socket_data2); | 1308 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1383 socket_data2.StopAfter(1); | 1309 socket_data2.StopAfter(1); |
| 1384 | 1310 |
| 1385 QuicStreamRequest request(&factory_); | 1311 QuicStreamRequest request(&factory_); |
| 1386 EXPECT_EQ(ERR_IO_PENDING, | 1312 EXPECT_EQ(ERR_IO_PENDING, |
| 1387 request.Request(host_port_pair_, | 1313 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1388 is_https_, | 1314 host_port_pair_.host(), "GET", net_log_, |
| 1389 privacy_mode_, | |
| 1390 "GET", | |
| 1391 net_log_, | |
| 1392 callback_.callback())); | 1315 callback_.callback())); |
| 1393 | 1316 |
| 1394 EXPECT_EQ(OK, callback_.WaitForResult()); | 1317 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1395 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1318 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1396 HttpRequestInfo request_info; | 1319 HttpRequestInfo request_info; |
| 1397 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1320 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1398 DEFAULT_PRIORITY, | 1321 DEFAULT_PRIORITY, |
| 1399 net_log_, CompletionCallback())); | 1322 net_log_, CompletionCallback())); |
| 1400 | 1323 |
| 1401 // Change the IP address and verify that stream saw the error. | 1324 // Change the IP address and verify that stream saw the error. |
| 1402 factory_.OnIPAddressChanged(); | 1325 factory_.OnIPAddressChanged(); |
| 1403 EXPECT_EQ(ERR_NETWORK_CHANGED, | 1326 EXPECT_EQ(ERR_NETWORK_CHANGED, |
| 1404 stream->ReadResponseHeaders(callback_.callback())); | 1327 stream->ReadResponseHeaders(callback_.callback())); |
| 1405 EXPECT_TRUE(factory_.require_confirmation()); | 1328 EXPECT_TRUE(factory_.require_confirmation()); |
| 1406 | 1329 |
| 1407 // Now attempting to request a stream to the same origin should create | 1330 // Now attempting to request a stream to the same origin should create |
| 1408 // a new session. | 1331 // a new session. |
| 1409 | 1332 |
| 1410 QuicStreamRequest request2(&factory_); | 1333 QuicStreamRequest request2(&factory_); |
| 1411 EXPECT_EQ(ERR_IO_PENDING, | 1334 EXPECT_EQ(ERR_IO_PENDING, |
| 1412 request2.Request(host_port_pair_, | 1335 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1413 is_https_, | 1336 host_port_pair_.host(), "GET", net_log_, |
| 1414 privacy_mode_, | |
| 1415 "GET", | |
| 1416 net_log_, | |
| 1417 callback_.callback())); | 1337 callback_.callback())); |
| 1418 | 1338 |
| 1419 EXPECT_EQ(OK, callback_.WaitForResult()); | 1339 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1420 stream = request2.ReleaseStream(); | 1340 stream = request2.ReleaseStream(); |
| 1421 stream.reset(); // Will reset stream 3. | 1341 stream.reset(); // Will reset stream 3. |
| 1422 | 1342 |
| 1423 EXPECT_TRUE(socket_data.at_read_eof()); | 1343 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1424 EXPECT_TRUE(socket_data.at_write_eof()); | 1344 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1425 EXPECT_TRUE(socket_data2.at_read_eof()); | 1345 EXPECT_TRUE(socket_data2.at_read_eof()); |
| 1426 EXPECT_TRUE(socket_data2.at_write_eof()); | 1346 EXPECT_TRUE(socket_data2.at_write_eof()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1441 | 1361 |
| 1442 MockRead reads2[] = { | 1362 MockRead reads2[] = { |
| 1443 MockRead(ASYNC, 0, 0) // EOF | 1363 MockRead(ASYNC, 0, 0) // EOF |
| 1444 }; | 1364 }; |
| 1445 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1365 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1446 socket_factory_.AddSocketDataProvider(&socket_data2); | 1366 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1447 socket_data2.StopAfter(1); | 1367 socket_data2.StopAfter(1); |
| 1448 | 1368 |
| 1449 QuicStreamRequest request(&factory_); | 1369 QuicStreamRequest request(&factory_); |
| 1450 EXPECT_EQ(ERR_IO_PENDING, | 1370 EXPECT_EQ(ERR_IO_PENDING, |
| 1451 request.Request(host_port_pair_, | 1371 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1452 is_https_, | 1372 host_port_pair_.host(), "GET", net_log_, |
| 1453 privacy_mode_, | |
| 1454 "GET", | |
| 1455 net_log_, | |
| 1456 callback_.callback())); | 1373 callback_.callback())); |
| 1457 | 1374 |
| 1458 EXPECT_EQ(OK, callback_.WaitForResult()); | 1375 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1459 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1376 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1460 HttpRequestInfo request_info; | 1377 HttpRequestInfo request_info; |
| 1461 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1378 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1462 DEFAULT_PRIORITY, | 1379 DEFAULT_PRIORITY, |
| 1463 net_log_, CompletionCallback())); | 1380 net_log_, CompletionCallback())); |
| 1464 | 1381 |
| 1465 // Add a cert and verify that stream saw the event. | 1382 // Add a cert and verify that stream saw the event. |
| 1466 factory_.OnCertAdded(nullptr); | 1383 factory_.OnCertAdded(nullptr); |
| 1467 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 1384 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 1468 stream->ReadResponseHeaders(callback_.callback())); | 1385 stream->ReadResponseHeaders(callback_.callback())); |
| 1469 EXPECT_FALSE(factory_.require_confirmation()); | 1386 EXPECT_FALSE(factory_.require_confirmation()); |
| 1470 | 1387 |
| 1471 // Now attempting to request a stream to the same origin should create | 1388 // Now attempting to request a stream to the same origin should create |
| 1472 // a new session. | 1389 // a new session. |
| 1473 | 1390 |
| 1474 QuicStreamRequest request2(&factory_); | 1391 QuicStreamRequest request2(&factory_); |
| 1475 EXPECT_EQ(ERR_IO_PENDING, | 1392 EXPECT_EQ(ERR_IO_PENDING, |
| 1476 request2.Request(host_port_pair_, | 1393 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1477 is_https_, | 1394 host_port_pair_.host(), "GET", net_log_, |
| 1478 privacy_mode_, | |
| 1479 "GET", | |
| 1480 net_log_, | |
| 1481 callback_.callback())); | 1395 callback_.callback())); |
| 1482 | 1396 |
| 1483 EXPECT_EQ(OK, callback_.WaitForResult()); | 1397 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1484 stream = request2.ReleaseStream(); | 1398 stream = request2.ReleaseStream(); |
| 1485 stream.reset(); // Will reset stream 3. | 1399 stream.reset(); // Will reset stream 3. |
| 1486 | 1400 |
| 1487 EXPECT_TRUE(socket_data.at_read_eof()); | 1401 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1488 EXPECT_TRUE(socket_data.at_write_eof()); | 1402 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1489 EXPECT_TRUE(socket_data2.at_read_eof()); | 1403 EXPECT_TRUE(socket_data2.at_read_eof()); |
| 1490 EXPECT_TRUE(socket_data2.at_write_eof()); | 1404 EXPECT_TRUE(socket_data2.at_write_eof()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1505 | 1419 |
| 1506 MockRead reads2[] = { | 1420 MockRead reads2[] = { |
| 1507 MockRead(ASYNC, 0, 0) // EOF | 1421 MockRead(ASYNC, 0, 0) // EOF |
| 1508 }; | 1422 }; |
| 1509 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1423 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1510 socket_factory_.AddSocketDataProvider(&socket_data2); | 1424 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1511 socket_data2.StopAfter(1); | 1425 socket_data2.StopAfter(1); |
| 1512 | 1426 |
| 1513 QuicStreamRequest request(&factory_); | 1427 QuicStreamRequest request(&factory_); |
| 1514 EXPECT_EQ(ERR_IO_PENDING, | 1428 EXPECT_EQ(ERR_IO_PENDING, |
| 1515 request.Request(host_port_pair_, | 1429 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1516 is_https_, | 1430 host_port_pair_.host(), "GET", net_log_, |
| 1517 privacy_mode_, | |
| 1518 "GET", | |
| 1519 net_log_, | |
| 1520 callback_.callback())); | 1431 callback_.callback())); |
| 1521 | 1432 |
| 1522 EXPECT_EQ(OK, callback_.WaitForResult()); | 1433 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1523 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1434 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1524 HttpRequestInfo request_info; | 1435 HttpRequestInfo request_info; |
| 1525 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1436 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1526 DEFAULT_PRIORITY, | 1437 DEFAULT_PRIORITY, |
| 1527 net_log_, CompletionCallback())); | 1438 net_log_, CompletionCallback())); |
| 1528 | 1439 |
| 1529 // Change the CA cert and verify that stream saw the event. | 1440 // Change the CA cert and verify that stream saw the event. |
| 1530 factory_.OnCACertChanged(nullptr); | 1441 factory_.OnCACertChanged(nullptr); |
| 1531 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 1442 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 1532 stream->ReadResponseHeaders(callback_.callback())); | 1443 stream->ReadResponseHeaders(callback_.callback())); |
| 1533 EXPECT_FALSE(factory_.require_confirmation()); | 1444 EXPECT_FALSE(factory_.require_confirmation()); |
| 1534 | 1445 |
| 1535 // Now attempting to request a stream to the same origin should create | 1446 // Now attempting to request a stream to the same origin should create |
| 1536 // a new session. | 1447 // a new session. |
| 1537 | 1448 |
| 1538 QuicStreamRequest request2(&factory_); | 1449 QuicStreamRequest request2(&factory_); |
| 1539 EXPECT_EQ(ERR_IO_PENDING, | 1450 EXPECT_EQ(ERR_IO_PENDING, |
| 1540 request2.Request(host_port_pair_, | 1451 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1541 is_https_, | 1452 host_port_pair_.host(), "GET", net_log_, |
| 1542 privacy_mode_, | |
| 1543 "GET", | |
| 1544 net_log_, | |
| 1545 callback_.callback())); | 1453 callback_.callback())); |
| 1546 | 1454 |
| 1547 EXPECT_EQ(OK, callback_.WaitForResult()); | 1455 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1548 stream = request2.ReleaseStream(); | 1456 stream = request2.ReleaseStream(); |
| 1549 stream.reset(); // Will reset stream 3. | 1457 stream.reset(); // Will reset stream 3. |
| 1550 | 1458 |
| 1551 EXPECT_TRUE(socket_data.at_read_eof()); | 1459 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1552 EXPECT_TRUE(socket_data.at_write_eof()); | 1460 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1553 EXPECT_TRUE(socket_data2.at_read_eof()); | 1461 EXPECT_TRUE(socket_data2.at_read_eof()); |
| 1554 EXPECT_TRUE(socket_data2.at_write_eof()); | 1462 EXPECT_TRUE(socket_data2.at_write_eof()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1644 | 1552 |
| 1645 crypto_client_stream_factory_.set_handshake_mode( | 1553 crypto_client_stream_factory_.set_handshake_mode( |
| 1646 MockCryptoClientStream::ZERO_RTT); | 1554 MockCryptoClientStream::ZERO_RTT); |
| 1647 host_resolver_.set_synchronous_mode(true); | 1555 host_resolver_.set_synchronous_mode(true); |
| 1648 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1556 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1649 "192.168.0.1", ""); | 1557 "192.168.0.1", ""); |
| 1650 | 1558 |
| 1651 QuicStreamRequest request(&factory_); | 1559 QuicStreamRequest request(&factory_); |
| 1652 QuicServerId server_id(host_port_pair_, is_https_, privacy_mode_); | 1560 QuicServerId server_id(host_port_pair_, is_https_, privacy_mode_); |
| 1653 EXPECT_EQ(ERR_IO_PENDING, | 1561 EXPECT_EQ(ERR_IO_PENDING, |
| 1654 request.Request(host_port_pair_, is_https_, privacy_mode_, "GET", | 1562 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1655 net_log_, callback_.callback())); | 1563 host_port_pair_.host(), "GET", net_log_, |
| 1564 callback_.callback())); | |
| 1656 EXPECT_EQ(2u, | 1565 EXPECT_EQ(2u, |
| 1657 QuicStreamFactoryPeer::GetNumberOfActiveJobs(&factory_, server_id)); | 1566 QuicStreamFactoryPeer::GetNumberOfActiveJobs(&factory_, server_id)); |
| 1658 | 1567 |
| 1659 runner_->RunNextTask(); | 1568 runner_->RunNextTask(); |
| 1660 | 1569 |
| 1661 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1570 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1662 EXPECT_TRUE(stream.get()); | 1571 EXPECT_TRUE(stream.get()); |
| 1663 EXPECT_TRUE(socket_data.at_read_eof()); | 1572 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1664 EXPECT_TRUE(socket_data.at_write_eof()); | 1573 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1665 EXPECT_EQ(0u, | 1574 EXPECT_EQ(0u, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1679 socket_data.StopAfter(1); | 1588 socket_data.StopAfter(1); |
| 1680 | 1589 |
| 1681 crypto_client_stream_factory_.set_handshake_mode( | 1590 crypto_client_stream_factory_.set_handshake_mode( |
| 1682 MockCryptoClientStream::ZERO_RTT); | 1591 MockCryptoClientStream::ZERO_RTT); |
| 1683 host_resolver_.set_synchronous_mode(true); | 1592 host_resolver_.set_synchronous_mode(true); |
| 1684 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1593 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1685 "192.168.0.1", ""); | 1594 "192.168.0.1", ""); |
| 1686 | 1595 |
| 1687 QuicStreamRequest request(&factory_); | 1596 QuicStreamRequest request(&factory_); |
| 1688 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1597 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1689 "GET", net_log_, callback_.callback())); | 1598 host_port_pair_.host(), "GET", net_log_, |
| 1599 callback_.callback())); | |
| 1690 | 1600 |
| 1691 // If we are waiting for disk cache, we would have posted a task. Verify that | 1601 // If we are waiting for disk cache, we would have posted a task. Verify that |
| 1692 // the CancelWaitForDataReady task hasn't been posted. | 1602 // the CancelWaitForDataReady task hasn't been posted. |
| 1693 ASSERT_EQ(0u, runner_->GetPostedTasks().size()); | 1603 ASSERT_EQ(0u, runner_->GetPostedTasks().size()); |
| 1694 | 1604 |
| 1695 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1605 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1696 EXPECT_TRUE(stream.get()); | 1606 EXPECT_TRUE(stream.get()); |
| 1697 EXPECT_TRUE(socket_data.at_read_eof()); | 1607 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1698 EXPECT_TRUE(socket_data.at_write_eof()); | 1608 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1699 } | 1609 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1729 crypto_client_stream_factory_.set_handshake_mode( | 1639 crypto_client_stream_factory_.set_handshake_mode( |
| 1730 MockCryptoClientStream::ZERO_RTT); | 1640 MockCryptoClientStream::ZERO_RTT); |
| 1731 host_resolver_.set_synchronous_mode(true); | 1641 host_resolver_.set_synchronous_mode(true); |
| 1732 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1642 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1733 "192.168.0.1", ""); | 1643 "192.168.0.1", ""); |
| 1734 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 1644 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1735 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 1645 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 1736 | 1646 |
| 1737 QuicStreamRequest request(&factory_); | 1647 QuicStreamRequest request(&factory_); |
| 1738 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1648 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1739 "GET", net_log_, callback_.callback())); | 1649 host_port_pair_.host(), "GET", net_log_, |
| 1650 callback_.callback())); | |
| 1740 | 1651 |
| 1741 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1652 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( |
| 1742 &factory_, host_port_pair_, is_https_); | 1653 &factory_, host_port_pair_, is_https_); |
| 1743 | 1654 |
| 1744 DVLOG(1) << "Create 1st session and test packet loss"; | 1655 DVLOG(1) << "Create 1st session and test packet loss"; |
| 1745 | 1656 |
| 1746 // Set packet_loss_rate to a lower value than packet_loss_threshold. | 1657 // Set packet_loss_rate to a lower value than packet_loss_threshold. |
| 1747 EXPECT_FALSE( | 1658 EXPECT_FALSE( |
| 1748 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); | 1659 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); |
| 1749 EXPECT_TRUE(session->connection()->connected()); | 1660 EXPECT_TRUE(session->connection()->connected()); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1765 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 1676 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( |
| 1766 &factory_, host_port_pair_, is_https_)); | 1677 &factory_, host_port_pair_, is_https_)); |
| 1767 EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get()); | 1678 EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get()); |
| 1768 | 1679 |
| 1769 // Test N-in-a-row high packet loss connections. | 1680 // Test N-in-a-row high packet loss connections. |
| 1770 | 1681 |
| 1771 DVLOG(1) << "Create 2nd session and test packet loss"; | 1682 DVLOG(1) << "Create 2nd session and test packet loss"; |
| 1772 | 1683 |
| 1773 TestCompletionCallback callback2; | 1684 TestCompletionCallback callback2; |
| 1774 QuicStreamRequest request2(&factory_); | 1685 QuicStreamRequest request2(&factory_); |
| 1775 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, "GET", | 1686 EXPECT_EQ(OK, |
| 1776 net_log_, callback2.callback())); | 1687 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 1688 "GET", net_log_, callback2.callback())); | |
| 1777 QuicClientSession* session2 = | 1689 QuicClientSession* session2 = |
| 1778 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 1690 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); |
| 1779 | 1691 |
| 1780 // If there is no packet loss during handshake confirmation, number of lossy | 1692 // If there is no packet loss during handshake confirmation, number of lossy |
| 1781 // connections for the port should be 0. | 1693 // connections for the port should be 0. |
| 1782 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1694 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1783 &factory_, server2.port())); | 1695 &factory_, server2.port())); |
| 1784 EXPECT_FALSE( | 1696 EXPECT_FALSE( |
| 1785 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); | 1697 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); |
| 1786 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1698 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1798 EXPECT_FALSE( | 1710 EXPECT_FALSE( |
| 1799 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); | 1711 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); |
| 1800 EXPECT_FALSE( | 1712 EXPECT_FALSE( |
| 1801 QuicStreamFactoryPeer::HasActiveSession(&factory_, server2, is_https_)); | 1713 QuicStreamFactoryPeer::HasActiveSession(&factory_, server2, is_https_)); |
| 1802 EXPECT_EQ(nullptr, CreateIfSessionExists(server2, net_log_).get()); | 1714 EXPECT_EQ(nullptr, CreateIfSessionExists(server2, net_log_).get()); |
| 1803 | 1715 |
| 1804 DVLOG(1) << "Create 3rd session which also has packet loss"; | 1716 DVLOG(1) << "Create 3rd session which also has packet loss"; |
| 1805 | 1717 |
| 1806 TestCompletionCallback callback3; | 1718 TestCompletionCallback callback3; |
| 1807 QuicStreamRequest request3(&factory_); | 1719 QuicStreamRequest request3(&factory_); |
| 1808 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, "GET", | 1720 EXPECT_EQ(OK, |
| 1809 net_log_, callback3.callback())); | 1721 request3.Request(server3, is_https_, privacy_mode_, server3.host(), |
| 1722 "GET", net_log_, callback3.callback())); | |
| 1810 QuicClientSession* session3 = | 1723 QuicClientSession* session3 = |
| 1811 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); | 1724 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); |
| 1812 | 1725 |
| 1813 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in | 1726 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in |
| 1814 // a row and that should close the session and disable QUIC. | 1727 // a row and that should close the session and disable QUIC. |
| 1815 EXPECT_TRUE( | 1728 EXPECT_TRUE( |
| 1816 factory_.OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); | 1729 factory_.OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); |
| 1817 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1730 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1818 &factory_, server3.port())); | 1731 &factory_, server3.port())); |
| 1819 EXPECT_FALSE(session2->connection()->connected()); | 1732 EXPECT_FALSE(session2->connection()->connected()); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1831 EXPECT_TRUE(socket_data.at_read_eof()); | 1744 EXPECT_TRUE(socket_data.at_read_eof()); |
| 1832 EXPECT_TRUE(socket_data.at_write_eof()); | 1745 EXPECT_TRUE(socket_data.at_write_eof()); |
| 1833 EXPECT_TRUE(socket_data2.at_read_eof()); | 1746 EXPECT_TRUE(socket_data2.at_read_eof()); |
| 1834 EXPECT_TRUE(socket_data2.at_write_eof()); | 1747 EXPECT_TRUE(socket_data2.at_write_eof()); |
| 1835 EXPECT_TRUE(socket_data3.at_read_eof()); | 1748 EXPECT_TRUE(socket_data3.at_read_eof()); |
| 1836 EXPECT_TRUE(socket_data3.at_write_eof()); | 1749 EXPECT_TRUE(socket_data3.at_write_eof()); |
| 1837 } | 1750 } |
| 1838 | 1751 |
| 1839 } // namespace test | 1752 } // namespace test |
| 1840 } // namespace net | 1753 } // namespace net |
| OLD | NEW |