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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 enable_non_blocking_io_(true), | 142 enable_non_blocking_io_(true), |
143 disable_disk_cache_(false), | 143 disable_disk_cache_(false), |
144 prefer_aes_(false), | 144 prefer_aes_(false), |
145 max_number_of_lossy_connections_(0), | 145 max_number_of_lossy_connections_(0), |
146 packet_loss_threshold_(1.0f), | 146 packet_loss_threshold_(1.0f), |
147 max_disabled_reasons_(3), | 147 max_disabled_reasons_(3), |
148 threshold_timeouts_with_open_streams_(2), | 148 threshold_timeouts_with_open_streams_(2), |
149 threshold_public_resets_post_handshake_(2), | 149 threshold_public_resets_post_handshake_(2), |
150 receive_buffer_size_(0), | 150 receive_buffer_size_(0), |
151 delay_tcp_race_(false), | 151 delay_tcp_race_(false), |
152 store_server_configs_in_properties_(false), | 152 number_of_server_configs_stored_in_properties_(0), |
153 close_sessions_on_ip_change_(false), | 153 close_sessions_on_ip_change_(false), |
154 idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds) { | 154 idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds) { |
155 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 155 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
156 } | 156 } |
157 | 157 |
158 void Initialize() { | 158 void Initialize() { |
159 factory_.reset(new QuicStreamFactory( | 159 factory_.reset(new QuicStreamFactory( |
160 &host_resolver_, &socket_factory_, http_server_properties_.GetWeakPtr(), | 160 &host_resolver_, &socket_factory_, http_server_properties_.GetWeakPtr(), |
161 cert_verifier_.get(), nullptr, channel_id_service_.get(), | 161 cert_verifier_.get(), nullptr, channel_id_service_.get(), |
162 &transport_security_state_, cert_transparency_verifier_.get(), | 162 &transport_security_state_, cert_transparency_verifier_.get(), |
163 /*SocketPerformanceWatcherFactory*/ nullptr, | 163 /*SocketPerformanceWatcherFactory*/ nullptr, |
164 &crypto_client_stream_factory_, &random_generator_, clock_, | 164 &crypto_client_stream_factory_, &random_generator_, clock_, |
165 kDefaultMaxPacketSize, std::string(), | 165 kDefaultMaxPacketSize, std::string(), |
166 SupportedVersions(GetParam().version), enable_port_selection_, | 166 SupportedVersions(GetParam().version), enable_port_selection_, |
167 always_require_handshake_confirmation_, disable_connection_pooling_, | 167 always_require_handshake_confirmation_, disable_connection_pooling_, |
168 load_server_info_timeout_srtt_multiplier_, enable_connection_racing_, | 168 load_server_info_timeout_srtt_multiplier_, enable_connection_racing_, |
169 enable_non_blocking_io_, disable_disk_cache_, prefer_aes_, | 169 enable_non_blocking_io_, disable_disk_cache_, prefer_aes_, |
170 max_number_of_lossy_connections_, packet_loss_threshold_, | 170 max_number_of_lossy_connections_, packet_loss_threshold_, |
171 max_disabled_reasons_, threshold_timeouts_with_open_streams_, | 171 max_disabled_reasons_, threshold_timeouts_with_open_streams_, |
172 threshold_public_resets_post_handshake_, receive_buffer_size_, | 172 threshold_public_resets_post_handshake_, receive_buffer_size_, |
173 delay_tcp_race_, store_server_configs_in_properties_, | 173 delay_tcp_race_, number_of_server_configs_stored_in_properties_, |
174 close_sessions_on_ip_change_, idle_connection_timeout_seconds_, | 174 close_sessions_on_ip_change_, idle_connection_timeout_seconds_, |
175 QuicTagVector())); | 175 QuicTagVector())); |
176 factory_->set_require_confirmation(false); | 176 factory_->set_require_confirmation(false); |
177 factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory()); | 177 factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory()); |
178 } | 178 } |
179 | 179 |
180 bool HasActiveSession(const HostPortPair& host_port_pair) { | 180 bool HasActiveSession(const HostPortPair& host_port_pair) { |
181 return QuicStreamFactoryPeer::HasActiveSession(factory_.get(), | 181 return QuicStreamFactoryPeer::HasActiveSession(factory_.get(), |
182 host_port_pair); | 182 host_port_pair); |
183 } | 183 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 bool enable_non_blocking_io_; | 295 bool enable_non_blocking_io_; |
296 bool disable_disk_cache_; | 296 bool disable_disk_cache_; |
297 bool prefer_aes_; | 297 bool prefer_aes_; |
298 int max_number_of_lossy_connections_; | 298 int max_number_of_lossy_connections_; |
299 double packet_loss_threshold_; | 299 double packet_loss_threshold_; |
300 int max_disabled_reasons_; | 300 int max_disabled_reasons_; |
301 int threshold_timeouts_with_open_streams_; | 301 int threshold_timeouts_with_open_streams_; |
302 int threshold_public_resets_post_handshake_; | 302 int threshold_public_resets_post_handshake_; |
303 int receive_buffer_size_; | 303 int receive_buffer_size_; |
304 bool delay_tcp_race_; | 304 bool delay_tcp_race_; |
305 bool store_server_configs_in_properties_; | 305 int number_of_server_configs_stored_in_properties_; |
306 bool close_sessions_on_ip_change_; | 306 bool close_sessions_on_ip_change_; |
307 int idle_connection_timeout_seconds_; | 307 int idle_connection_timeout_seconds_; |
308 }; | 308 }; |
309 | 309 |
310 INSTANTIATE_TEST_CASE_P(Version, | 310 INSTANTIATE_TEST_CASE_P(Version, |
311 QuicStreamFactoryTest, | 311 QuicStreamFactoryTest, |
312 ::testing::ValuesIn(GetTestParams())); | 312 ::testing::ValuesIn(GetTestParams())); |
313 | 313 |
314 TEST_P(QuicStreamFactoryTest, Create) { | 314 TEST_P(QuicStreamFactoryTest, Create) { |
315 Initialize(); | 315 Initialize(); |
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 EXPECT_EQ(OK, callback_.WaitForResult()); | 2489 EXPECT_EQ(OK, callback_.WaitForResult()); |
2490 | 2490 |
2491 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2491 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
2492 EXPECT_TRUE(stream.get()); | 2492 EXPECT_TRUE(stream.get()); |
2493 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2493 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
2494 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2494 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
2495 QuicStreamFactoryPeer::SetDelayTcpRace(factory_.get(), delay_tcp_race); | 2495 QuicStreamFactoryPeer::SetDelayTcpRace(factory_.get(), delay_tcp_race); |
2496 } | 2496 } |
2497 | 2497 |
2498 TEST_P(QuicStreamFactoryTest, MaybeInitialize) { | 2498 TEST_P(QuicStreamFactoryTest, MaybeInitialize) { |
2499 store_server_configs_in_properties_ = true; | 2499 number_of_server_configs_stored_in_properties_ = kMaxQuicServersToPersist; |
2500 idle_connection_timeout_seconds_ = 500; | 2500 idle_connection_timeout_seconds_ = 500; |
2501 Initialize(); | 2501 Initialize(); |
2502 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); | 2502 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); |
2503 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 2503 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
2504 const QuicConfig* config = QuicStreamFactoryPeer::GetConfig(factory_.get()); | 2504 const QuicConfig* config = QuicStreamFactoryPeer::GetConfig(factory_.get()); |
2505 EXPECT_EQ(500, config->IdleConnectionStateLifetime().ToSeconds()); | 2505 EXPECT_EQ(500, config->IdleConnectionStateLifetime().ToSeconds()); |
2506 | 2506 |
2507 QuicStreamFactoryPeer::SetTaskRunner(factory_.get(), runner_.get()); | 2507 QuicStreamFactoryPeer::SetTaskRunner(factory_.get(), runner_.get()); |
2508 | 2508 |
2509 const AlternativeService alternative_service1(QUIC, host_port_pair_.host(), | 2509 const AlternativeService alternative_service1(QUIC, host_port_pair_.host(), |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2678 EXPECT_EQ(1u, observer.executed_count()); | 2678 EXPECT_EQ(1u, observer.executed_count()); |
2679 | 2679 |
2680 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2680 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
2681 EXPECT_TRUE(stream.get()); | 2681 EXPECT_TRUE(stream.get()); |
2682 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2682 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
2683 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2683 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
2684 } | 2684 } |
2685 | 2685 |
2686 } // namespace test | 2686 } // namespace test |
2687 } // namespace net | 2687 } // namespace net |
OLD | NEW |