| 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 19 matching lines...) Expand all Loading... |
| 30 #include "net/quic/quic_clock.h" | 30 #include "net/quic/quic_clock.h" |
| 31 #include "net/quic/quic_connection.h" | 31 #include "net/quic/quic_connection.h" |
| 32 #include "net/quic/quic_connection_helper.h" | 32 #include "net/quic/quic_connection_helper.h" |
| 33 #include "net/quic/quic_crypto_client_stream_factory.h" | 33 #include "net/quic/quic_crypto_client_stream_factory.h" |
| 34 #include "net/quic/quic_default_packet_writer.h" | 34 #include "net/quic/quic_default_packet_writer.h" |
| 35 #include "net/quic/quic_flags.h" | 35 #include "net/quic/quic_flags.h" |
| 36 #include "net/quic/quic_http_stream.h" | 36 #include "net/quic/quic_http_stream.h" |
| 37 #include "net/quic/quic_protocol.h" | 37 #include "net/quic/quic_protocol.h" |
| 38 #include "net/quic/quic_server_id.h" | 38 #include "net/quic/quic_server_id.h" |
| 39 #include "net/socket/client_socket_factory.h" | 39 #include "net/socket/client_socket_factory.h" |
| 40 #include "net/udp/udp_client_socket.h" | |
| 41 | 40 |
| 42 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 43 #include "base/win/windows_version.h" | 42 #include "base/win/windows_version.h" |
| 44 #endif | 43 #endif |
| 45 | 44 |
| 46 namespace net { | 45 namespace net { |
| 47 | 46 |
| 48 namespace { | 47 namespace { |
| 49 | 48 |
| 50 enum CreateSessionFailure { | 49 enum CreateSessionFailure { |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 size_t max_packet_length, | 590 size_t max_packet_length, |
| 592 const std::string& user_agent_id, | 591 const std::string& user_agent_id, |
| 593 const QuicVersionVector& supported_versions, | 592 const QuicVersionVector& supported_versions, |
| 594 bool enable_port_selection, | 593 bool enable_port_selection, |
| 595 bool always_require_handshake_confirmation, | 594 bool always_require_handshake_confirmation, |
| 596 bool disable_connection_pooling, | 595 bool disable_connection_pooling, |
| 597 int load_server_info_timeout, | 596 int load_server_info_timeout, |
| 598 float load_server_info_timeout_srtt_multiplier, | 597 float load_server_info_timeout_srtt_multiplier, |
| 599 bool enable_truncated_connection_ids, | 598 bool enable_truncated_connection_ids, |
| 600 bool enable_connection_racing, | 599 bool enable_connection_racing, |
| 601 bool enable_non_blocking_io, | |
| 602 bool disable_disk_cache, | 600 bool disable_disk_cache, |
| 603 int socket_receive_buffer_size, | 601 int socket_receive_buffer_size, |
| 604 const QuicTagVector& connection_options) | 602 const QuicTagVector& connection_options) |
| 605 : require_confirmation_(true), | 603 : require_confirmation_(true), |
| 606 host_resolver_(host_resolver), | 604 host_resolver_(host_resolver), |
| 607 client_socket_factory_(client_socket_factory), | 605 client_socket_factory_(client_socket_factory), |
| 608 http_server_properties_(http_server_properties), | 606 http_server_properties_(http_server_properties), |
| 609 transport_security_state_(transport_security_state), | 607 transport_security_state_(transport_security_state), |
| 610 quic_server_info_factory_(nullptr), | 608 quic_server_info_factory_(nullptr), |
| 611 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 609 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 612 random_generator_(random_generator), | 610 random_generator_(random_generator), |
| 613 clock_(clock), | 611 clock_(clock), |
| 614 max_packet_length_(max_packet_length), | 612 max_packet_length_(max_packet_length), |
| 615 config_(InitializeQuicConfig(connection_options)), | 613 config_(InitializeQuicConfig(connection_options)), |
| 616 supported_versions_(supported_versions), | 614 supported_versions_(supported_versions), |
| 617 enable_port_selection_(enable_port_selection), | 615 enable_port_selection_(enable_port_selection), |
| 618 always_require_handshake_confirmation_( | 616 always_require_handshake_confirmation_( |
| 619 always_require_handshake_confirmation), | 617 always_require_handshake_confirmation), |
| 620 disable_connection_pooling_(disable_connection_pooling), | 618 disable_connection_pooling_(disable_connection_pooling), |
| 621 load_server_info_timeout_ms_(load_server_info_timeout), | 619 load_server_info_timeout_ms_(load_server_info_timeout), |
| 622 load_server_info_timeout_srtt_multiplier_( | 620 load_server_info_timeout_srtt_multiplier_( |
| 623 load_server_info_timeout_srtt_multiplier), | 621 load_server_info_timeout_srtt_multiplier), |
| 624 enable_truncated_connection_ids_(enable_truncated_connection_ids), | 622 enable_truncated_connection_ids_(enable_truncated_connection_ids), |
| 625 enable_connection_racing_(enable_connection_racing), | 623 enable_connection_racing_(enable_connection_racing), |
| 626 enable_non_blocking_io_(enable_non_blocking_io), | |
| 627 disable_disk_cache_(disable_disk_cache), | 624 disable_disk_cache_(disable_disk_cache), |
| 628 socket_receive_buffer_size_(socket_receive_buffer_size), | 625 socket_receive_buffer_size_(socket_receive_buffer_size), |
| 629 port_seed_(random_generator_->RandUint64()), | 626 port_seed_(random_generator_->RandUint64()), |
| 630 check_persisted_supports_quic_(true), | 627 check_persisted_supports_quic_(true), |
| 631 task_runner_(nullptr), | 628 task_runner_(nullptr), |
| 632 weak_factory_(this) { | 629 weak_factory_(this) { |
| 633 DCHECK(transport_security_state_); | 630 DCHECK(transport_security_state_); |
| 634 crypto_config_.set_user_agent_id(user_agent_id); | 631 crypto_config_.set_user_agent_id(user_agent_id); |
| 635 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 632 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
| 636 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 633 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 new PortSuggester(server_id.host_port_pair(), port_seed_); | 1008 new PortSuggester(server_id.host_port_pair(), port_seed_); |
| 1012 DatagramSocket::BindType bind_type = enable_port_selection ? | 1009 DatagramSocket::BindType bind_type = enable_port_selection ? |
| 1013 DatagramSocket::RANDOM_BIND : // Use our callback. | 1010 DatagramSocket::RANDOM_BIND : // Use our callback. |
| 1014 DatagramSocket::DEFAULT_BIND; // Use OS to randomize. | 1011 DatagramSocket::DEFAULT_BIND; // Use OS to randomize. |
| 1015 scoped_ptr<DatagramClientSocket> socket( | 1012 scoped_ptr<DatagramClientSocket> socket( |
| 1016 client_socket_factory_->CreateDatagramClientSocket( | 1013 client_socket_factory_->CreateDatagramClientSocket( |
| 1017 bind_type, | 1014 bind_type, |
| 1018 base::Bind(&PortSuggester::SuggestPort, port_suggester), | 1015 base::Bind(&PortSuggester::SuggestPort, port_suggester), |
| 1019 net_log.net_log(), net_log.source())); | 1016 net_log.net_log(), net_log.source())); |
| 1020 | 1017 |
| 1021 if (enable_non_blocking_io_ && | |
| 1022 client_socket_factory_ == ClientSocketFactory::GetDefaultFactory()) { | |
| 1023 #if defined(OS_WIN) | |
| 1024 static_cast<UDPClientSocket*>(socket.get())->UseNonBlockingIO(); | |
| 1025 #endif | |
| 1026 } | |
| 1027 | |
| 1028 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1018 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1029 tracked_objects::ScopedTracker tracking_profile2( | 1019 tracked_objects::ScopedTracker tracking_profile2( |
| 1030 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1020 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 1031 "422516 QuicStreamFactory::CreateSession2")); | 1021 "422516 QuicStreamFactory::CreateSession2")); |
| 1032 | 1022 |
| 1033 int rv = socket->Connect(addr); | 1023 int rv = socket->Connect(addr); |
| 1034 | 1024 |
| 1035 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 1025 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 1036 tracked_objects::ScopedTracker tracking_profile3( | 1026 tracked_objects::ScopedTracker tracking_profile3( |
| 1037 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1027 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 http_server_properties_->ClearAlternateProtocol(server); | 1343 http_server_properties_->ClearAlternateProtocol(server); |
| 1354 http_server_properties_->SetAlternateProtocol( | 1344 http_server_properties_->SetAlternateProtocol( |
| 1355 server, alternate.port, alternate.protocol, 1); | 1345 server, alternate.port, alternate.protocol, 1); |
| 1356 DCHECK_EQ(QUIC, | 1346 DCHECK_EQ(QUIC, |
| 1357 http_server_properties_->GetAlternateProtocol(server).protocol); | 1347 http_server_properties_->GetAlternateProtocol(server).protocol); |
| 1358 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1348 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
| 1359 server)); | 1349 server)); |
| 1360 } | 1350 } |
| 1361 | 1351 |
| 1362 } // namespace net | 1352 } // namespace net |
| OLD | NEW |