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 <ostream> | 7 #include <ostream> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 packet_loss_threshold_(1.0f), | 313 packet_loss_threshold_(1.0f), |
314 max_disabled_reasons_(3), | 314 max_disabled_reasons_(3), |
315 threshold_timeouts_with_open_streams_(2), | 315 threshold_timeouts_with_open_streams_(2), |
316 threshold_public_resets_post_handshake_(2), | 316 threshold_public_resets_post_handshake_(2), |
317 receive_buffer_size_(0), | 317 receive_buffer_size_(0), |
318 delay_tcp_race_(true), | 318 delay_tcp_race_(true), |
319 close_sessions_on_ip_change_(false), | 319 close_sessions_on_ip_change_(false), |
320 disable_quic_on_timeout_with_open_streams_(false), | 320 disable_quic_on_timeout_with_open_streams_(false), |
321 idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds), | 321 idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds), |
322 migrate_sessions_on_network_change_(false), | 322 migrate_sessions_on_network_change_(false), |
323 migrate_sessions_early_(false) { | 323 migrate_sessions_early_(false), |
| 324 force_hol_blocking_(false) { |
324 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 325 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
325 } | 326 } |
326 | 327 |
327 ~QuicStreamFactoryTestBase() { | 328 ~QuicStreamFactoryTestBase() { |
328 // If |factory_| was initialized, then it took over ownership of |clock_|. | 329 // If |factory_| was initialized, then it took over ownership of |clock_|. |
329 // If |factory_| was not initialized, then |clock_| needs to be destroyed. | 330 // If |factory_| was not initialized, then |clock_| needs to be destroyed. |
330 if (!factory_) { | 331 if (!factory_) { |
331 delete clock_; | 332 delete clock_; |
332 } | 333 } |
333 } | 334 } |
(...skipping 11 matching lines...) Expand all Loading... |
345 enable_port_selection_, always_require_handshake_confirmation_, | 346 enable_port_selection_, always_require_handshake_confirmation_, |
346 disable_connection_pooling_, load_server_info_timeout_srtt_multiplier_, | 347 disable_connection_pooling_, load_server_info_timeout_srtt_multiplier_, |
347 enable_connection_racing_, enable_non_blocking_io_, disable_disk_cache_, | 348 enable_connection_racing_, enable_non_blocking_io_, disable_disk_cache_, |
348 prefer_aes_, max_number_of_lossy_connections_, packet_loss_threshold_, | 349 prefer_aes_, max_number_of_lossy_connections_, packet_loss_threshold_, |
349 max_disabled_reasons_, threshold_timeouts_with_open_streams_, | 350 max_disabled_reasons_, threshold_timeouts_with_open_streams_, |
350 threshold_public_resets_post_handshake_, receive_buffer_size_, | 351 threshold_public_resets_post_handshake_, receive_buffer_size_, |
351 delay_tcp_race_, /*max_server_configs_stored_in_properties*/ 0, | 352 delay_tcp_race_, /*max_server_configs_stored_in_properties*/ 0, |
352 close_sessions_on_ip_change_, | 353 close_sessions_on_ip_change_, |
353 disable_quic_on_timeout_with_open_streams_, | 354 disable_quic_on_timeout_with_open_streams_, |
354 idle_connection_timeout_seconds_, migrate_sessions_on_network_change_, | 355 idle_connection_timeout_seconds_, migrate_sessions_on_network_change_, |
355 migrate_sessions_early_, QuicTagVector(), | 356 migrate_sessions_early_, force_hol_blocking_, QuicTagVector(), |
356 /*enable_token_binding*/ false)); | 357 /*enable_token_binding*/ false)); |
357 factory_->set_require_confirmation(false); | 358 factory_->set_require_confirmation(false); |
358 EXPECT_FALSE(factory_->has_quic_server_info_factory()); | 359 EXPECT_FALSE(factory_->has_quic_server_info_factory()); |
359 factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory()); | 360 factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory()); |
360 EXPECT_TRUE(factory_->has_quic_server_info_factory()); | 361 EXPECT_TRUE(factory_->has_quic_server_info_factory()); |
361 } | 362 } |
362 | 363 |
363 void InitializeConnectionMigrationTest( | 364 void InitializeConnectionMigrationTest( |
364 NetworkChangeNotifier::NetworkList connected_networks) { | 365 NetworkChangeNotifier::NetworkList connected_networks) { |
365 scoped_mock_network_change_notifier_.reset( | 366 scoped_mock_network_change_notifier_.reset( |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 int max_disabled_reasons_; | 539 int max_disabled_reasons_; |
539 int threshold_timeouts_with_open_streams_; | 540 int threshold_timeouts_with_open_streams_; |
540 int threshold_public_resets_post_handshake_; | 541 int threshold_public_resets_post_handshake_; |
541 int receive_buffer_size_; | 542 int receive_buffer_size_; |
542 bool delay_tcp_race_; | 543 bool delay_tcp_race_; |
543 bool close_sessions_on_ip_change_; | 544 bool close_sessions_on_ip_change_; |
544 bool disable_quic_on_timeout_with_open_streams_; | 545 bool disable_quic_on_timeout_with_open_streams_; |
545 int idle_connection_timeout_seconds_; | 546 int idle_connection_timeout_seconds_; |
546 bool migrate_sessions_on_network_change_; | 547 bool migrate_sessions_on_network_change_; |
547 bool migrate_sessions_early_; | 548 bool migrate_sessions_early_; |
| 549 bool force_hol_blocking_; |
548 }; | 550 }; |
549 | 551 |
550 class QuicStreamFactoryTest : public QuicStreamFactoryTestBase, | 552 class QuicStreamFactoryTest : public QuicStreamFactoryTestBase, |
551 public ::testing::TestWithParam<TestParams> { | 553 public ::testing::TestWithParam<TestParams> { |
552 protected: | 554 protected: |
553 QuicStreamFactoryTest() | 555 QuicStreamFactoryTest() |
554 : QuicStreamFactoryTestBase(GetParam().version, | 556 : QuicStreamFactoryTestBase(GetParam().version, |
555 GetParam().enable_connection_racing) {} | 557 GetParam().enable_connection_racing) {} |
556 }; | 558 }; |
557 | 559 |
(...skipping 3829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4387 QuicChromiumClientSession* session2 = | 4389 QuicChromiumClientSession* session2 = |
4388 QuicHttpStreamPeer::GetSession(stream2.get()); | 4390 QuicHttpStreamPeer::GetSession(stream2.get()); |
4389 EXPECT_EQ(session1, session2); | 4391 EXPECT_EQ(session1, session2); |
4390 EXPECT_EQ(QuicServerId(host_port_pair_, privacy_mode_), | 4392 EXPECT_EQ(QuicServerId(host_port_pair_, privacy_mode_), |
4391 session1->server_id()); | 4393 session1->server_id()); |
4392 | 4394 |
4393 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 4395 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
4394 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 4396 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
4395 } | 4397 } |
4396 | 4398 |
| 4399 TEST_P(QuicStreamFactoryTest, ForceHolBlockingEnabled) { |
| 4400 force_hol_blocking_ = true; |
| 4401 Initialize(); |
| 4402 |
| 4403 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 4404 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 4405 |
| 4406 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 4407 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); |
| 4408 socket_factory_.AddSocketDataProvider(&socket_data); |
| 4409 |
| 4410 QuicStreamRequest request(factory_.get()); |
| 4411 EXPECT_EQ(ERR_IO_PENDING, |
| 4412 request.Request(host_port_pair_, privacy_mode_, |
| 4413 /*cert_verify_flags=*/0, url_, "GET", net_log_, |
| 4414 callback_.callback())); |
| 4415 |
| 4416 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 4417 |
| 4418 QuicChromiumClientSession* session = GetActiveSession(host_port_pair_); |
| 4419 if (session->connection()->version() > QUIC_VERSION_35) { |
| 4420 EXPECT_TRUE(session->force_hol_blocking()); |
| 4421 } else { |
| 4422 EXPECT_FALSE(session->force_hol_blocking()); |
| 4423 } |
| 4424 } |
| 4425 |
4397 class QuicStreamFactoryWithDestinationTest | 4426 class QuicStreamFactoryWithDestinationTest |
4398 : public QuicStreamFactoryTestBase, | 4427 : public QuicStreamFactoryTestBase, |
4399 public ::testing::TestWithParam<PoolingTestParams> { | 4428 public ::testing::TestWithParam<PoolingTestParams> { |
4400 protected: | 4429 protected: |
4401 QuicStreamFactoryWithDestinationTest() | 4430 QuicStreamFactoryWithDestinationTest() |
4402 : QuicStreamFactoryTestBase(GetParam().version, | 4431 : QuicStreamFactoryTestBase(GetParam().version, |
4403 GetParam().enable_connection_racing), | 4432 GetParam().enable_connection_racing), |
4404 destination_type_(GetParam().destination_type), | 4433 destination_type_(GetParam().destination_type), |
4405 hanging_read_(SYNCHRONOUS, ERR_IO_PENDING, 0) {} | 4434 hanging_read_(SYNCHRONOUS, ERR_IO_PENDING, 0) {} |
4406 | 4435 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4675 EXPECT_NE(session1, session2); | 4704 EXPECT_NE(session1, session2); |
4676 | 4705 |
4677 EXPECT_EQ(QuicServerId(origin1_, privacy_mode_), session1->server_id()); | 4706 EXPECT_EQ(QuicServerId(origin1_, privacy_mode_), session1->server_id()); |
4678 EXPECT_EQ(QuicServerId(origin2_, privacy_mode_), session2->server_id()); | 4707 EXPECT_EQ(QuicServerId(origin2_, privacy_mode_), session2->server_id()); |
4679 | 4708 |
4680 EXPECT_TRUE(AllDataConsumed()); | 4709 EXPECT_TRUE(AllDataConsumed()); |
4681 } | 4710 } |
4682 | 4711 |
4683 } // namespace test | 4712 } // namespace test |
4684 } // namespace net | 4713 } // namespace net |
OLD | NEW |