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" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/metrics/field_trial.h" | |
12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
13 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
14 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/cert/cert_verifier.h" | 20 #include "net/cert/cert_verifier.h" |
20 #include "net/dns/host_resolver.h" | 21 #include "net/dns/host_resolver.h" |
21 #include "net/dns/single_request_host_resolver.h" | 22 #include "net/dns/single_request_host_resolver.h" |
22 #include "net/http/http_server_properties.h" | 23 #include "net/http/http_server_properties.h" |
23 #include "net/quic/congestion_control/tcp_receiver.h" | 24 #include "net/quic/congestion_control/tcp_receiver.h" |
24 #include "net/quic/crypto/channel_id_chromium.h" | 25 #include "net/quic/crypto/channel_id_chromium.h" |
25 #include "net/quic/crypto/proof_verifier_chromium.h" | 26 #include "net/quic/crypto/proof_verifier_chromium.h" |
26 #include "net/quic/crypto/quic_random.h" | 27 #include "net/quic/crypto/quic_random.h" |
27 #include "net/quic/crypto/quic_server_info.h" | 28 #include "net/quic/crypto/quic_server_info.h" |
28 #include "net/quic/port_suggester.h" | 29 #include "net/quic/port_suggester.h" |
29 #include "net/quic/quic_client_session.h" | 30 #include "net/quic/quic_client_session.h" |
30 #include "net/quic/quic_clock.h" | 31 #include "net/quic/quic_clock.h" |
31 #include "net/quic/quic_connection.h" | 32 #include "net/quic/quic_connection.h" |
32 #include "net/quic/quic_connection_helper.h" | 33 #include "net/quic/quic_connection_helper.h" |
33 #include "net/quic/quic_crypto_client_stream_factory.h" | 34 #include "net/quic/quic_crypto_client_stream_factory.h" |
34 #include "net/quic/quic_default_packet_writer.h" | 35 #include "net/quic/quic_default_packet_writer.h" |
36 #include "net/quic/quic_flags.h" | |
35 #include "net/quic/quic_http_stream.h" | 37 #include "net/quic/quic_http_stream.h" |
36 #include "net/quic/quic_protocol.h" | 38 #include "net/quic/quic_protocol.h" |
37 #include "net/quic/quic_server_id.h" | 39 #include "net/quic/quic_server_id.h" |
38 #include "net/socket/client_socket_factory.h" | 40 #include "net/socket/client_socket_factory.h" |
39 | 41 |
40 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
41 #include "base/win/windows_version.h" | 43 #include "base/win/windows_version.h" |
42 #endif | 44 #endif |
43 | 45 |
44 namespace net { | 46 namespace net { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 QuicClock* clock, | 560 QuicClock* clock, |
559 size_t max_packet_length, | 561 size_t max_packet_length, |
560 const std::string& user_agent_id, | 562 const std::string& user_agent_id, |
561 const QuicVersionVector& supported_versions, | 563 const QuicVersionVector& supported_versions, |
562 bool enable_port_selection, | 564 bool enable_port_selection, |
563 bool always_require_handshake_confirmation, | 565 bool always_require_handshake_confirmation, |
564 bool disable_connection_pooling, | 566 bool disable_connection_pooling, |
565 int load_server_info_timeout, | 567 int load_server_info_timeout, |
566 bool disable_loading_server_info_for_new_servers, | 568 bool disable_loading_server_info_for_new_servers, |
567 float load_server_info_timeout_srtt_multiplier, | 569 float load_server_info_timeout_srtt_multiplier, |
570 bool disable_truncated_connection_ids, | |
568 const QuicTagVector& connection_options) | 571 const QuicTagVector& connection_options) |
569 : require_confirmation_(true), | 572 : require_confirmation_(true), |
570 host_resolver_(host_resolver), | 573 host_resolver_(host_resolver), |
571 client_socket_factory_(client_socket_factory), | 574 client_socket_factory_(client_socket_factory), |
572 http_server_properties_(http_server_properties), | 575 http_server_properties_(http_server_properties), |
573 transport_security_state_(transport_security_state), | 576 transport_security_state_(transport_security_state), |
574 quic_server_info_factory_(nullptr), | 577 quic_server_info_factory_(nullptr), |
575 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 578 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
576 random_generator_(random_generator), | 579 random_generator_(random_generator), |
577 clock_(clock), | 580 clock_(clock), |
578 max_packet_length_(max_packet_length), | 581 max_packet_length_(max_packet_length), |
579 config_(InitializeQuicConfig(connection_options)), | 582 config_(InitializeQuicConfig(connection_options)), |
580 supported_versions_(supported_versions), | 583 supported_versions_(supported_versions), |
581 enable_port_selection_(enable_port_selection), | 584 enable_port_selection_(enable_port_selection), |
582 always_require_handshake_confirmation_( | 585 always_require_handshake_confirmation_( |
583 always_require_handshake_confirmation), | 586 always_require_handshake_confirmation), |
584 disable_connection_pooling_(disable_connection_pooling), | 587 disable_connection_pooling_(disable_connection_pooling), |
585 load_server_info_timeout_ms_(load_server_info_timeout), | 588 load_server_info_timeout_ms_(load_server_info_timeout), |
586 disable_loading_server_info_for_new_servers_( | 589 disable_loading_server_info_for_new_servers_( |
587 disable_loading_server_info_for_new_servers), | 590 disable_loading_server_info_for_new_servers), |
588 load_server_info_timeout_srtt_multiplier_( | 591 load_server_info_timeout_srtt_multiplier_( |
589 load_server_info_timeout_srtt_multiplier), | 592 load_server_info_timeout_srtt_multiplier), |
593 disable_truncated_connection_ids_(disable_truncated_connection_ids), | |
590 port_seed_(random_generator_->RandUint64()), | 594 port_seed_(random_generator_->RandUint64()), |
591 check_persisted_supports_quic_(true), | 595 check_persisted_supports_quic_(true), |
592 task_runner_(nullptr), | 596 task_runner_(nullptr), |
593 weak_factory_(this) { | 597 weak_factory_(this) { |
594 DCHECK(transport_security_state_); | 598 DCHECK(transport_security_state_); |
599 if (disable_truncated_connection_ids_) | |
600 FLAGS_allow_truncated_connection_ids_for_quic = false; | |
Ryan Hamilton
2015/01/08 22:28:07
Instead of assigning to FLAGS_ here, how 'bout che
ramant (doing other things)
2015/01/08 23:06:58
Done.
| |
595 crypto_config_.set_user_agent_id(user_agent_id); | 601 crypto_config_.set_user_agent_id(user_agent_id); |
596 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 602 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
597 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 603 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
598 crypto_config_.SetProofVerifier( | 604 crypto_config_.SetProofVerifier( |
599 new ProofVerifierChromium(cert_verifier, transport_security_state)); | 605 new ProofVerifierChromium(cert_verifier, transport_security_state)); |
600 crypto_config_.SetChannelIDSource( | 606 crypto_config_.SetChannelIDSource( |
601 new ChannelIDSourceChromium(channel_id_service)); | 607 new ChannelIDSourceChromium(channel_id_service)); |
602 base::CPU cpu; | 608 base::CPU cpu; |
603 if (cpu.has_aesni() && cpu.has_avx()) | 609 if (cpu.has_aesni() && cpu.has_avx()) |
604 crypto_config_.PreferAesGcm(); | 610 crypto_config_.PreferAesGcm(); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1017 InitializeCachedStateInCryptoConfig(server_id, server_info); | 1023 InitializeCachedStateInCryptoConfig(server_id, server_info); |
1018 | 1024 |
1019 QuicConfig config = config_; | 1025 QuicConfig config = config_; |
1020 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); | 1026 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); |
1021 config.SetInitialFlowControlWindowToSend(kInitialReceiveWindowSize); | 1027 config.SetInitialFlowControlWindowToSend(kInitialReceiveWindowSize); |
1022 config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize); | 1028 config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize); |
1023 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); | 1029 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); |
1024 int64 srtt = GetServerNetworkStatsSmoothedRttInMicroseconds(server_id); | 1030 int64 srtt = GetServerNetworkStatsSmoothedRttInMicroseconds(server_id); |
1025 if (srtt > 0) | 1031 if (srtt > 0) |
1026 config.SetInitialRoundTripTimeUsToSend(static_cast<uint32>(srtt)); | 1032 config.SetInitialRoundTripTimeUsToSend(static_cast<uint32>(srtt)); |
1033 if (FLAGS_allow_truncated_connection_ids_for_quic) | |
1034 config.SetBytesForConnectionIdToSend(0); | |
1027 | 1035 |
1028 if (quic_server_info_factory_ && !server_info) { | 1036 if (quic_server_info_factory_ && !server_info) { |
1029 // Start the disk cache loading so that we can persist the newer QUIC server | 1037 // Start the disk cache loading so that we can persist the newer QUIC server |
1030 // information and/or inform the disk cache that we have reused | 1038 // information and/or inform the disk cache that we have reused |
1031 // |server_info|. | 1039 // |server_info|. |
1032 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); | 1040 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); |
1033 server_info->Start(); | 1041 server_info->Start(); |
1034 } | 1042 } |
1035 | 1043 |
1036 *session = new QuicClientSession( | 1044 *session = new QuicClientSession( |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1179 http_server_properties_->ClearAlternateProtocol(server); | 1187 http_server_properties_->ClearAlternateProtocol(server); |
1180 http_server_properties_->SetAlternateProtocol( | 1188 http_server_properties_->SetAlternateProtocol( |
1181 server, alternate.port, alternate.protocol, 1); | 1189 server, alternate.port, alternate.protocol, 1); |
1182 DCHECK_EQ(QUIC, | 1190 DCHECK_EQ(QUIC, |
1183 http_server_properties_->GetAlternateProtocol(server).protocol); | 1191 http_server_properties_->GetAlternateProtocol(server).protocol); |
1184 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1192 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
1185 server)); | 1193 server)); |
1186 } | 1194 } |
1187 | 1195 |
1188 } // namespace net | 1196 } // namespace net |
OLD | NEW |