| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 tracked_objects::ScopedTracker tracking_profile( | 388 tracked_objects::ScopedTracker tracking_profile( |
| 389 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 389 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 390 "422516 QuicStreamFactory::Job::DoLoadServerInfo")); | 390 "422516 QuicStreamFactory::Job::DoLoadServerInfo")); |
| 391 | 391 |
| 392 io_state_ = STATE_LOAD_SERVER_INFO_COMPLETE; | 392 io_state_ = STATE_LOAD_SERVER_INFO_COMPLETE; |
| 393 | 393 |
| 394 DCHECK(server_info_); | 394 DCHECK(server_info_); |
| 395 | 395 |
| 396 // To mitigate the effects of disk cache taking too long to load QUIC server | 396 // To mitigate the effects of disk cache taking too long to load QUIC server |
| 397 // information, set up a timer to cancel WaitForDataReady's callback. | 397 // information, set up a timer to cancel WaitForDataReady's callback. |
| 398 int64 load_server_info_timeout_ms = factory_->load_server_info_timeout_ms_; | |
| 399 if (factory_->load_server_info_timeout_srtt_multiplier_ > 0) { | 398 if (factory_->load_server_info_timeout_srtt_multiplier_ > 0) { |
| 400 DCHECK_EQ(0, load_server_info_timeout_ms); | 399 int64 load_server_info_timeout_ms = |
| 401 load_server_info_timeout_ms = | |
| 402 (factory_->load_server_info_timeout_srtt_multiplier_ * | 400 (factory_->load_server_info_timeout_srtt_multiplier_ * |
| 403 factory_->GetServerNetworkStatsSmoothedRttInMicroseconds(server_id_)) / | 401 factory_->GetServerNetworkStatsSmoothedRttInMicroseconds(server_id_)) / |
| 404 1000; | 402 1000; |
| 405 } | 403 if (load_server_info_timeout_ms > 0) { |
| 406 if (load_server_info_timeout_ms > 0) { | 404 factory_->task_runner_->PostDelayedTask( |
| 407 factory_->task_runner_->PostDelayedTask( | 405 FROM_HERE, |
| 408 FROM_HERE, | 406 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback, |
| 409 base::Bind(&QuicStreamFactory::Job::CancelWaitForDataReadyCallback, | 407 GetWeakPtr()), |
| 410 GetWeakPtr()), | 408 base::TimeDelta::FromMilliseconds(load_server_info_timeout_ms)); |
| 411 base::TimeDelta::FromMilliseconds(load_server_info_timeout_ms)); | 409 } |
| 412 } | 410 } |
| 413 | 411 |
| 414 int rv = server_info_->WaitForDataReady( | 412 int rv = server_info_->WaitForDataReady( |
| 415 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); | 413 base::Bind(&QuicStreamFactory::Job::OnIOComplete, GetWeakPtr())); |
| 416 if (rv == ERR_IO_PENDING && factory_->enable_connection_racing()) { | 414 if (rv == ERR_IO_PENDING && factory_->enable_connection_racing()) { |
| 417 // If we are waiting to load server config from the disk cache, then start | 415 // If we are waiting to load server config from the disk cache, then start |
| 418 // another job. | 416 // another job. |
| 419 started_another_job_ = true; | 417 started_another_job_ = true; |
| 420 factory_->CreateAuxilaryJob(server_id_, is_post_, net_log_); | 418 factory_->CreateAuxilaryJob(server_id_, is_post_, net_log_); |
| 421 } | 419 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 TransportSecurityState* transport_security_state, | 585 TransportSecurityState* transport_security_state, |
| 588 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, | 586 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
| 589 QuicRandom* random_generator, | 587 QuicRandom* random_generator, |
| 590 QuicClock* clock, | 588 QuicClock* clock, |
| 591 size_t max_packet_length, | 589 size_t max_packet_length, |
| 592 const std::string& user_agent_id, | 590 const std::string& user_agent_id, |
| 593 const QuicVersionVector& supported_versions, | 591 const QuicVersionVector& supported_versions, |
| 594 bool enable_port_selection, | 592 bool enable_port_selection, |
| 595 bool always_require_handshake_confirmation, | 593 bool always_require_handshake_confirmation, |
| 596 bool disable_connection_pooling, | 594 bool disable_connection_pooling, |
| 597 int load_server_info_timeout, | |
| 598 float load_server_info_timeout_srtt_multiplier, | 595 float load_server_info_timeout_srtt_multiplier, |
| 599 bool enable_truncated_connection_ids, | |
| 600 bool enable_connection_racing, | 596 bool enable_connection_racing, |
| 601 bool enable_non_blocking_io, | 597 bool enable_non_blocking_io, |
| 602 bool disable_disk_cache, | 598 bool disable_disk_cache, |
| 603 int socket_receive_buffer_size, | 599 int socket_receive_buffer_size, |
| 604 const QuicTagVector& connection_options) | 600 const QuicTagVector& connection_options) |
| 605 : require_confirmation_(true), | 601 : require_confirmation_(true), |
| 606 host_resolver_(host_resolver), | 602 host_resolver_(host_resolver), |
| 607 client_socket_factory_(client_socket_factory), | 603 client_socket_factory_(client_socket_factory), |
| 608 http_server_properties_(http_server_properties), | 604 http_server_properties_(http_server_properties), |
| 609 transport_security_state_(transport_security_state), | 605 transport_security_state_(transport_security_state), |
| 610 quic_server_info_factory_(nullptr), | 606 quic_server_info_factory_(nullptr), |
| 611 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 607 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 612 random_generator_(random_generator), | 608 random_generator_(random_generator), |
| 613 clock_(clock), | 609 clock_(clock), |
| 614 max_packet_length_(max_packet_length), | 610 max_packet_length_(max_packet_length), |
| 615 config_(InitializeQuicConfig(connection_options)), | 611 config_(InitializeQuicConfig(connection_options)), |
| 616 supported_versions_(supported_versions), | 612 supported_versions_(supported_versions), |
| 617 enable_port_selection_(enable_port_selection), | 613 enable_port_selection_(enable_port_selection), |
| 618 always_require_handshake_confirmation_( | 614 always_require_handshake_confirmation_( |
| 619 always_require_handshake_confirmation), | 615 always_require_handshake_confirmation), |
| 620 disable_connection_pooling_(disable_connection_pooling), | 616 disable_connection_pooling_(disable_connection_pooling), |
| 621 load_server_info_timeout_ms_(load_server_info_timeout), | |
| 622 load_server_info_timeout_srtt_multiplier_( | 617 load_server_info_timeout_srtt_multiplier_( |
| 623 load_server_info_timeout_srtt_multiplier), | 618 load_server_info_timeout_srtt_multiplier), |
| 624 enable_truncated_connection_ids_(enable_truncated_connection_ids), | |
| 625 enable_connection_racing_(enable_connection_racing), | 619 enable_connection_racing_(enable_connection_racing), |
| 626 enable_non_blocking_io_(enable_non_blocking_io), | 620 enable_non_blocking_io_(enable_non_blocking_io), |
| 627 disable_disk_cache_(disable_disk_cache), | 621 disable_disk_cache_(disable_disk_cache), |
| 628 socket_receive_buffer_size_(socket_receive_buffer_size), | 622 socket_receive_buffer_size_(socket_receive_buffer_size), |
| 629 port_seed_(random_generator_->RandUint64()), | 623 port_seed_(random_generator_->RandUint64()), |
| 630 check_persisted_supports_quic_(true), | 624 check_persisted_supports_quic_(true), |
| 631 task_runner_(nullptr), | 625 task_runner_(nullptr), |
| 632 weak_factory_(this) { | 626 weak_factory_(this) { |
| 633 DCHECK(transport_security_state_); | 627 DCHECK(transport_security_state_); |
| 634 crypto_config_.set_user_agent_id(user_agent_id); | 628 crypto_config_.set_user_agent_id(user_agent_id); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 "422516 QuicStreamFactory::CreateSession56")); | 1140 "422516 QuicStreamFactory::CreateSession56")); |
| 1147 | 1141 |
| 1148 if (srtt > 0) | 1142 if (srtt > 0) |
| 1149 config.SetInitialRoundTripTimeUsToSend(static_cast<uint32>(srtt)); | 1143 config.SetInitialRoundTripTimeUsToSend(static_cast<uint32>(srtt)); |
| 1150 | 1144 |
| 1151 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1145 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1152 tracked_objects::ScopedTracker tracking_profile57( | 1146 tracked_objects::ScopedTracker tracking_profile57( |
| 1153 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1147 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1154 "422516 QuicStreamFactory::CreateSession57")); | 1148 "422516 QuicStreamFactory::CreateSession57")); |
| 1155 | 1149 |
| 1156 if (enable_truncated_connection_ids_) | 1150 config.SetBytesForConnectionIdToSend(0); |
| 1157 config.SetBytesForConnectionIdToSend(0); | |
| 1158 | 1151 |
| 1159 if (quic_server_info_factory_ && !server_info) { | 1152 if (quic_server_info_factory_ && !server_info) { |
| 1160 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1153 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1161 tracked_objects::ScopedTracker tracking_profile6( | 1154 tracked_objects::ScopedTracker tracking_profile6( |
| 1162 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1155 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1163 "422516 QuicStreamFactory::CreateSession6")); | 1156 "422516 QuicStreamFactory::CreateSession6")); |
| 1164 | 1157 |
| 1165 // Start the disk cache loading so that we can persist the newer QUIC server | 1158 // Start the disk cache loading so that we can persist the newer QUIC server |
| 1166 // information and/or inform the disk cache that we have reused | 1159 // information and/or inform the disk cache that we have reused |
| 1167 // |server_info|. | 1160 // |server_info|. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 http_server_properties_->ClearAlternateProtocol(server); | 1346 http_server_properties_->ClearAlternateProtocol(server); |
| 1354 http_server_properties_->SetAlternateProtocol( | 1347 http_server_properties_->SetAlternateProtocol( |
| 1355 server, alternate.port, alternate.protocol, 1); | 1348 server, alternate.port, alternate.protocol, 1); |
| 1356 DCHECK_EQ(QUIC, | 1349 DCHECK_EQ(QUIC, |
| 1357 http_server_properties_->GetAlternateProtocol(server).protocol); | 1350 http_server_properties_->GetAlternateProtocol(server).protocol); |
| 1358 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1351 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
| 1359 server)); | 1352 server)); |
| 1360 } | 1353 } |
| 1361 | 1354 |
| 1362 } // namespace net | 1355 } // namespace net |
| OLD | NEW |