| 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.AllReadDataConsumed()); | 366 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 377 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 367 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 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.AllReadDataConsumed()); | 391 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 406 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 392 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 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.AllReadDataConsumed()); | 423 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 441 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 424 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 442 } | 425 } |
| 443 | 426 |
| 427 TEST_P(QuicStreamFactoryTest, NoZeroRttForDifferentHost) { |
| 428 MockRead reads[] = { |
| 429 MockRead(ASYNC, OK, 0), |
| 430 }; |
| 431 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 432 socket_factory_.AddSocketDataProvider(&socket_data); |
| 433 socket_data.StopAfter(1); |
| 434 |
| 435 crypto_client_stream_factory_.set_handshake_mode( |
| 436 MockCryptoClientStream::ZERO_RTT); |
| 437 host_resolver_.set_synchronous_mode(true); |
| 438 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 439 "192.168.0.1", ""); |
| 440 |
| 441 QuicStreamRequest request(&factory_); |
| 442 int rv = request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 443 "different.host.example.com", "GET", net_log_, |
| 444 callback_.callback()); |
| 445 // If server and origin have different hostnames, then handshake confirmation |
| 446 // should be required, so Request will return asynchronously. |
| 447 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 448 // Confirm handshake. |
| 449 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( |
| 450 QuicSession::HANDSHAKE_CONFIRMED); |
| 451 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 452 |
| 453 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 454 EXPECT_TRUE(stream.get()); |
| 455 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 456 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 457 } |
| 458 |
| 444 TEST_P(QuicStreamFactoryTest, CreateHttpVsHttps) { | 459 TEST_P(QuicStreamFactoryTest, CreateHttpVsHttps) { |
| 445 MockRead reads[] = { | 460 MockRead reads[] = { |
| 446 MockRead(ASYNC, OK, 0) // EOF | 461 MockRead(ASYNC, OK, 0) // EOF |
| 447 }; | 462 }; |
| 448 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); | 463 DeterministicSocketData socket_data1(reads, arraysize(reads), nullptr, 0); |
| 449 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | 464 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 450 socket_factory_.AddSocketDataProvider(&socket_data1); | 465 socket_factory_.AddSocketDataProvider(&socket_data1); |
| 451 socket_factory_.AddSocketDataProvider(&socket_data2); | 466 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 452 socket_data1.StopAfter(1); | 467 socket_data1.StopAfter(1); |
| 453 socket_data2.StopAfter(1); | 468 socket_data2.StopAfter(1); |
| 454 | 469 |
| 455 QuicStreamRequest request(&factory_); | 470 QuicStreamRequest request(&factory_); |
| 456 EXPECT_EQ(ERR_IO_PENDING, | 471 EXPECT_EQ(ERR_IO_PENDING, |
| 457 request.Request(host_port_pair_, | 472 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 458 is_https_, | 473 host_port_pair_.host(), "GET", net_log_, |
| 459 privacy_mode_, | |
| 460 "GET", | |
| 461 net_log_, | |
| 462 callback_.callback())); | 474 callback_.callback())); |
| 463 | 475 |
| 464 EXPECT_EQ(OK, callback_.WaitForResult()); | 476 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 465 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 477 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 466 EXPECT_TRUE(stream.get()); | 478 EXPECT_TRUE(stream.get()); |
| 467 | 479 |
| 468 QuicStreamRequest request2(&factory_); | 480 QuicStreamRequest request2(&factory_); |
| 469 EXPECT_EQ(ERR_IO_PENDING, | 481 EXPECT_EQ(ERR_IO_PENDING, |
| 470 request2.Request(host_port_pair_, | 482 request2.Request(host_port_pair_, !is_https_, privacy_mode_, |
| 471 !is_https_, | 483 host_port_pair_.host(), "GET", net_log_, |
| 472 privacy_mode_, | |
| 473 "GET", | |
| 474 net_log_, | |
| 475 callback_.callback())); | 484 callback_.callback())); |
| 476 EXPECT_EQ(OK, callback_.WaitForResult()); | 485 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 477 stream = request2.ReleaseStream(); | 486 stream = request2.ReleaseStream(); |
| 478 EXPECT_TRUE(stream.get()); | 487 EXPECT_TRUE(stream.get()); |
| 479 stream.reset(); | 488 stream.reset(); |
| 480 | 489 |
| 481 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 490 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 482 &factory_, host_port_pair_, is_https_), | 491 &factory_, host_port_pair_, is_https_), |
| 483 QuicStreamFactoryPeer::GetActiveSession( | 492 QuicStreamFactoryPeer::GetActiveSession( |
| 484 &factory_, host_port_pair_, !is_https_)); | 493 &factory_, host_port_pair_, !is_https_)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 498 socket_data.StopAfter(1); | 507 socket_data.StopAfter(1); |
| 499 | 508 |
| 500 HostPortPair server2("mail.google.com", kDefaultServerPort); | 509 HostPortPair server2("mail.google.com", kDefaultServerPort); |
| 501 host_resolver_.set_synchronous_mode(true); | 510 host_resolver_.set_synchronous_mode(true); |
| 502 host_resolver_.rules()->AddIPLiteralRule( | 511 host_resolver_.rules()->AddIPLiteralRule( |
| 503 kDefaultServerHostName, "192.168.0.1", ""); | 512 kDefaultServerHostName, "192.168.0.1", ""); |
| 504 host_resolver_.rules()->AddIPLiteralRule( | 513 host_resolver_.rules()->AddIPLiteralRule( |
| 505 "mail.google.com", "192.168.0.1", ""); | 514 "mail.google.com", "192.168.0.1", ""); |
| 506 | 515 |
| 507 QuicStreamRequest request(&factory_); | 516 QuicStreamRequest request(&factory_); |
| 508 EXPECT_EQ(OK, | 517 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 509 request.Request(host_port_pair_, | 518 host_port_pair_.host(), "GET", net_log_, |
| 510 is_https_, | 519 callback_.callback())); |
| 511 privacy_mode_, | |
| 512 "GET", | |
| 513 net_log_, | |
| 514 callback_.callback())); | |
| 515 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 520 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 516 EXPECT_TRUE(stream.get()); | 521 EXPECT_TRUE(stream.get()); |
| 517 | 522 |
| 518 TestCompletionCallback callback; | 523 TestCompletionCallback callback; |
| 519 QuicStreamRequest request2(&factory_); | 524 QuicStreamRequest request2(&factory_); |
| 520 EXPECT_EQ(OK, | 525 EXPECT_EQ(OK, |
| 521 request2.Request(server2, | 526 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 522 is_https_, | 527 "GET", net_log_, callback.callback())); |
| 523 privacy_mode_, | |
| 524 "GET", | |
| 525 net_log_, | |
| 526 callback.callback())); | |
| 527 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 528 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 528 EXPECT_TRUE(stream2.get()); | 529 EXPECT_TRUE(stream2.get()); |
| 529 | 530 |
| 530 EXPECT_EQ( | 531 EXPECT_EQ( |
| 531 QuicStreamFactoryPeer::GetActiveSession( | 532 QuicStreamFactoryPeer::GetActiveSession( |
| 532 &factory_, host_port_pair_, is_https_), | 533 &factory_, host_port_pair_, is_https_), |
| 533 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); | 534 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); |
| 534 | 535 |
| 535 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 536 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 536 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 537 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 551 host_resolver_.set_synchronous_mode(true); | 552 host_resolver_.set_synchronous_mode(true); |
| 552 host_resolver_.rules()->AddIPLiteralRule( | 553 host_resolver_.rules()->AddIPLiteralRule( |
| 553 kDefaultServerHostName, "192.168.0.1", ""); | 554 kDefaultServerHostName, "192.168.0.1", ""); |
| 554 host_resolver_.rules()->AddIPLiteralRule( | 555 host_resolver_.rules()->AddIPLiteralRule( |
| 555 "mail.google.com", "192.168.0.1", ""); | 556 "mail.google.com", "192.168.0.1", ""); |
| 556 | 557 |
| 557 // Disable connection pooling. | 558 // Disable connection pooling. |
| 558 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 559 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 559 | 560 |
| 560 QuicStreamRequest request(&factory_); | 561 QuicStreamRequest request(&factory_); |
| 561 EXPECT_EQ(OK, | 562 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 562 request.Request(host_port_pair_, | 563 host_port_pair_.host(), "GET", net_log_, |
| 563 is_https_, | 564 callback_.callback())); |
| 564 privacy_mode_, | |
| 565 "GET", | |
| 566 net_log_, | |
| 567 callback_.callback())); | |
| 568 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 565 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 569 EXPECT_TRUE(stream.get()); | 566 EXPECT_TRUE(stream.get()); |
| 570 | 567 |
| 571 TestCompletionCallback callback; | 568 TestCompletionCallback callback; |
| 572 QuicStreamRequest request2(&factory_); | 569 QuicStreamRequest request2(&factory_); |
| 573 EXPECT_EQ(OK, | 570 EXPECT_EQ(OK, |
| 574 request2.Request(server2, | 571 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 575 is_https_, | 572 "GET", net_log_, callback.callback())); |
| 576 privacy_mode_, | |
| 577 "GET", | |
| 578 net_log_, | |
| 579 callback.callback())); | |
| 580 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 573 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 581 EXPECT_TRUE(stream2.get()); | 574 EXPECT_TRUE(stream2.get()); |
| 582 | 575 |
| 583 EXPECT_NE( | 576 EXPECT_NE( |
| 584 QuicStreamFactoryPeer::GetActiveSession( | 577 QuicStreamFactoryPeer::GetActiveSession( |
| 585 &factory_, host_port_pair_, is_https_), | 578 &factory_, host_port_pair_, is_https_), |
| 586 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); | 579 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_)); |
| 587 | 580 |
| 588 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 581 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 589 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 582 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 603 socket_data2.StopAfter(1); | 596 socket_data2.StopAfter(1); |
| 604 | 597 |
| 605 HostPortPair server2("mail.google.com", kDefaultServerPort); | 598 HostPortPair server2("mail.google.com", kDefaultServerPort); |
| 606 host_resolver_.set_synchronous_mode(true); | 599 host_resolver_.set_synchronous_mode(true); |
| 607 host_resolver_.rules()->AddIPLiteralRule( | 600 host_resolver_.rules()->AddIPLiteralRule( |
| 608 kDefaultServerHostName, "192.168.0.1", ""); | 601 kDefaultServerHostName, "192.168.0.1", ""); |
| 609 host_resolver_.rules()->AddIPLiteralRule( | 602 host_resolver_.rules()->AddIPLiteralRule( |
| 610 "mail.google.com", "192.168.0.1", ""); | 603 "mail.google.com", "192.168.0.1", ""); |
| 611 | 604 |
| 612 QuicStreamRequest request(&factory_); | 605 QuicStreamRequest request(&factory_); |
| 613 EXPECT_EQ(OK, | 606 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 614 request.Request(host_port_pair_, | 607 host_port_pair_.host(), "GET", net_log_, |
| 615 is_https_, | 608 callback_.callback())); |
| 616 privacy_mode_, | |
| 617 "GET", | |
| 618 net_log_, | |
| 619 callback_.callback())); | |
| 620 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 609 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 621 EXPECT_TRUE(stream.get()); | 610 EXPECT_TRUE(stream.get()); |
| 622 | 611 |
| 623 TestCompletionCallback callback; | 612 TestCompletionCallback callback; |
| 624 QuicStreamRequest request2(&factory_); | 613 QuicStreamRequest request2(&factory_); |
| 625 EXPECT_EQ(OK, | 614 EXPECT_EQ(OK, |
| 626 request2.Request(server2, | 615 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 627 is_https_, | 616 "GET", net_log_, callback.callback())); |
| 628 privacy_mode_, | |
| 629 "GET", | |
| 630 net_log_, | |
| 631 callback.callback())); | |
| 632 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 617 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 633 EXPECT_TRUE(stream2.get()); | 618 EXPECT_TRUE(stream2.get()); |
| 634 | 619 |
| 635 factory_.OnSessionGoingAway(QuicStreamFactoryPeer::GetActiveSession( | 620 factory_.OnSessionGoingAway(QuicStreamFactoryPeer::GetActiveSession( |
| 636 &factory_, host_port_pair_, is_https_)); | 621 &factory_, host_port_pair_, is_https_)); |
| 637 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 622 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( |
| 638 &factory_, host_port_pair_, is_https_)); | 623 &factory_, host_port_pair_, is_https_)); |
| 639 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 624 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( |
| 640 &factory_, server2, is_https_)); | 625 &factory_, server2, is_https_)); |
| 641 | 626 |
| 642 TestCompletionCallback callback3; | 627 TestCompletionCallback callback3; |
| 643 QuicStreamRequest request3(&factory_); | 628 QuicStreamRequest request3(&factory_); |
| 644 EXPECT_EQ(OK, | 629 EXPECT_EQ(OK, |
| 645 request3.Request(server2, | 630 request3.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 646 is_https_, | 631 "GET", net_log_, callback3.callback())); |
| 647 privacy_mode_, | |
| 648 "GET", | |
| 649 net_log_, | |
| 650 callback3.callback())); | |
| 651 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); | 632 scoped_ptr<QuicHttpStream> stream3 = request3.ReleaseStream(); |
| 652 EXPECT_TRUE(stream3.get()); | 633 EXPECT_TRUE(stream3.get()); |
| 653 | 634 |
| 654 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( | 635 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession( |
| 655 &factory_, server2, is_https_)); | 636 &factory_, server2, is_https_)); |
| 656 | 637 |
| 657 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 638 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 658 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 639 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 659 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 640 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 660 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 641 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 684 verify_details.cert_verify_result.is_issued_by_known_root = true; | 665 verify_details.cert_verify_result.is_issued_by_known_root = true; |
| 685 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 666 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 686 | 667 |
| 687 host_resolver_.set_synchronous_mode(true); | 668 host_resolver_.set_synchronous_mode(true); |
| 688 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 669 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 689 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 670 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 690 | 671 |
| 691 QuicStreamRequest request(&factory_); | 672 QuicStreamRequest request(&factory_); |
| 692 is_https_ = true; | 673 is_https_ = true; |
| 693 EXPECT_EQ(OK, | 674 EXPECT_EQ(OK, |
| 694 request.Request(server1, | 675 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 695 is_https_, | 676 "GET", net_log_, callback_.callback())); |
| 696 privacy_mode_, | |
| 697 "GET", | |
| 698 net_log_, | |
| 699 callback_.callback())); | |
| 700 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 677 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 701 EXPECT_TRUE(stream.get()); | 678 EXPECT_TRUE(stream.get()); |
| 702 | 679 |
| 703 TestCompletionCallback callback; | 680 TestCompletionCallback callback; |
| 704 QuicStreamRequest request2(&factory_); | 681 QuicStreamRequest request2(&factory_); |
| 705 EXPECT_EQ(OK, | 682 EXPECT_EQ(OK, |
| 706 request2.Request(server2, | 683 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 707 is_https_, | 684 "GET", net_log_, callback_.callback())); |
| 708 privacy_mode_, | |
| 709 "GET", | |
| 710 net_log_, | |
| 711 callback_.callback())); | |
| 712 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 685 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 713 EXPECT_TRUE(stream2.get()); | 686 EXPECT_TRUE(stream2.get()); |
| 714 | 687 |
| 715 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( | 688 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( |
| 716 &factory_, server1, is_https_), | 689 &factory_, server1, is_https_), |
| 717 QuicStreamFactoryPeer::GetActiveSession( | 690 QuicStreamFactoryPeer::GetActiveSession( |
| 718 &factory_, server2, is_https_)); | 691 &factory_, server2, is_https_)); |
| 719 | 692 |
| 720 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 693 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 721 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 694 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 751 host_resolver_.set_synchronous_mode(true); | 724 host_resolver_.set_synchronous_mode(true); |
| 752 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 725 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 753 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 726 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 754 | 727 |
| 755 // Disable connection pooling. | 728 // Disable connection pooling. |
| 756 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 729 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 757 | 730 |
| 758 QuicStreamRequest request(&factory_); | 731 QuicStreamRequest request(&factory_); |
| 759 is_https_ = true; | 732 is_https_ = true; |
| 760 EXPECT_EQ(OK, | 733 EXPECT_EQ(OK, |
| 761 request.Request(server1, | 734 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 762 is_https_, | 735 "GET", net_log_, callback_.callback())); |
| 763 privacy_mode_, | |
| 764 "GET", | |
| 765 net_log_, | |
| 766 callback_.callback())); | |
| 767 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 736 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 768 EXPECT_TRUE(stream.get()); | 737 EXPECT_TRUE(stream.get()); |
| 769 | 738 |
| 770 TestCompletionCallback callback; | 739 TestCompletionCallback callback; |
| 771 QuicStreamRequest request2(&factory_); | 740 QuicStreamRequest request2(&factory_); |
| 772 EXPECT_EQ(OK, | 741 EXPECT_EQ(OK, |
| 773 request2.Request(server2, | 742 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 774 is_https_, | 743 "GET", net_log_, callback_.callback())); |
| 775 privacy_mode_, | |
| 776 "GET", | |
| 777 net_log_, | |
| 778 callback_.callback())); | |
| 779 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 744 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 780 EXPECT_TRUE(stream2.get()); | 745 EXPECT_TRUE(stream2.get()); |
| 781 | 746 |
| 782 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 747 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 783 &factory_, server1, is_https_), | 748 &factory_, server1, is_https_), |
| 784 QuicStreamFactoryPeer::GetActiveSession( | 749 QuicStreamFactoryPeer::GetActiveSession( |
| 785 &factory_, server2, is_https_)); | 750 &factory_, server2, is_https_)); |
| 786 | 751 |
| 787 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 752 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 788 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 753 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 817 verify_details.cert_verify_result.verified_cert = test_cert; | 782 verify_details.cert_verify_result.verified_cert = test_cert; |
| 818 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 783 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 819 | 784 |
| 820 host_resolver_.set_synchronous_mode(true); | 785 host_resolver_.set_synchronous_mode(true); |
| 821 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 786 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 822 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 787 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 823 | 788 |
| 824 QuicStreamRequest request(&factory_); | 789 QuicStreamRequest request(&factory_); |
| 825 is_https_ = true; | 790 is_https_ = true; |
| 826 EXPECT_EQ(OK, | 791 EXPECT_EQ(OK, |
| 827 request.Request(server1, | 792 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 828 is_https_, | 793 "GET", net_log_, callback_.callback())); |
| 829 privacy_mode_, | |
| 830 "GET", | |
| 831 net_log_, | |
| 832 callback_.callback())); | |
| 833 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 794 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 834 EXPECT_TRUE(stream.get()); | 795 EXPECT_TRUE(stream.get()); |
| 835 | 796 |
| 836 TestCompletionCallback callback; | 797 TestCompletionCallback callback; |
| 837 QuicStreamRequest request2(&factory_); | 798 QuicStreamRequest request2(&factory_); |
| 838 EXPECT_EQ(OK, | 799 EXPECT_EQ(OK, |
| 839 request2.Request(server2, | 800 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 840 is_https_, | 801 "GET", net_log_, callback_.callback())); |
| 841 privacy_mode_, | |
| 842 "GET", | |
| 843 net_log_, | |
| 844 callback_.callback())); | |
| 845 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 802 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 846 EXPECT_TRUE(stream2.get()); | 803 EXPECT_TRUE(stream2.get()); |
| 847 | 804 |
| 848 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 805 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 849 &factory_, server1, is_https_), | 806 &factory_, server1, is_https_), |
| 850 QuicStreamFactoryPeer::GetActiveSession( | 807 QuicStreamFactoryPeer::GetActiveSession( |
| 851 &factory_, server2, is_https_)); | 808 &factory_, server2, is_https_)); |
| 852 | 809 |
| 853 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 810 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 854 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 811 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 885 test::GetTestHashValue(primary_pin)); | 842 test::GetTestHashValue(primary_pin)); |
| 886 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 843 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 887 | 844 |
| 888 host_resolver_.set_synchronous_mode(true); | 845 host_resolver_.set_synchronous_mode(true); |
| 889 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 846 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 890 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 847 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 891 | 848 |
| 892 QuicStreamRequest request(&factory_); | 849 QuicStreamRequest request(&factory_); |
| 893 is_https_ = true; | 850 is_https_ = true; |
| 894 EXPECT_EQ(OK, | 851 EXPECT_EQ(OK, |
| 895 request.Request(server1, | 852 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 896 is_https_, | 853 "GET", net_log_, callback_.callback())); |
| 897 privacy_mode_, | |
| 898 "GET", | |
| 899 net_log_, | |
| 900 callback_.callback())); | |
| 901 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 854 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 902 EXPECT_TRUE(stream.get()); | 855 EXPECT_TRUE(stream.get()); |
| 903 | 856 |
| 904 TestCompletionCallback callback; | 857 TestCompletionCallback callback; |
| 905 QuicStreamRequest request2(&factory_); | 858 QuicStreamRequest request2(&factory_); |
| 906 EXPECT_EQ(OK, | 859 EXPECT_EQ(OK, |
| 907 request2.Request(server2, | 860 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 908 is_https_, | 861 "GET", net_log_, callback_.callback())); |
| 909 privacy_mode_, | |
| 910 "GET", | |
| 911 net_log_, | |
| 912 callback_.callback())); | |
| 913 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 862 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 914 EXPECT_TRUE(stream2.get()); | 863 EXPECT_TRUE(stream2.get()); |
| 915 | 864 |
| 916 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( | 865 EXPECT_EQ(QuicStreamFactoryPeer::GetActiveSession( |
| 917 &factory_, server1, is_https_), | 866 &factory_, server1, is_https_), |
| 918 QuicStreamFactoryPeer::GetActiveSession( | 867 QuicStreamFactoryPeer::GetActiveSession( |
| 919 &factory_, server2, is_https_)); | 868 &factory_, server2, is_https_)); |
| 920 | 869 |
| 921 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 870 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 922 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 871 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 host_resolver_.set_synchronous_mode(true); | 906 host_resolver_.set_synchronous_mode(true); |
| 958 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 907 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 959 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 908 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 960 | 909 |
| 961 // Disable connection pooling. | 910 // Disable connection pooling. |
| 962 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); | 911 QuicStreamFactoryPeer::DisableConnectionPooling(&factory_); |
| 963 | 912 |
| 964 QuicStreamRequest request(&factory_); | 913 QuicStreamRequest request(&factory_); |
| 965 is_https_ = true; | 914 is_https_ = true; |
| 966 EXPECT_EQ(OK, | 915 EXPECT_EQ(OK, |
| 967 request.Request(server1, | 916 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 968 is_https_, | 917 "GET", net_log_, callback_.callback())); |
| 969 privacy_mode_, | |
| 970 "GET", | |
| 971 net_log_, | |
| 972 callback_.callback())); | |
| 973 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 918 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 974 EXPECT_TRUE(stream.get()); | 919 EXPECT_TRUE(stream.get()); |
| 975 | 920 |
| 976 TestCompletionCallback callback; | 921 TestCompletionCallback callback; |
| 977 QuicStreamRequest request2(&factory_); | 922 QuicStreamRequest request2(&factory_); |
| 978 EXPECT_EQ(OK, | 923 EXPECT_EQ(OK, |
| 979 request2.Request(server2, | 924 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 980 is_https_, | 925 "GET", net_log_, callback_.callback())); |
| 981 privacy_mode_, | |
| 982 "GET", | |
| 983 net_log_, | |
| 984 callback_.callback())); | |
| 985 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 926 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 986 EXPECT_TRUE(stream2.get()); | 927 EXPECT_TRUE(stream2.get()); |
| 987 | 928 |
| 988 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 929 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 989 &factory_, server1, is_https_), | 930 &factory_, server1, is_https_), |
| 990 QuicStreamFactoryPeer::GetActiveSession( | 931 QuicStreamFactoryPeer::GetActiveSession( |
| 991 &factory_, server2, is_https_)); | 932 &factory_, server2, is_https_)); |
| 992 | 933 |
| 993 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 934 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 994 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 935 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 test::GetTestHashValue(primary_pin)); | 978 test::GetTestHashValue(primary_pin)); |
| 1038 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); | 979 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); |
| 1039 | 980 |
| 1040 host_resolver_.set_synchronous_mode(true); | 981 host_resolver_.set_synchronous_mode(true); |
| 1041 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); | 982 host_resolver_.rules()->AddIPLiteralRule(server1.host(), "192.168.0.1", ""); |
| 1042 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 983 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1043 | 984 |
| 1044 QuicStreamRequest request(&factory_); | 985 QuicStreamRequest request(&factory_); |
| 1045 is_https_ = true; | 986 is_https_ = true; |
| 1046 EXPECT_EQ(OK, | 987 EXPECT_EQ(OK, |
| 1047 request.Request(server1, | 988 request.Request(server1, is_https_, privacy_mode_, server1.host(), |
| 1048 is_https_, | 989 "GET", net_log_, callback_.callback())); |
| 1049 privacy_mode_, | |
| 1050 "GET", | |
| 1051 net_log_, | |
| 1052 callback_.callback())); | |
| 1053 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 990 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1054 EXPECT_TRUE(stream.get()); | 991 EXPECT_TRUE(stream.get()); |
| 1055 | 992 |
| 1056 TestCompletionCallback callback; | 993 TestCompletionCallback callback; |
| 1057 QuicStreamRequest request2(&factory_); | 994 QuicStreamRequest request2(&factory_); |
| 1058 EXPECT_EQ(OK, | 995 EXPECT_EQ(OK, |
| 1059 request2.Request(server2, | 996 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 1060 is_https_, | 997 "GET", net_log_, callback_.callback())); |
| 1061 privacy_mode_, | |
| 1062 "GET", | |
| 1063 net_log_, | |
| 1064 callback_.callback())); | |
| 1065 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 998 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1066 EXPECT_TRUE(stream2.get()); | 999 EXPECT_TRUE(stream2.get()); |
| 1067 | 1000 |
| 1068 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( | 1001 EXPECT_NE(QuicStreamFactoryPeer::GetActiveSession( |
| 1069 &factory_, server1, is_https_), | 1002 &factory_, server1, is_https_), |
| 1070 QuicStreamFactoryPeer::GetActiveSession( | 1003 QuicStreamFactoryPeer::GetActiveSession( |
| 1071 &factory_, server2, is_https_)); | 1004 &factory_, server2, is_https_)); |
| 1072 | 1005 |
| 1073 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 1006 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 1074 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 1007 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 1075 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1008 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1076 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1009 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1077 } | 1010 } |
| 1078 | 1011 |
| 1079 TEST_P(QuicStreamFactoryTest, Goaway) { | 1012 TEST_P(QuicStreamFactoryTest, Goaway) { |
| 1080 MockRead reads[] = { | 1013 MockRead reads[] = { |
| 1081 MockRead(ASYNC, OK, 0) // EOF | 1014 MockRead(ASYNC, OK, 0) // EOF |
| 1082 }; | 1015 }; |
| 1083 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 1016 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 1084 socket_data.StopAfter(1); | 1017 socket_data.StopAfter(1); |
| 1085 socket_factory_.AddSocketDataProvider(&socket_data); | 1018 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1086 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); | 1019 DeterministicSocketData socket_data2(reads, arraysize(reads), nullptr, 0); |
| 1087 socket_data2.StopAfter(1); | 1020 socket_data2.StopAfter(1); |
| 1088 socket_factory_.AddSocketDataProvider(&socket_data2); | 1021 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1089 | 1022 |
| 1090 QuicStreamRequest request(&factory_); | 1023 QuicStreamRequest request(&factory_); |
| 1091 EXPECT_EQ(ERR_IO_PENDING, | 1024 EXPECT_EQ(ERR_IO_PENDING, |
| 1092 request.Request(host_port_pair_, | 1025 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1093 is_https_, | 1026 host_port_pair_.host(), "GET", net_log_, |
| 1094 privacy_mode_, | |
| 1095 "GET", | |
| 1096 net_log_, | |
| 1097 callback_.callback())); | 1027 callback_.callback())); |
| 1098 | 1028 |
| 1099 EXPECT_EQ(OK, callback_.WaitForResult()); | 1029 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1100 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1030 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1101 EXPECT_TRUE(stream.get()); | 1031 EXPECT_TRUE(stream.get()); |
| 1102 | 1032 |
| 1103 // Mark the session as going away. Ensure that while it is still alive | 1033 // Mark the session as going away. Ensure that while it is still alive |
| 1104 // that it is no longer active. | 1034 // that it is no longer active. |
| 1105 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1035 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( |
| 1106 &factory_, host_port_pair_, is_https_); | 1036 &factory_, host_port_pair_, is_https_); |
| 1107 factory_.OnSessionGoingAway(session); | 1037 factory_.OnSessionGoingAway(session); |
| 1108 EXPECT_EQ(true, QuicStreamFactoryPeer::IsLiveSession(&factory_, session)); | 1038 EXPECT_EQ(true, QuicStreamFactoryPeer::IsLiveSession(&factory_, session)); |
| 1109 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 1039 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( |
| 1110 &factory_, host_port_pair_, is_https_)); | 1040 &factory_, host_port_pair_, is_https_)); |
| 1111 EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get()); | 1041 EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get()); |
| 1112 | 1042 |
| 1113 // Create a new request for the same destination and verify that a | 1043 // Create a new request for the same destination and verify that a |
| 1114 // new session is created. | 1044 // new session is created. |
| 1115 QuicStreamRequest request2(&factory_); | 1045 QuicStreamRequest request2(&factory_); |
| 1116 EXPECT_EQ(ERR_IO_PENDING, | 1046 EXPECT_EQ(ERR_IO_PENDING, |
| 1117 request2.Request(host_port_pair_, | 1047 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1118 is_https_, | 1048 host_port_pair_.host(), "GET", net_log_, |
| 1119 privacy_mode_, | |
| 1120 "GET", | |
| 1121 net_log_, | |
| 1122 callback_.callback())); | 1049 callback_.callback())); |
| 1123 EXPECT_EQ(OK, callback_.WaitForResult()); | 1050 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1124 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1051 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1125 EXPECT_TRUE(stream2.get()); | 1052 EXPECT_TRUE(stream2.get()); |
| 1126 | 1053 |
| 1127 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(&factory_, | 1054 EXPECT_TRUE(QuicStreamFactoryPeer::HasActiveSession(&factory_, |
| 1128 host_port_pair_, | 1055 host_port_pair_, |
| 1129 is_https_)); | 1056 is_https_)); |
| 1130 EXPECT_NE(session, | 1057 EXPECT_NE(session, |
| 1131 QuicStreamFactoryPeer::GetActiveSession( | 1058 QuicStreamFactoryPeer::GetActiveSession( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1155 writes, arraysize(writes)); | 1082 writes, arraysize(writes)); |
| 1156 socket_factory_.AddSocketDataProvider(&socket_data); | 1083 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1157 socket_data.StopAfter(1); | 1084 socket_data.StopAfter(1); |
| 1158 | 1085 |
| 1159 HttpRequestInfo request_info; | 1086 HttpRequestInfo request_info; |
| 1160 std::vector<QuicHttpStream*> streams; | 1087 std::vector<QuicHttpStream*> streams; |
| 1161 // The MockCryptoClientStream sets max_open_streams to be | 1088 // The MockCryptoClientStream sets max_open_streams to be |
| 1162 // kDefaultMaxStreamsPerConnection / 2. | 1089 // kDefaultMaxStreamsPerConnection / 2. |
| 1163 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection / 2; i++) { | 1090 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection / 2; i++) { |
| 1164 QuicStreamRequest request(&factory_); | 1091 QuicStreamRequest request(&factory_); |
| 1165 int rv = request.Request(host_port_pair_, | 1092 int rv = request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1166 is_https_, | 1093 host_port_pair_.host(), "GET", net_log_, |
| 1167 privacy_mode_, | |
| 1168 "GET", | |
| 1169 net_log_, | |
| 1170 callback_.callback()); | 1094 callback_.callback()); |
| 1171 if (i == 0) { | 1095 if (i == 0) { |
| 1172 EXPECT_EQ(ERR_IO_PENDING, rv); | 1096 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1173 EXPECT_EQ(OK, callback_.WaitForResult()); | 1097 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1174 } else { | 1098 } else { |
| 1175 EXPECT_EQ(OK, rv); | 1099 EXPECT_EQ(OK, rv); |
| 1176 } | 1100 } |
| 1177 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1101 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1178 EXPECT_TRUE(stream); | 1102 EXPECT_TRUE(stream); |
| 1179 EXPECT_EQ(OK, stream->InitializeStream( | 1103 EXPECT_EQ(OK, stream->InitializeStream( |
| 1180 &request_info, DEFAULT_PRIORITY, net_log_, CompletionCallback())); | 1104 &request_info, DEFAULT_PRIORITY, net_log_, CompletionCallback())); |
| 1181 streams.push_back(stream.release()); | 1105 streams.push_back(stream.release()); |
| 1182 } | 1106 } |
| 1183 | 1107 |
| 1184 QuicStreamRequest request(&factory_); | 1108 QuicStreamRequest request(&factory_); |
| 1185 EXPECT_EQ(OK, | 1109 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1186 request.Request(host_port_pair_, | 1110 host_port_pair_.host(), "GET", net_log_, |
| 1187 is_https_, | 1111 CompletionCallback())); |
| 1188 privacy_mode_, | |
| 1189 "GET", | |
| 1190 net_log_, | |
| 1191 CompletionCallback())); | |
| 1192 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1112 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1193 EXPECT_TRUE(stream); | 1113 EXPECT_TRUE(stream); |
| 1194 EXPECT_EQ(ERR_IO_PENDING, stream->InitializeStream( | 1114 EXPECT_EQ(ERR_IO_PENDING, stream->InitializeStream( |
| 1195 &request_info, DEFAULT_PRIORITY, net_log_, callback_.callback())); | 1115 &request_info, DEFAULT_PRIORITY, net_log_, callback_.callback())); |
| 1196 | 1116 |
| 1197 // Close the first stream. | 1117 // Close the first stream. |
| 1198 streams.front()->Close(false); | 1118 streams.front()->Close(false); |
| 1199 | 1119 |
| 1200 ASSERT_TRUE(callback_.have_result()); | 1120 ASSERT_TRUE(callback_.have_result()); |
| 1201 | 1121 |
| 1202 EXPECT_EQ(OK, callback_.WaitForResult()); | 1122 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1203 | 1123 |
| 1204 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1124 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1205 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1125 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1206 STLDeleteElements(&streams); | 1126 STLDeleteElements(&streams); |
| 1207 } | 1127 } |
| 1208 | 1128 |
| 1209 TEST_P(QuicStreamFactoryTest, ResolutionErrorInCreate) { | 1129 TEST_P(QuicStreamFactoryTest, ResolutionErrorInCreate) { |
| 1210 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); | 1130 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); |
| 1211 socket_factory_.AddSocketDataProvider(&socket_data); | 1131 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1212 | 1132 |
| 1213 host_resolver_.rules()->AddSimulatedFailure(kDefaultServerHostName); | 1133 host_resolver_.rules()->AddSimulatedFailure(kDefaultServerHostName); |
| 1214 | 1134 |
| 1215 QuicStreamRequest request(&factory_); | 1135 QuicStreamRequest request(&factory_); |
| 1216 EXPECT_EQ(ERR_IO_PENDING, | 1136 EXPECT_EQ(ERR_IO_PENDING, |
| 1217 request.Request(host_port_pair_, | 1137 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1218 is_https_, | 1138 host_port_pair_.host(), "GET", net_log_, |
| 1219 privacy_mode_, | |
| 1220 "GET", | |
| 1221 net_log_, | |
| 1222 callback_.callback())); | 1139 callback_.callback())); |
| 1223 | 1140 |
| 1224 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); | 1141 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); |
| 1225 | 1142 |
| 1226 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1143 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1227 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1144 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1228 } | 1145 } |
| 1229 | 1146 |
| 1230 TEST_P(QuicStreamFactoryTest, ConnectErrorInCreate) { | 1147 TEST_P(QuicStreamFactoryTest, ConnectErrorInCreate) { |
| 1231 MockConnect connect(SYNCHRONOUS, ERR_ADDRESS_IN_USE); | 1148 MockConnect connect(SYNCHRONOUS, ERR_ADDRESS_IN_USE); |
| 1232 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); | 1149 DeterministicSocketData socket_data(nullptr, 0, nullptr, 0); |
| 1233 socket_data.set_connect_data(connect); | 1150 socket_data.set_connect_data(connect); |
| 1234 socket_factory_.AddSocketDataProvider(&socket_data); | 1151 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1235 socket_data.StopAfter(1); | 1152 socket_data.StopAfter(1); |
| 1236 | 1153 |
| 1237 QuicStreamRequest request(&factory_); | 1154 QuicStreamRequest request(&factory_); |
| 1238 EXPECT_EQ(ERR_IO_PENDING, | 1155 EXPECT_EQ(ERR_IO_PENDING, |
| 1239 request.Request(host_port_pair_, | 1156 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1240 is_https_, | 1157 host_port_pair_.host(), "GET", net_log_, |
| 1241 privacy_mode_, | |
| 1242 "GET", | |
| 1243 net_log_, | |
| 1244 callback_.callback())); | 1158 callback_.callback())); |
| 1245 | 1159 |
| 1246 EXPECT_EQ(ERR_ADDRESS_IN_USE, callback_.WaitForResult()); | 1160 EXPECT_EQ(ERR_ADDRESS_IN_USE, callback_.WaitForResult()); |
| 1247 | 1161 |
| 1248 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1162 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1249 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1163 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1250 } | 1164 } |
| 1251 | 1165 |
| 1252 TEST_P(QuicStreamFactoryTest, CancelCreate) { | 1166 TEST_P(QuicStreamFactoryTest, CancelCreate) { |
| 1253 MockRead reads[] = { | 1167 MockRead reads[] = { |
| 1254 MockRead(ASYNC, OK, 0) // EOF | 1168 MockRead(ASYNC, OK, 0) // EOF |
| 1255 }; | 1169 }; |
| 1256 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); | 1170 DeterministicSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 1257 socket_factory_.AddSocketDataProvider(&socket_data); | 1171 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1258 { | 1172 { |
| 1259 QuicStreamRequest request(&factory_); | 1173 QuicStreamRequest request(&factory_); |
| 1260 EXPECT_EQ(ERR_IO_PENDING, | 1174 EXPECT_EQ(ERR_IO_PENDING, |
| 1261 request.Request(host_port_pair_, | 1175 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1262 is_https_, | 1176 host_port_pair_.host(), "GET", net_log_, |
| 1263 privacy_mode_, | |
| 1264 "GET", | |
| 1265 net_log_, | |
| 1266 callback_.callback())); | 1177 callback_.callback())); |
| 1267 } | 1178 } |
| 1268 | 1179 |
| 1269 socket_data.StopAfter(1); | 1180 socket_data.StopAfter(1); |
| 1270 base::RunLoop run_loop; | 1181 base::RunLoop run_loop; |
| 1271 run_loop.RunUntilIdle(); | 1182 run_loop.RunUntilIdle(); |
| 1272 | 1183 |
| 1273 scoped_ptr<QuicHttpStream> stream( | 1184 scoped_ptr<QuicHttpStream> stream( |
| 1274 CreateIfSessionExists(host_port_pair_, net_log_)); | 1185 CreateIfSessionExists(host_port_pair_, net_log_)); |
| 1275 EXPECT_TRUE(stream.get()); | 1186 EXPECT_TRUE(stream.get()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 | 1229 |
| 1319 MockRead reads2[] = { | 1230 MockRead reads2[] = { |
| 1320 MockRead(ASYNC, 0, 0) // EOF | 1231 MockRead(ASYNC, 0, 0) // EOF |
| 1321 }; | 1232 }; |
| 1322 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1233 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1323 socket_factory_.AddSocketDataProvider(&socket_data2); | 1234 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1324 socket_data2.StopAfter(1); | 1235 socket_data2.StopAfter(1); |
| 1325 | 1236 |
| 1326 QuicStreamRequest request(&factory_); | 1237 QuicStreamRequest request(&factory_); |
| 1327 EXPECT_EQ(ERR_IO_PENDING, | 1238 EXPECT_EQ(ERR_IO_PENDING, |
| 1328 request.Request(host_port_pair_, | 1239 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1329 is_https_, | 1240 host_port_pair_.host(), "GET", net_log_, |
| 1330 privacy_mode_, | |
| 1331 "GET", | |
| 1332 net_log_, | |
| 1333 callback_.callback())); | 1241 callback_.callback())); |
| 1334 | 1242 |
| 1335 EXPECT_EQ(OK, callback_.WaitForResult()); | 1243 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1336 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1244 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1337 HttpRequestInfo request_info; | 1245 HttpRequestInfo request_info; |
| 1338 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1246 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1339 DEFAULT_PRIORITY, | 1247 DEFAULT_PRIORITY, |
| 1340 net_log_, CompletionCallback())); | 1248 net_log_, CompletionCallback())); |
| 1341 | 1249 |
| 1342 // Close the session and verify that stream saw the error. | 1250 // Close the session and verify that stream saw the error. |
| 1343 factory_.CloseAllSessions(ERR_INTERNET_DISCONNECTED); | 1251 factory_.CloseAllSessions(ERR_INTERNET_DISCONNECTED); |
| 1344 EXPECT_EQ(ERR_INTERNET_DISCONNECTED, | 1252 EXPECT_EQ(ERR_INTERNET_DISCONNECTED, |
| 1345 stream->ReadResponseHeaders(callback_.callback())); | 1253 stream->ReadResponseHeaders(callback_.callback())); |
| 1346 | 1254 |
| 1347 // Now attempting to request a stream to the same origin should create | 1255 // Now attempting to request a stream to the same origin should create |
| 1348 // a new session. | 1256 // a new session. |
| 1349 | 1257 |
| 1350 QuicStreamRequest request2(&factory_); | 1258 QuicStreamRequest request2(&factory_); |
| 1351 EXPECT_EQ(ERR_IO_PENDING, | 1259 EXPECT_EQ(ERR_IO_PENDING, |
| 1352 request2.Request(host_port_pair_, | 1260 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1353 is_https_, | 1261 host_port_pair_.host(), "GET", net_log_, |
| 1354 privacy_mode_, | |
| 1355 "GET", | |
| 1356 net_log_, | |
| 1357 callback_.callback())); | 1262 callback_.callback())); |
| 1358 | 1263 |
| 1359 EXPECT_EQ(OK, callback_.WaitForResult()); | 1264 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1360 stream = request2.ReleaseStream(); | 1265 stream = request2.ReleaseStream(); |
| 1361 stream.reset(); // Will reset stream 3. | 1266 stream.reset(); // Will reset stream 3. |
| 1362 | 1267 |
| 1363 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1268 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1364 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1269 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1365 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1270 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1366 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1271 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1381 | 1286 |
| 1382 MockRead reads2[] = { | 1287 MockRead reads2[] = { |
| 1383 MockRead(ASYNC, 0, 0) // EOF | 1288 MockRead(ASYNC, 0, 0) // EOF |
| 1384 }; | 1289 }; |
| 1385 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1290 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1386 socket_factory_.AddSocketDataProvider(&socket_data2); | 1291 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1387 socket_data2.StopAfter(1); | 1292 socket_data2.StopAfter(1); |
| 1388 | 1293 |
| 1389 QuicStreamRequest request(&factory_); | 1294 QuicStreamRequest request(&factory_); |
| 1390 EXPECT_EQ(ERR_IO_PENDING, | 1295 EXPECT_EQ(ERR_IO_PENDING, |
| 1391 request.Request(host_port_pair_, | 1296 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1392 is_https_, | 1297 host_port_pair_.host(), "GET", net_log_, |
| 1393 privacy_mode_, | |
| 1394 "GET", | |
| 1395 net_log_, | |
| 1396 callback_.callback())); | 1298 callback_.callback())); |
| 1397 | 1299 |
| 1398 EXPECT_EQ(OK, callback_.WaitForResult()); | 1300 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1399 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1301 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1400 HttpRequestInfo request_info; | 1302 HttpRequestInfo request_info; |
| 1401 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1303 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1402 DEFAULT_PRIORITY, | 1304 DEFAULT_PRIORITY, |
| 1403 net_log_, CompletionCallback())); | 1305 net_log_, CompletionCallback())); |
| 1404 | 1306 |
| 1405 // Change the IP address and verify that stream saw the error. | 1307 // Change the IP address and verify that stream saw the error. |
| 1406 factory_.OnIPAddressChanged(); | 1308 factory_.OnIPAddressChanged(); |
| 1407 EXPECT_EQ(ERR_NETWORK_CHANGED, | 1309 EXPECT_EQ(ERR_NETWORK_CHANGED, |
| 1408 stream->ReadResponseHeaders(callback_.callback())); | 1310 stream->ReadResponseHeaders(callback_.callback())); |
| 1409 EXPECT_TRUE(factory_.require_confirmation()); | 1311 EXPECT_TRUE(factory_.require_confirmation()); |
| 1410 | 1312 |
| 1411 // Now attempting to request a stream to the same origin should create | 1313 // Now attempting to request a stream to the same origin should create |
| 1412 // a new session. | 1314 // a new session. |
| 1413 | 1315 |
| 1414 QuicStreamRequest request2(&factory_); | 1316 QuicStreamRequest request2(&factory_); |
| 1415 EXPECT_EQ(ERR_IO_PENDING, | 1317 EXPECT_EQ(ERR_IO_PENDING, |
| 1416 request2.Request(host_port_pair_, | 1318 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1417 is_https_, | 1319 host_port_pair_.host(), "GET", net_log_, |
| 1418 privacy_mode_, | |
| 1419 "GET", | |
| 1420 net_log_, | |
| 1421 callback_.callback())); | 1320 callback_.callback())); |
| 1422 | 1321 |
| 1423 EXPECT_EQ(OK, callback_.WaitForResult()); | 1322 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1424 stream = request2.ReleaseStream(); | 1323 stream = request2.ReleaseStream(); |
| 1425 stream.reset(); // Will reset stream 3. | 1324 stream.reset(); // Will reset stream 3. |
| 1426 | 1325 |
| 1427 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1326 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1428 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1327 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1429 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1328 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1430 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1329 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1445 | 1344 |
| 1446 MockRead reads2[] = { | 1345 MockRead reads2[] = { |
| 1447 MockRead(ASYNC, 0, 0) // EOF | 1346 MockRead(ASYNC, 0, 0) // EOF |
| 1448 }; | 1347 }; |
| 1449 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1348 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1450 socket_factory_.AddSocketDataProvider(&socket_data2); | 1349 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1451 socket_data2.StopAfter(1); | 1350 socket_data2.StopAfter(1); |
| 1452 | 1351 |
| 1453 QuicStreamRequest request(&factory_); | 1352 QuicStreamRequest request(&factory_); |
| 1454 EXPECT_EQ(ERR_IO_PENDING, | 1353 EXPECT_EQ(ERR_IO_PENDING, |
| 1455 request.Request(host_port_pair_, | 1354 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1456 is_https_, | 1355 host_port_pair_.host(), "GET", net_log_, |
| 1457 privacy_mode_, | |
| 1458 "GET", | |
| 1459 net_log_, | |
| 1460 callback_.callback())); | 1356 callback_.callback())); |
| 1461 | 1357 |
| 1462 EXPECT_EQ(OK, callback_.WaitForResult()); | 1358 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1463 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1359 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1464 HttpRequestInfo request_info; | 1360 HttpRequestInfo request_info; |
| 1465 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1361 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1466 DEFAULT_PRIORITY, | 1362 DEFAULT_PRIORITY, |
| 1467 net_log_, CompletionCallback())); | 1363 net_log_, CompletionCallback())); |
| 1468 | 1364 |
| 1469 // Add a cert and verify that stream saw the event. | 1365 // Add a cert and verify that stream saw the event. |
| 1470 factory_.OnCertAdded(nullptr); | 1366 factory_.OnCertAdded(nullptr); |
| 1471 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 1367 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 1472 stream->ReadResponseHeaders(callback_.callback())); | 1368 stream->ReadResponseHeaders(callback_.callback())); |
| 1473 EXPECT_FALSE(factory_.require_confirmation()); | 1369 EXPECT_FALSE(factory_.require_confirmation()); |
| 1474 | 1370 |
| 1475 // Now attempting to request a stream to the same origin should create | 1371 // Now attempting to request a stream to the same origin should create |
| 1476 // a new session. | 1372 // a new session. |
| 1477 | 1373 |
| 1478 QuicStreamRequest request2(&factory_); | 1374 QuicStreamRequest request2(&factory_); |
| 1479 EXPECT_EQ(ERR_IO_PENDING, | 1375 EXPECT_EQ(ERR_IO_PENDING, |
| 1480 request2.Request(host_port_pair_, | 1376 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1481 is_https_, | 1377 host_port_pair_.host(), "GET", net_log_, |
| 1482 privacy_mode_, | |
| 1483 "GET", | |
| 1484 net_log_, | |
| 1485 callback_.callback())); | 1378 callback_.callback())); |
| 1486 | 1379 |
| 1487 EXPECT_EQ(OK, callback_.WaitForResult()); | 1380 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1488 stream = request2.ReleaseStream(); | 1381 stream = request2.ReleaseStream(); |
| 1489 stream.reset(); // Will reset stream 3. | 1382 stream.reset(); // Will reset stream 3. |
| 1490 | 1383 |
| 1491 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1384 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1492 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1385 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1493 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1386 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1494 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1387 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1509 | 1402 |
| 1510 MockRead reads2[] = { | 1403 MockRead reads2[] = { |
| 1511 MockRead(ASYNC, 0, 0) // EOF | 1404 MockRead(ASYNC, 0, 0) // EOF |
| 1512 }; | 1405 }; |
| 1513 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); | 1406 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1514 socket_factory_.AddSocketDataProvider(&socket_data2); | 1407 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1515 socket_data2.StopAfter(1); | 1408 socket_data2.StopAfter(1); |
| 1516 | 1409 |
| 1517 QuicStreamRequest request(&factory_); | 1410 QuicStreamRequest request(&factory_); |
| 1518 EXPECT_EQ(ERR_IO_PENDING, | 1411 EXPECT_EQ(ERR_IO_PENDING, |
| 1519 request.Request(host_port_pair_, | 1412 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1520 is_https_, | 1413 host_port_pair_.host(), "GET", net_log_, |
| 1521 privacy_mode_, | |
| 1522 "GET", | |
| 1523 net_log_, | |
| 1524 callback_.callback())); | 1414 callback_.callback())); |
| 1525 | 1415 |
| 1526 EXPECT_EQ(OK, callback_.WaitForResult()); | 1416 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1527 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1417 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1528 HttpRequestInfo request_info; | 1418 HttpRequestInfo request_info; |
| 1529 EXPECT_EQ(OK, stream->InitializeStream(&request_info, | 1419 EXPECT_EQ(OK, stream->InitializeStream(&request_info, |
| 1530 DEFAULT_PRIORITY, | 1420 DEFAULT_PRIORITY, |
| 1531 net_log_, CompletionCallback())); | 1421 net_log_, CompletionCallback())); |
| 1532 | 1422 |
| 1533 // Change the CA cert and verify that stream saw the event. | 1423 // Change the CA cert and verify that stream saw the event. |
| 1534 factory_.OnCACertChanged(nullptr); | 1424 factory_.OnCACertChanged(nullptr); |
| 1535 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, | 1425 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED, |
| 1536 stream->ReadResponseHeaders(callback_.callback())); | 1426 stream->ReadResponseHeaders(callback_.callback())); |
| 1537 EXPECT_FALSE(factory_.require_confirmation()); | 1427 EXPECT_FALSE(factory_.require_confirmation()); |
| 1538 | 1428 |
| 1539 // Now attempting to request a stream to the same origin should create | 1429 // Now attempting to request a stream to the same origin should create |
| 1540 // a new session. | 1430 // a new session. |
| 1541 | 1431 |
| 1542 QuicStreamRequest request2(&factory_); | 1432 QuicStreamRequest request2(&factory_); |
| 1543 EXPECT_EQ(ERR_IO_PENDING, | 1433 EXPECT_EQ(ERR_IO_PENDING, |
| 1544 request2.Request(host_port_pair_, | 1434 request2.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1545 is_https_, | 1435 host_port_pair_.host(), "GET", net_log_, |
| 1546 privacy_mode_, | |
| 1547 "GET", | |
| 1548 net_log_, | |
| 1549 callback_.callback())); | 1436 callback_.callback())); |
| 1550 | 1437 |
| 1551 EXPECT_EQ(OK, callback_.WaitForResult()); | 1438 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1552 stream = request2.ReleaseStream(); | 1439 stream = request2.ReleaseStream(); |
| 1553 stream.reset(); // Will reset stream 3. | 1440 stream.reset(); // Will reset stream 3. |
| 1554 | 1441 |
| 1555 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1442 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1556 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1443 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1557 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1444 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1558 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1445 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 | 1535 |
| 1649 crypto_client_stream_factory_.set_handshake_mode( | 1536 crypto_client_stream_factory_.set_handshake_mode( |
| 1650 MockCryptoClientStream::ZERO_RTT); | 1537 MockCryptoClientStream::ZERO_RTT); |
| 1651 host_resolver_.set_synchronous_mode(true); | 1538 host_resolver_.set_synchronous_mode(true); |
| 1652 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1539 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1653 "192.168.0.1", ""); | 1540 "192.168.0.1", ""); |
| 1654 | 1541 |
| 1655 QuicStreamRequest request(&factory_); | 1542 QuicStreamRequest request(&factory_); |
| 1656 QuicServerId server_id(host_port_pair_, is_https_, privacy_mode_); | 1543 QuicServerId server_id(host_port_pair_, is_https_, privacy_mode_); |
| 1657 EXPECT_EQ(ERR_IO_PENDING, | 1544 EXPECT_EQ(ERR_IO_PENDING, |
| 1658 request.Request(host_port_pair_, is_https_, privacy_mode_, "GET", | 1545 request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1659 net_log_, callback_.callback())); | 1546 host_port_pair_.host(), "GET", net_log_, |
| 1547 callback_.callback())); |
| 1660 EXPECT_EQ(2u, | 1548 EXPECT_EQ(2u, |
| 1661 QuicStreamFactoryPeer::GetNumberOfActiveJobs(&factory_, server_id)); | 1549 QuicStreamFactoryPeer::GetNumberOfActiveJobs(&factory_, server_id)); |
| 1662 | 1550 |
| 1663 runner_->RunNextTask(); | 1551 runner_->RunNextTask(); |
| 1664 | 1552 |
| 1665 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1553 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1666 EXPECT_TRUE(stream.get()); | 1554 EXPECT_TRUE(stream.get()); |
| 1667 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1555 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1668 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1556 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1669 EXPECT_EQ(0u, | 1557 EXPECT_EQ(0u, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1683 socket_data.StopAfter(1); | 1571 socket_data.StopAfter(1); |
| 1684 | 1572 |
| 1685 crypto_client_stream_factory_.set_handshake_mode( | 1573 crypto_client_stream_factory_.set_handshake_mode( |
| 1686 MockCryptoClientStream::ZERO_RTT); | 1574 MockCryptoClientStream::ZERO_RTT); |
| 1687 host_resolver_.set_synchronous_mode(true); | 1575 host_resolver_.set_synchronous_mode(true); |
| 1688 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1576 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1689 "192.168.0.1", ""); | 1577 "192.168.0.1", ""); |
| 1690 | 1578 |
| 1691 QuicStreamRequest request(&factory_); | 1579 QuicStreamRequest request(&factory_); |
| 1692 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1580 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1693 "GET", net_log_, callback_.callback())); | 1581 host_port_pair_.host(), "GET", net_log_, |
| 1582 callback_.callback())); |
| 1694 | 1583 |
| 1695 // If we are waiting for disk cache, we would have posted a task. Verify that | 1584 // If we are waiting for disk cache, we would have posted a task. Verify that |
| 1696 // the CancelWaitForDataReady task hasn't been posted. | 1585 // the CancelWaitForDataReady task hasn't been posted. |
| 1697 ASSERT_EQ(0u, runner_->GetPostedTasks().size()); | 1586 ASSERT_EQ(0u, runner_->GetPostedTasks().size()); |
| 1698 | 1587 |
| 1699 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 1588 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1700 EXPECT_TRUE(stream.get()); | 1589 EXPECT_TRUE(stream.get()); |
| 1701 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1590 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1702 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1591 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1703 } | 1592 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1733 crypto_client_stream_factory_.set_handshake_mode( | 1622 crypto_client_stream_factory_.set_handshake_mode( |
| 1734 MockCryptoClientStream::ZERO_RTT); | 1623 MockCryptoClientStream::ZERO_RTT); |
| 1735 host_resolver_.set_synchronous_mode(true); | 1624 host_resolver_.set_synchronous_mode(true); |
| 1736 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), | 1625 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), |
| 1737 "192.168.0.1", ""); | 1626 "192.168.0.1", ""); |
| 1738 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); | 1627 host_resolver_.rules()->AddIPLiteralRule(server2.host(), "192.168.0.1", ""); |
| 1739 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); | 1628 host_resolver_.rules()->AddIPLiteralRule(server3.host(), "192.168.0.1", ""); |
| 1740 | 1629 |
| 1741 QuicStreamRequest request(&factory_); | 1630 QuicStreamRequest request(&factory_); |
| 1742 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, | 1631 EXPECT_EQ(OK, request.Request(host_port_pair_, is_https_, privacy_mode_, |
| 1743 "GET", net_log_, callback_.callback())); | 1632 host_port_pair_.host(), "GET", net_log_, |
| 1633 callback_.callback())); |
| 1744 | 1634 |
| 1745 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( | 1635 QuicClientSession* session = QuicStreamFactoryPeer::GetActiveSession( |
| 1746 &factory_, host_port_pair_, is_https_); | 1636 &factory_, host_port_pair_, is_https_); |
| 1747 | 1637 |
| 1748 DVLOG(1) << "Create 1st session and test packet loss"; | 1638 DVLOG(1) << "Create 1st session and test packet loss"; |
| 1749 | 1639 |
| 1750 // Set packet_loss_rate to a lower value than packet_loss_threshold. | 1640 // Set packet_loss_rate to a lower value than packet_loss_threshold. |
| 1751 EXPECT_FALSE( | 1641 EXPECT_FALSE( |
| 1752 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); | 1642 factory_.OnHandshakeConfirmed(session, /*packet_loss_rate=*/0.9f)); |
| 1753 EXPECT_TRUE(session->connection()->connected()); | 1643 EXPECT_TRUE(session->connection()->connected()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1769 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( | 1659 EXPECT_FALSE(QuicStreamFactoryPeer::HasActiveSession( |
| 1770 &factory_, host_port_pair_, is_https_)); | 1660 &factory_, host_port_pair_, is_https_)); |
| 1771 EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get()); | 1661 EXPECT_EQ(nullptr, CreateIfSessionExists(host_port_pair_, net_log_).get()); |
| 1772 | 1662 |
| 1773 // Test N-in-a-row high packet loss connections. | 1663 // Test N-in-a-row high packet loss connections. |
| 1774 | 1664 |
| 1775 DVLOG(1) << "Create 2nd session and test packet loss"; | 1665 DVLOG(1) << "Create 2nd session and test packet loss"; |
| 1776 | 1666 |
| 1777 TestCompletionCallback callback2; | 1667 TestCompletionCallback callback2; |
| 1778 QuicStreamRequest request2(&factory_); | 1668 QuicStreamRequest request2(&factory_); |
| 1779 EXPECT_EQ(OK, request2.Request(server2, is_https_, privacy_mode_, "GET", | 1669 EXPECT_EQ(OK, |
| 1780 net_log_, callback2.callback())); | 1670 request2.Request(server2, is_https_, privacy_mode_, server2.host(), |
| 1671 "GET", net_log_, callback2.callback())); |
| 1781 QuicClientSession* session2 = | 1672 QuicClientSession* session2 = |
| 1782 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); | 1673 QuicStreamFactoryPeer::GetActiveSession(&factory_, server2, is_https_); |
| 1783 | 1674 |
| 1784 // If there is no packet loss during handshake confirmation, number of lossy | 1675 // If there is no packet loss during handshake confirmation, number of lossy |
| 1785 // connections for the port should be 0. | 1676 // connections for the port should be 0. |
| 1786 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1677 EXPECT_EQ(1, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1787 &factory_, server2.port())); | 1678 &factory_, server2.port())); |
| 1788 EXPECT_FALSE( | 1679 EXPECT_FALSE( |
| 1789 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); | 1680 factory_.OnHandshakeConfirmed(session2, /*packet_loss_rate=*/0.9f)); |
| 1790 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1681 EXPECT_EQ(0, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1802 EXPECT_FALSE( | 1693 EXPECT_FALSE( |
| 1803 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); | 1694 QuicStreamFactoryPeer::IsQuicDisabled(&factory_, server2.port())); |
| 1804 EXPECT_FALSE( | 1695 EXPECT_FALSE( |
| 1805 QuicStreamFactoryPeer::HasActiveSession(&factory_, server2, is_https_)); | 1696 QuicStreamFactoryPeer::HasActiveSession(&factory_, server2, is_https_)); |
| 1806 EXPECT_EQ(nullptr, CreateIfSessionExists(server2, net_log_).get()); | 1697 EXPECT_EQ(nullptr, CreateIfSessionExists(server2, net_log_).get()); |
| 1807 | 1698 |
| 1808 DVLOG(1) << "Create 3rd session which also has packet loss"; | 1699 DVLOG(1) << "Create 3rd session which also has packet loss"; |
| 1809 | 1700 |
| 1810 TestCompletionCallback callback3; | 1701 TestCompletionCallback callback3; |
| 1811 QuicStreamRequest request3(&factory_); | 1702 QuicStreamRequest request3(&factory_); |
| 1812 EXPECT_EQ(OK, request3.Request(server3, is_https_, privacy_mode_, "GET", | 1703 EXPECT_EQ(OK, |
| 1813 net_log_, callback3.callback())); | 1704 request3.Request(server3, is_https_, privacy_mode_, server3.host(), |
| 1705 "GET", net_log_, callback3.callback())); |
| 1814 QuicClientSession* session3 = | 1706 QuicClientSession* session3 = |
| 1815 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); | 1707 QuicStreamFactoryPeer::GetActiveSession(&factory_, server3, is_https_); |
| 1816 | 1708 |
| 1817 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in | 1709 // Set packet_loss_rate to higher value than packet_loss_threshold 2nd time in |
| 1818 // a row and that should close the session and disable QUIC. | 1710 // a row and that should close the session and disable QUIC. |
| 1819 EXPECT_TRUE( | 1711 EXPECT_TRUE( |
| 1820 factory_.OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); | 1712 factory_.OnHandshakeConfirmed(session3, /*packet_loss_rate=*/1.0f)); |
| 1821 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( | 1713 EXPECT_EQ(2, QuicStreamFactoryPeer::GetNumberOfLossyConnections( |
| 1822 &factory_, server3.port())); | 1714 &factory_, server3.port())); |
| 1823 EXPECT_FALSE(session2->connection()->connected()); | 1715 EXPECT_FALSE(session2->connection()->connected()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1835 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1727 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1836 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1728 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1837 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1729 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1838 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1730 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1839 EXPECT_TRUE(socket_data3.AllReadDataConsumed()); | 1731 EXPECT_TRUE(socket_data3.AllReadDataConsumed()); |
| 1840 EXPECT_TRUE(socket_data3.AllWriteDataConsumed()); | 1732 EXPECT_TRUE(socket_data3.AllWriteDataConsumed()); |
| 1841 } | 1733 } |
| 1842 | 1734 |
| 1843 } // namespace test | 1735 } // namespace test |
| 1844 } // namespace net | 1736 } // namespace net |
| OLD | NEW |