| 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" |
| 11 #include "net/cert/cert_verifier.h" | 11 #include "net/cert/cert_verifier.h" |
| 12 #include "net/cert/multi_log_ct_verifier.h" |
| 12 #include "net/dns/mock_host_resolver.h" | 13 #include "net/dns/mock_host_resolver.h" |
| 13 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
| 14 #include "net/http/http_response_info.h" | 15 #include "net/http/http_response_info.h" |
| 15 #include "net/http/http_server_properties_impl.h" | 16 #include "net/http/http_server_properties_impl.h" |
| 16 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
| 17 #include "net/http/transport_security_state.h" | 18 #include "net/http/transport_security_state.h" |
| 18 #include "net/quic/crypto/crypto_handshake.h" | 19 #include "net/quic/crypto/crypto_handshake.h" |
| 19 #include "net/quic/crypto/proof_verifier_chromium.h" | 20 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 20 #include "net/quic/crypto/properties_based_quic_server_info.h" | 21 #include "net/quic/crypto/properties_based_quic_server_info.h" |
| 21 #include "net/quic/crypto/quic_crypto_client_config.h" | 22 #include "net/quic/crypto/quic_crypto_client_config.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 protected: | 221 protected: |
| 221 QuicStreamFactoryTest() | 222 QuicStreamFactoryTest() |
| 222 : random_generator_(0), | 223 : random_generator_(0), |
| 223 clock_(new MockClock()), | 224 clock_(new MockClock()), |
| 224 runner_(new TestTaskRunner(clock_)), | 225 runner_(new TestTaskRunner(clock_)), |
| 225 maker_(GetParam().version, 0, clock_, kDefaultServerHostName), | 226 maker_(GetParam().version, 0, clock_, kDefaultServerHostName), |
| 226 cert_verifier_(CertVerifier::CreateDefault()), | 227 cert_verifier_(CertVerifier::CreateDefault()), |
| 227 channel_id_service_( | 228 channel_id_service_( |
| 228 new ChannelIDService(new DefaultChannelIDStore(nullptr), | 229 new ChannelIDService(new DefaultChannelIDStore(nullptr), |
| 229 base::ThreadTaskRunnerHandle::Get())), | 230 base::ThreadTaskRunnerHandle::Get())), |
| 231 cert_transparency_verifier_(new MultiLogCTVerifier()), |
| 230 factory_(nullptr), | 232 factory_(nullptr), |
| 231 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), | 233 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), |
| 232 privacy_mode_(PRIVACY_MODE_DISABLED), | 234 privacy_mode_(PRIVACY_MODE_DISABLED), |
| 233 enable_port_selection_(true), | 235 enable_port_selection_(true), |
| 234 always_require_handshake_confirmation_(false), | 236 always_require_handshake_confirmation_(false), |
| 235 disable_connection_pooling_(false), | 237 disable_connection_pooling_(false), |
| 236 load_server_info_timeout_srtt_multiplier_(0.0f), | 238 load_server_info_timeout_srtt_multiplier_(0.0f), |
| 237 enable_connection_racing_(true), | 239 enable_connection_racing_(true), |
| 238 enable_non_blocking_io_(true), | 240 enable_non_blocking_io_(true), |
| 239 disable_disk_cache_(false), | 241 disable_disk_cache_(false), |
| 240 prefer_aes_(false), | 242 prefer_aes_(false), |
| 241 max_number_of_lossy_connections_(0), | 243 max_number_of_lossy_connections_(0), |
| 242 packet_loss_threshold_(1.0f), | 244 packet_loss_threshold_(1.0f), |
| 243 max_disabled_reasons_(3), | 245 max_disabled_reasons_(3), |
| 244 threshold_timeouts_with_open_streams_(2), | 246 threshold_timeouts_with_open_streams_(2), |
| 245 threshold_public_resets_post_handshake_(2), | 247 threshold_public_resets_post_handshake_(2), |
| 246 receive_buffer_size_(0), | 248 receive_buffer_size_(0), |
| 247 delay_tcp_race_(false), | 249 delay_tcp_race_(false), |
| 248 store_server_configs_in_properties_(false), | 250 store_server_configs_in_properties_(false), |
| 249 close_sessions_on_ip_change_(false) { | 251 close_sessions_on_ip_change_(false) { |
| 250 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 252 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 251 } | 253 } |
| 252 | 254 |
| 253 void Initialize() { | 255 void Initialize() { |
| 254 factory_.reset(new QuicStreamFactory( | 256 factory_.reset(new QuicStreamFactory( |
| 255 &host_resolver_, &socket_factory_, http_server_properties_.GetWeakPtr(), | 257 &host_resolver_, &socket_factory_, http_server_properties_.GetWeakPtr(), |
| 256 cert_verifier_.get(), nullptr, channel_id_service_.get(), | 258 cert_verifier_.get(), nullptr, channel_id_service_.get(), |
| 257 &transport_security_state_, | 259 &transport_security_state_, cert_transparency_verifier_.get(), |
| 258 /*SocketPerformanceWatcherFactory*/ nullptr, | 260 /*SocketPerformanceWatcherFactory*/ nullptr, |
| 259 &crypto_client_stream_factory_, &random_generator_, clock_, | 261 &crypto_client_stream_factory_, &random_generator_, clock_, |
| 260 kDefaultMaxPacketSize, std::string(), | 262 kDefaultMaxPacketSize, std::string(), |
| 261 SupportedVersions(GetParam().version), enable_port_selection_, | 263 SupportedVersions(GetParam().version), enable_port_selection_, |
| 262 always_require_handshake_confirmation_, disable_connection_pooling_, | 264 always_require_handshake_confirmation_, disable_connection_pooling_, |
| 263 load_server_info_timeout_srtt_multiplier_, enable_connection_racing_, | 265 load_server_info_timeout_srtt_multiplier_, enable_connection_racing_, |
| 264 enable_non_blocking_io_, disable_disk_cache_, prefer_aes_, | 266 enable_non_blocking_io_, disable_disk_cache_, prefer_aes_, |
| 265 max_number_of_lossy_connections_, packet_loss_threshold_, | 267 max_number_of_lossy_connections_, packet_loss_threshold_, |
| 266 max_disabled_reasons_, threshold_timeouts_with_open_streams_, | 268 max_disabled_reasons_, threshold_timeouts_with_open_streams_, |
| 267 threshold_public_resets_post_handshake_, receive_buffer_size_, | 269 threshold_public_resets_post_handshake_, receive_buffer_size_, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 DeterministicMockClientSocketFactory socket_factory_; | 377 DeterministicMockClientSocketFactory socket_factory_; |
| 376 MockCryptoClientStreamFactory crypto_client_stream_factory_; | 378 MockCryptoClientStreamFactory crypto_client_stream_factory_; |
| 377 MockRandom random_generator_; | 379 MockRandom random_generator_; |
| 378 MockClock* clock_; // Owned by factory_. | 380 MockClock* clock_; // Owned by factory_. |
| 379 scoped_refptr<TestTaskRunner> runner_; | 381 scoped_refptr<TestTaskRunner> runner_; |
| 380 QuicTestPacketMaker maker_; | 382 QuicTestPacketMaker maker_; |
| 381 HttpServerPropertiesImpl http_server_properties_; | 383 HttpServerPropertiesImpl http_server_properties_; |
| 382 scoped_ptr<CertVerifier> cert_verifier_; | 384 scoped_ptr<CertVerifier> cert_verifier_; |
| 383 scoped_ptr<ChannelIDService> channel_id_service_; | 385 scoped_ptr<ChannelIDService> channel_id_service_; |
| 384 TransportSecurityState transport_security_state_; | 386 TransportSecurityState transport_security_state_; |
| 387 scoped_ptr<CTVerifier> cert_transparency_verifier_; |
| 385 scoped_ptr<QuicStreamFactory> factory_; | 388 scoped_ptr<QuicStreamFactory> factory_; |
| 386 HostPortPair host_port_pair_; | 389 HostPortPair host_port_pair_; |
| 387 PrivacyMode privacy_mode_; | 390 PrivacyMode privacy_mode_; |
| 388 BoundNetLog net_log_; | 391 BoundNetLog net_log_; |
| 389 TestCompletionCallback callback_; | 392 TestCompletionCallback callback_; |
| 390 | 393 |
| 391 // Variables to configure QuicStreamFactory. | 394 // Variables to configure QuicStreamFactory. |
| 392 bool enable_port_selection_; | 395 bool enable_port_selection_; |
| 393 bool always_require_handshake_confirmation_; | 396 bool always_require_handshake_confirmation_; |
| 394 bool disable_connection_pooling_; | 397 bool disable_connection_pooling_; |
| (...skipping 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2808 EXPECT_EQ(1u, observer.executed_count()); | 2811 EXPECT_EQ(1u, observer.executed_count()); |
| 2809 | 2812 |
| 2810 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); | 2813 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); |
| 2811 EXPECT_TRUE(stream.get()); | 2814 EXPECT_TRUE(stream.get()); |
| 2812 EXPECT_TRUE(socket_data.AllReadDataConsumed()); | 2815 EXPECT_TRUE(socket_data.AllReadDataConsumed()); |
| 2813 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); | 2816 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); |
| 2814 } | 2817 } |
| 2815 | 2818 |
| 2816 } // namespace test | 2819 } // namespace test |
| 2817 } // namespace net | 2820 } // namespace net |
| OLD | NEW |