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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
22 #include "net/base/socket_performance_watcher.h" | |
23 #include "net/base/socket_performance_watcher_factory.h" | |
22 #include "net/cert/cert_verifier.h" | 24 #include "net/cert/cert_verifier.h" |
23 #include "net/dns/host_resolver.h" | 25 #include "net/dns/host_resolver.h" |
24 #include "net/dns/single_request_host_resolver.h" | 26 #include "net/dns/single_request_host_resolver.h" |
25 #include "net/http/http_server_properties.h" | 27 #include "net/http/http_server_properties.h" |
26 #include "net/quic/crypto/channel_id_chromium.h" | 28 #include "net/quic/crypto/channel_id_chromium.h" |
27 #include "net/quic/crypto/proof_verifier_chromium.h" | 29 #include "net/quic/crypto/proof_verifier_chromium.h" |
28 #include "net/quic/crypto/quic_random.h" | 30 #include "net/quic/crypto/quic_random.h" |
29 #include "net/quic/crypto/quic_server_info.h" | 31 #include "net/quic/crypto/quic_server_info.h" |
30 #include "net/quic/port_suggester.h" | 32 #include "net/quic/port_suggester.h" |
31 #include "net/quic/quic_chromium_client_session.h" | 33 #include "net/quic/quic_chromium_client_session.h" |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 } | 553 } |
552 | 554 |
553 QuicStreamFactory::QuicStreamFactory( | 555 QuicStreamFactory::QuicStreamFactory( |
554 HostResolver* host_resolver, | 556 HostResolver* host_resolver, |
555 ClientSocketFactory* client_socket_factory, | 557 ClientSocketFactory* client_socket_factory, |
556 base::WeakPtr<HttpServerProperties> http_server_properties, | 558 base::WeakPtr<HttpServerProperties> http_server_properties, |
557 CertVerifier* cert_verifier, | 559 CertVerifier* cert_verifier, |
558 CertPolicyEnforcer* cert_policy_enforcer, | 560 CertPolicyEnforcer* cert_policy_enforcer, |
559 ChannelIDService* channel_id_service, | 561 ChannelIDService* channel_id_service, |
560 TransportSecurityState* transport_security_state, | 562 TransportSecurityState* transport_security_state, |
563 const SocketPerformanceWatcherFactory* socket_performance_watcher_factory, | |
561 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, | 564 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
562 QuicRandom* random_generator, | 565 QuicRandom* random_generator, |
563 QuicClock* clock, | 566 QuicClock* clock, |
564 size_t max_packet_length, | 567 size_t max_packet_length, |
565 const std::string& user_agent_id, | 568 const std::string& user_agent_id, |
566 const QuicVersionVector& supported_versions, | 569 const QuicVersionVector& supported_versions, |
567 bool enable_port_selection, | 570 bool enable_port_selection, |
568 bool always_require_handshake_confirmation, | 571 bool always_require_handshake_confirmation, |
569 bool disable_connection_pooling, | 572 bool disable_connection_pooling, |
570 float load_server_info_timeout_srtt_multiplier, | 573 float load_server_info_timeout_srtt_multiplier, |
(...skipping 11 matching lines...) Expand all Loading... | |
582 : require_confirmation_(true), | 585 : require_confirmation_(true), |
583 host_resolver_(host_resolver), | 586 host_resolver_(host_resolver), |
584 client_socket_factory_(client_socket_factory), | 587 client_socket_factory_(client_socket_factory), |
585 http_server_properties_(http_server_properties), | 588 http_server_properties_(http_server_properties), |
586 transport_security_state_(transport_security_state), | 589 transport_security_state_(transport_security_state), |
587 quic_server_info_factory_(nullptr), | 590 quic_server_info_factory_(nullptr), |
588 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 591 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
589 random_generator_(random_generator), | 592 random_generator_(random_generator), |
590 clock_(clock), | 593 clock_(clock), |
591 max_packet_length_(max_packet_length), | 594 max_packet_length_(max_packet_length), |
595 socket_performance_watcher_factory_(socket_performance_watcher_factory), | |
592 config_(InitializeQuicConfig(connection_options)), | 596 config_(InitializeQuicConfig(connection_options)), |
593 supported_versions_(supported_versions), | 597 supported_versions_(supported_versions), |
594 enable_port_selection_(enable_port_selection), | 598 enable_port_selection_(enable_port_selection), |
595 always_require_handshake_confirmation_( | 599 always_require_handshake_confirmation_( |
596 always_require_handshake_confirmation), | 600 always_require_handshake_confirmation), |
597 disable_connection_pooling_(disable_connection_pooling), | 601 disable_connection_pooling_(disable_connection_pooling), |
598 load_server_info_timeout_srtt_multiplier_( | 602 load_server_info_timeout_srtt_multiplier_( |
599 load_server_info_timeout_srtt_multiplier), | 603 load_server_info_timeout_srtt_multiplier), |
600 enable_connection_racing_(enable_connection_racing), | 604 enable_connection_racing_(enable_connection_racing), |
601 enable_non_blocking_io_(enable_non_blocking_io), | 605 enable_non_blocking_io_(enable_non_blocking_io), |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1218 } | 1222 } |
1219 | 1223 |
1220 DefaultPacketWriterFactory packet_writer_factory(socket.get()); | 1224 DefaultPacketWriterFactory packet_writer_factory(socket.get()); |
1221 | 1225 |
1222 if (!helper_.get()) { | 1226 if (!helper_.get()) { |
1223 helper_.reset( | 1227 helper_.reset( |
1224 new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(), | 1228 new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(), |
1225 clock_.get(), random_generator_)); | 1229 clock_.get(), random_generator_)); |
1226 } | 1230 } |
1227 | 1231 |
1232 // Use the factory to create a new socket performance watcher, and pass the | |
1233 // ownership to the QUIC connection. | |
1234 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher; | |
1235 if (socket_performance_watcher_factory_) { | |
Ryan Hamilton
2015/09/10 19:32:04
When do we expect this to be null?
tbansal1
2015/09/11 19:38:35
incognito and some tests.
| |
1236 socket_performance_watcher = socket_performance_watcher_factory_ | |
1237 ->CreateUDPSocketPerformanceWatcher(); | |
Ryan Hamilton
2015/09/10 19:32:04
Is this git cl format'd?
tbansal1
2015/09/11 19:38:35
Yes.
| |
1238 } | |
1239 | |
1228 QuicConnection* connection = new QuicConnection( | 1240 QuicConnection* connection = new QuicConnection( |
1229 connection_id, addr, helper_.get(), packet_writer_factory, | 1241 connection_id, addr, helper_.get(), packet_writer_factory, |
1230 true /* owns_writer */, Perspective::IS_CLIENT, server_id.is_https(), | 1242 true /* owns_writer */, Perspective::IS_CLIENT, server_id.is_https(), |
1231 supported_versions_); | 1243 supported_versions_, socket_performance_watcher.Pass()); |
1232 connection->set_max_packet_length(max_packet_length_); | 1244 connection->set_max_packet_length(max_packet_length_); |
1233 | 1245 |
1234 InitializeCachedStateInCryptoConfig(server_id, server_info); | 1246 InitializeCachedStateInCryptoConfig(server_id, server_info); |
1235 | 1247 |
1236 QuicConfig config = config_; | 1248 QuicConfig config = config_; |
1237 config.SetSocketReceiveBufferToSend(socket_receive_buffer_size_); | 1249 config.SetSocketReceiveBufferToSend(socket_receive_buffer_size_); |
1238 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); | 1250 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); |
1239 config.SetInitialSessionFlowControlWindowToSend( | 1251 config.SetInitialSessionFlowControlWindowToSend( |
1240 kQuicSessionMaxRecvWindowSize); | 1252 kQuicSessionMaxRecvWindowSize); |
1241 config.SetInitialStreamFlowControlWindowToSend(kQuicStreamMaxRecvWindowSize); | 1253 config.SetInitialStreamFlowControlWindowToSend(kQuicStreamMaxRecvWindowSize); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1403 // Since the session was active, there's no longer an | 1415 // Since the session was active, there's no longer an |
1404 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1416 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
1405 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1417 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
1406 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1418 // it as recently broken, which means that 0-RTT will be disabled but we'll |
1407 // still race. | 1419 // still race. |
1408 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1420 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
1409 alternative_service); | 1421 alternative_service); |
1410 } | 1422 } |
1411 | 1423 |
1412 } // namespace net | 1424 } // namespace net |
OLD | NEW |