| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "net/base/test_data_directory.h" | 10 #include "net/base/test_data_directory.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 max_number_of_lossy_connections_(0), | 213 max_number_of_lossy_connections_(0), |
| 214 packet_loss_threshold_(1.0f), | 214 packet_loss_threshold_(1.0f), |
| 215 max_disabled_reasons_(3), | 215 max_disabled_reasons_(3), |
| 216 threshold_timeouts_with_open_streams_(2), | 216 threshold_timeouts_with_open_streams_(2), |
| 217 threshold_public_resets_post_handshake_(2), | 217 threshold_public_resets_post_handshake_(2), |
| 218 receive_buffer_size_(0), | 218 receive_buffer_size_(0), |
| 219 delay_tcp_race_(false), | 219 delay_tcp_race_(false), |
| 220 close_sessions_on_ip_change_(false), | 220 close_sessions_on_ip_change_(false), |
| 221 disable_quic_on_timeout_with_open_streams_(false), | 221 disable_quic_on_timeout_with_open_streams_(false), |
| 222 idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds), | 222 idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds), |
| 223 migrate_sessions_on_network_change_(false) { | 223 migrate_sessions_on_network_change_(false), |
| 224 migrate_sessions_early_(false) { |
| 224 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 225 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 225 } | 226 } |
| 226 | 227 |
| 227 void Initialize() { | 228 void Initialize() { |
| 228 factory_.reset(new QuicStreamFactory( | 229 factory_.reset(new QuicStreamFactory( |
| 229 &host_resolver_, &socket_factory_, http_server_properties_.GetWeakPtr(), | 230 &host_resolver_, &socket_factory_, http_server_properties_.GetWeakPtr(), |
| 230 cert_verifier_.get(), nullptr, channel_id_service_.get(), | 231 cert_verifier_.get(), nullptr, channel_id_service_.get(), |
| 231 &transport_security_state_, cert_transparency_verifier_.get(), | 232 &transport_security_state_, cert_transparency_verifier_.get(), |
| 232 /*SocketPerformanceWatcherFactory*/ nullptr, | 233 /*SocketPerformanceWatcherFactory*/ nullptr, |
| 233 &crypto_client_stream_factory_, &random_generator_, clock_, | 234 &crypto_client_stream_factory_, &random_generator_, clock_, |
| 234 kDefaultMaxPacketSize, std::string(), | 235 kDefaultMaxPacketSize, std::string(), |
| 235 SupportedVersions(GetParam().version), enable_port_selection_, | 236 SupportedVersions(GetParam().version), enable_port_selection_, |
| 236 always_require_handshake_confirmation_, disable_connection_pooling_, | 237 always_require_handshake_confirmation_, disable_connection_pooling_, |
| 237 load_server_info_timeout_srtt_multiplier_, enable_connection_racing_, | 238 load_server_info_timeout_srtt_multiplier_, enable_connection_racing_, |
| 238 enable_non_blocking_io_, disable_disk_cache_, prefer_aes_, | 239 enable_non_blocking_io_, disable_disk_cache_, prefer_aes_, |
| 239 max_number_of_lossy_connections_, packet_loss_threshold_, | 240 max_number_of_lossy_connections_, packet_loss_threshold_, |
| 240 max_disabled_reasons_, threshold_timeouts_with_open_streams_, | 241 max_disabled_reasons_, threshold_timeouts_with_open_streams_, |
| 241 threshold_public_resets_post_handshake_, receive_buffer_size_, | 242 threshold_public_resets_post_handshake_, receive_buffer_size_, |
| 242 delay_tcp_race_, /*max_server_configs_stored_in_properties*/ 0, | 243 delay_tcp_race_, /*max_server_configs_stored_in_properties*/ 0, |
| 243 close_sessions_on_ip_change_, | 244 close_sessions_on_ip_change_, |
| 244 disable_quic_on_timeout_with_open_streams_, | 245 disable_quic_on_timeout_with_open_streams_, |
| 245 idle_connection_timeout_seconds_, migrate_sessions_on_network_change_, | 246 idle_connection_timeout_seconds_, migrate_sessions_on_network_change_, |
| 246 QuicTagVector())); | 247 migrate_sessions_early_, QuicTagVector())); |
| 247 factory_->set_require_confirmation(false); | 248 factory_->set_require_confirmation(false); |
| 248 EXPECT_FALSE(factory_->has_quic_server_info_factory()); | 249 EXPECT_FALSE(factory_->has_quic_server_info_factory()); |
| 249 factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory()); | 250 factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory()); |
| 250 EXPECT_TRUE(factory_->has_quic_server_info_factory()); | 251 EXPECT_TRUE(factory_->has_quic_server_info_factory()); |
| 251 } | 252 } |
| 252 | 253 |
| 253 void InitializeConnectionMigrationTest( | 254 void InitializeConnectionMigrationTest( |
| 254 NetworkChangeNotifier::NetworkList connected_networks) { | 255 NetworkChangeNotifier::NetworkList connected_networks) { |
| 255 scoped_mock_network_change_notifier_.reset( | 256 scoped_mock_network_change_notifier_.reset( |
| 256 new ScopedMockNetworkChangeNotifier()); | 257 new ScopedMockNetworkChangeNotifier()); |
| 257 MockNetworkChangeNotifier* mock_ncn = | 258 MockNetworkChangeNotifier* mock_ncn = |
| 258 scoped_mock_network_change_notifier_->mock_network_change_notifier(); | 259 scoped_mock_network_change_notifier_->mock_network_change_notifier(); |
| 259 mock_ncn->ForceNetworkHandlesSupported(); | 260 mock_ncn->ForceNetworkHandlesSupported(); |
| 260 mock_ncn->SetConnectedNetworksList(connected_networks); | 261 mock_ncn->SetConnectedNetworksList(connected_networks); |
| 261 migrate_sessions_on_network_change_ = true; | 262 migrate_sessions_on_network_change_ = true; |
| 263 migrate_sessions_early_ = true; |
| 262 Initialize(); | 264 Initialize(); |
| 263 } | 265 } |
| 264 | 266 |
| 265 bool HasActiveSession(const HostPortPair& host_port_pair) { | 267 bool HasActiveSession(const HostPortPair& host_port_pair) { |
| 266 return QuicStreamFactoryPeer::HasActiveSession(factory_.get(), | 268 return QuicStreamFactoryPeer::HasActiveSession(factory_.get(), |
| 267 host_port_pair); | 269 host_port_pair); |
| 268 } | 270 } |
| 269 | 271 |
| 270 scoped_ptr<QuicHttpStream> CreateFromSession( | 272 scoped_ptr<QuicHttpStream> CreateFromSession( |
| 271 const HostPortPair& host_port_pair) { | 273 const HostPortPair& host_port_pair) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 double packet_loss_threshold_; | 414 double packet_loss_threshold_; |
| 413 int max_disabled_reasons_; | 415 int max_disabled_reasons_; |
| 414 int threshold_timeouts_with_open_streams_; | 416 int threshold_timeouts_with_open_streams_; |
| 415 int threshold_public_resets_post_handshake_; | 417 int threshold_public_resets_post_handshake_; |
| 416 int receive_buffer_size_; | 418 int receive_buffer_size_; |
| 417 bool delay_tcp_race_; | 419 bool delay_tcp_race_; |
| 418 bool close_sessions_on_ip_change_; | 420 bool close_sessions_on_ip_change_; |
| 419 bool disable_quic_on_timeout_with_open_streams_; | 421 bool disable_quic_on_timeout_with_open_streams_; |
| 420 int idle_connection_timeout_seconds_; | 422 int idle_connection_timeout_seconds_; |
| 421 bool migrate_sessions_on_network_change_; | 423 bool migrate_sessions_on_network_change_; |
| 424 bool migrate_sessions_early_; |
| 422 }; | 425 }; |
| 423 | 426 |
| 424 INSTANTIATE_TEST_CASE_P(Version, | 427 INSTANTIATE_TEST_CASE_P(Version, |
| 425 QuicStreamFactoryTest, | 428 QuicStreamFactoryTest, |
| 426 ::testing::ValuesIn(GetTestParams())); | 429 ::testing::ValuesIn(GetTestParams())); |
| 427 | 430 |
| 428 TEST_P(QuicStreamFactoryTest, Create) { | 431 TEST_P(QuicStreamFactoryTest, Create) { |
| 429 Initialize(); | 432 Initialize(); |
| 430 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 433 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 431 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 434 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 EXPECT_EQ(ERR_IO_PENDING, | 1455 EXPECT_EQ(ERR_IO_PENDING, |
| 1453 request2.Request(host_port_pair_, privacy_mode_, | 1456 request2.Request(host_port_pair_, privacy_mode_, |
| 1454 /*cert_verify_flags=*/0, host_port_pair_.host(), | 1457 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1455 "GET", net_log_, callback_.callback())); | 1458 "GET", net_log_, callback_.callback())); |
| 1456 EXPECT_EQ(OK, callback_.WaitForResult()); | 1459 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1457 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); | 1460 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1458 EXPECT_TRUE(stream2.get()); | 1461 EXPECT_TRUE(stream2.get()); |
| 1459 | 1462 |
| 1460 EXPECT_TRUE( | 1463 EXPECT_TRUE( |
| 1461 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); | 1464 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 1462 EXPECT_NE(session, QuicStreamFactoryPeer::GetActiveSession(factory_.get(), | 1465 QuicChromiumClientSession* new_session = |
| 1463 host_port_pair_)); | 1466 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 1467 EXPECT_NE(session, new_session); |
| 1464 | 1468 |
| 1465 // On a DISCONNECTED notification, nothing happens to the migrated session. | 1469 // On a DISCONNECTED notification, nothing happens to the migrated |
| 1470 // session, but the new session is closed since it has no open |
| 1471 // streams. |
| 1466 scoped_mock_network_change_notifier_->mock_network_change_notifier() | 1472 scoped_mock_network_change_notifier_->mock_network_change_notifier() |
| 1467 ->NotifyNetworkDisconnected(kDefaultNetworkForTests); | 1473 ->NotifyNetworkDisconnected(kDefaultNetworkForTests); |
| 1468 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); | 1474 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1469 EXPECT_EQ(1u, session->GetNumActiveStreams()); | 1475 EXPECT_EQ(1u, session->GetNumActiveStreams()); |
| 1476 EXPECT_FALSE( |
| 1477 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), new_session)); |
| 1470 | 1478 |
| 1471 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1479 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1472 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1480 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1473 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); | 1481 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 1474 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); | 1482 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 1475 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); | 1483 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1476 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); | 1484 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1477 } | 1485 } |
| 1478 | 1486 |
| 1479 TEST_P(QuicStreamFactoryTest, OnNetworkChangeDisconnected) { | 1487 TEST_P(QuicStreamFactoryTest, OnNetworkChangeDisconnected) { |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 scoped_mock_network_change_notifier_->mock_network_change_notifier() | 1860 scoped_mock_network_change_notifier_->mock_network_change_notifier() |
| 1853 ->NotifyNetworkDisconnected(kDefaultNetworkForTests); | 1861 ->NotifyNetworkDisconnected(kDefaultNetworkForTests); |
| 1854 | 1862 |
| 1855 EXPECT_FALSE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); | 1863 EXPECT_FALSE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1856 EXPECT_FALSE(HasActiveSession(host_port_pair_)); | 1864 EXPECT_FALSE(HasActiveSession(host_port_pair_)); |
| 1857 | 1865 |
| 1858 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 1866 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1859 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 1867 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1860 } | 1868 } |
| 1861 | 1869 |
| 1870 TEST_P(QuicStreamFactoryTest, MigrateSessionEarly) { |
| 1871 InitializeConnectionMigrationTest( |
| 1872 {kDefaultNetworkForTests, kNewNetworkForTests}); |
| 1873 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 1874 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1875 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1876 |
| 1877 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1878 scoped_ptr<QuicEncryptedPacket> request_packet( |
| 1879 ConstructGetRequestPacket(1, kClientDataStreamId1, true, true)); |
| 1880 MockWrite writes[] = {MockWrite(SYNCHRONOUS, request_packet->data(), |
| 1881 request_packet->length(), 1)}; |
| 1882 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 1883 arraysize(writes)); |
| 1884 socket_factory_.AddSocketDataProvider(&socket_data); |
| 1885 |
| 1886 // Create request and QuicHttpStream. |
| 1887 QuicStreamRequest request(factory_.get()); |
| 1888 EXPECT_EQ(ERR_IO_PENDING, |
| 1889 request.Request(host_port_pair_, privacy_mode_, |
| 1890 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1891 "GET", net_log_, callback_.callback())); |
| 1892 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1893 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 1894 EXPECT_TRUE(stream.get()); |
| 1895 |
| 1896 // Cause QUIC stream to be created. |
| 1897 HttpRequestInfo request_info; |
| 1898 request_info.method = "GET"; |
| 1899 request_info.url = GURL("https://www.example.org/"); |
| 1900 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 1901 net_log_, CompletionCallback())); |
| 1902 |
| 1903 // Ensure that session is alive and active. |
| 1904 QuicChromiumClientSession* session = |
| 1905 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 1906 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1907 EXPECT_TRUE(HasActiveSession(host_port_pair_)); |
| 1908 |
| 1909 // Send GET request on stream. |
| 1910 HttpResponseInfo response; |
| 1911 HttpRequestHeaders request_headers; |
| 1912 EXPECT_EQ(OK, stream->SendRequest(request_headers, &response, |
| 1913 callback_.callback())); |
| 1914 |
| 1915 // Set up second socket data provider that is used after migration. |
| 1916 // The response to the earlier request is read on this new socket. |
| 1917 scoped_ptr<QuicEncryptedPacket> ping( |
| 1918 maker_.MakePingPacket(2, /*include_version=*/true)); |
| 1919 MockWrite writes1[] = { |
| 1920 MockWrite(SYNCHRONOUS, ping->data(), ping->length(), 0)}; |
| 1921 scoped_ptr<QuicEncryptedPacket> response_headers_packet( |
| 1922 ConstructOkResponsePacket(1, kClientDataStreamId1, false, false)); |
| 1923 MockRead reads1[] = {MockRead(ASYNC, response_headers_packet->data(), |
| 1924 response_headers_packet->length(), 1), |
| 1925 MockRead(SYNCHRONOUS, ERR_IO_PENDING, 2)}; |
| 1926 SequencedSocketData socket_data1(reads1, arraysize(reads1), writes1, |
| 1927 arraysize(writes1)); |
| 1928 socket_factory_.AddSocketDataProvider(&socket_data1); |
| 1929 |
| 1930 // Trigger early connection migration. This should cause a PING frame |
| 1931 // to be emitted. |
| 1932 session->OnPathDegrading(); |
| 1933 |
| 1934 // Run the message loop so that data queued in the new socket is read by the |
| 1935 // packet reader. |
| 1936 base::RunLoop().RunUntilIdle(); |
| 1937 |
| 1938 // The session should now be marked as going away. Ensure that |
| 1939 // while it is still alive, it is no longer active. |
| 1940 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1941 EXPECT_FALSE(HasActiveSession(host_port_pair_)); |
| 1942 EXPECT_EQ(1u, session->GetNumActiveStreams()); |
| 1943 |
| 1944 // Verify that response headers on the migrated socket were delivered to the |
| 1945 // stream. |
| 1946 EXPECT_EQ(OK, stream->ReadResponseHeaders(callback_.callback())); |
| 1947 EXPECT_EQ(200, response.headers->response_code()); |
| 1948 |
| 1949 // Create a new request for the same destination and verify that a |
| 1950 // new session is created. |
| 1951 MockRead reads2[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1952 SequencedSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0); |
| 1953 socket_factory_.AddSocketDataProvider(&socket_data2); |
| 1954 |
| 1955 QuicStreamRequest request2(factory_.get()); |
| 1956 EXPECT_EQ(ERR_IO_PENDING, |
| 1957 request2.Request(host_port_pair_, privacy_mode_, |
| 1958 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 1959 "GET", net_log_, callback_.callback())); |
| 1960 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 1961 scoped_ptr<QuicHttpStream> stream2 = request2.ReleaseStream(); |
| 1962 EXPECT_TRUE(stream2.get()); |
| 1963 |
| 1964 EXPECT_TRUE( |
| 1965 QuicStreamFactoryPeer::HasActiveSession(factory_.get(), host_port_pair_)); |
| 1966 QuicChromiumClientSession* new_session = |
| 1967 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 1968 EXPECT_NE(session, new_session); |
| 1969 |
| 1970 // On a SOON_TO_DISCONNECT notification, nothing happens to the |
| 1971 // migrated session, but the new session is closed since it has no |
| 1972 // open streams. |
| 1973 scoped_mock_network_change_notifier_->mock_network_change_notifier() |
| 1974 ->NotifyNetworkSoonToDisconnect(kDefaultNetworkForTests); |
| 1975 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1976 EXPECT_EQ(1u, session->GetNumActiveStreams()); |
| 1977 EXPECT_FALSE( |
| 1978 QuicStreamFactoryPeer::IsLiveSession(factory_.get(), new_session)); |
| 1979 |
| 1980 // On a DISCONNECTED notification, nothing happens to the migrated session. |
| 1981 scoped_mock_network_change_notifier_->mock_network_change_notifier() |
| 1982 ->NotifyNetworkDisconnected(kDefaultNetworkForTests); |
| 1983 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 1984 EXPECT_EQ(1u, session->GetNumActiveStreams()); |
| 1985 |
| 1986 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 1987 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 1988 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); |
| 1989 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); |
| 1990 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); |
| 1991 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); |
| 1992 } |
| 1993 |
| 1994 TEST_P(QuicStreamFactoryTest, MigrateSessionEarlyNoNewNetwork) { |
| 1995 InitializeConnectionMigrationTest({kDefaultNetworkForTests}); |
| 1996 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 1997 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1998 |
| 1999 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 2000 scoped_ptr<QuicEncryptedPacket> client_rst(maker_.MakeRstPacket( |
| 2001 1, true, kClientDataStreamId1, QUIC_STREAM_CANCELLED)); |
| 2002 MockWrite writes[] = { |
| 2003 MockWrite(SYNCHRONOUS, client_rst->data(), client_rst->length(), 1), |
| 2004 }; |
| 2005 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 2006 arraysize(writes)); |
| 2007 socket_factory_.AddSocketDataProvider(&socket_data); |
| 2008 |
| 2009 // Create request and QuicHttpStream. |
| 2010 QuicStreamRequest request(factory_.get()); |
| 2011 EXPECT_EQ(ERR_IO_PENDING, |
| 2012 request.Request(host_port_pair_, privacy_mode_, |
| 2013 /*cert_verify_flags=*/0, host_port_pair_.host(), |
| 2014 "GET", net_log_, callback_.callback())); |
| 2015 EXPECT_EQ(OK, callback_.WaitForResult()); |
| 2016 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2017 EXPECT_TRUE(stream.get()); |
| 2018 |
| 2019 // Cause QUIC stream to be created. |
| 2020 HttpRequestInfo request_info; |
| 2021 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY, |
| 2022 net_log_, CompletionCallback())); |
| 2023 |
| 2024 // Ensure that session is alive and active. |
| 2025 QuicChromiumClientSession* session = |
| 2026 QuicStreamFactoryPeer::GetActiveSession(factory_.get(), host_port_pair_); |
| 2027 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 2028 EXPECT_TRUE(HasActiveSession(host_port_pair_)); |
| 2029 |
| 2030 // Trigger connection migration. Since there are no networks |
| 2031 // to migrate to, this should cause session to be continue but be marked as |
| 2032 // going away. |
| 2033 session->OnPathDegrading(); |
| 2034 |
| 2035 // Run the message loop so that data queued in the new socket is read by the |
| 2036 // packet reader. |
| 2037 base::RunLoop().RunUntilIdle(); |
| 2038 |
| 2039 EXPECT_TRUE(QuicStreamFactoryPeer::IsLiveSession(factory_.get(), session)); |
| 2040 EXPECT_TRUE(HasActiveSession(host_port_pair_)); |
| 2041 EXPECT_EQ(1u, session->GetNumActiveStreams()); |
| 2042 |
| 2043 stream.reset(); |
| 2044 |
| 2045 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 2046 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 2047 } |
| 2048 |
| 1862 TEST_P(QuicStreamFactoryTest, OnSSLConfigChanged) { | 2049 TEST_P(QuicStreamFactoryTest, OnSSLConfigChanged) { |
| 1863 Initialize(); | 2050 Initialize(); |
| 1864 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 2051 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
| 1865 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 2052 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1866 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 2053 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 1867 | 2054 |
| 1868 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 2055 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 1869 scoped_ptr<QuicEncryptedPacket> rst(ConstructRstPacket()); | 2056 scoped_ptr<QuicEncryptedPacket> rst(ConstructRstPacket()); |
| 1870 std::vector<MockWrite> writes; | 2057 std::vector<MockWrite> writes; |
| 1871 writes.push_back(MockWrite(ASYNC, rst->data(), rst->length(), 1)); | 2058 writes.push_back(MockWrite(ASYNC, rst->data(), rst->length(), 1)); |
| (...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3349 EXPECT_EQ(1u, observer.executed_count()); | 3536 EXPECT_EQ(1u, observer.executed_count()); |
| 3350 | 3537 |
| 3351 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 3538 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 3352 EXPECT_TRUE(stream.get()); | 3539 EXPECT_TRUE(stream.get()); |
| 3353 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 3540 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 3354 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 3541 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 3355 } | 3542 } |
| 3356 | 3543 |
| 3357 } // namespace test | 3544 } // namespace test |
| 3358 } // namespace net | 3545 } // namespace net |
| OLD | NEW |