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