[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| 6 | #define NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| 7 | |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
bnc | 614a92d3 | 2016-04-04 13:56:07 | [diff] [blame^] | 11 | #include <deque> |
[email protected] | 1cd2a5f | 2014-03-14 06:33:25 | [diff] [blame] | 12 | #include <list> |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 13 | #include <map> |
bnc | 614a92d3 | 2016-04-04 13:56:07 | [diff] [blame^] | 14 | #include <set> |
[email protected] | 41d6b17 | 2013-01-29 16:10:57 | [diff] [blame] | 15 | #include <string> |
[email protected] | 6e12d70 | 2013-11-13 00:17:17 | [diff] [blame] | 16 | #include <vector> |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 17 | |
thestig | a0e18cd | 2015-09-25 04:58:36 | [diff] [blame] | 18 | #include "base/gtest_prod_util.h" |
[email protected] | e8cf7555b | 2014-02-28 23:52:53 | [diff] [blame] | 19 | #include "base/logging.h" |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 20 | #include "base/macros.h" |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 21 | #include "base/memory/weak_ptr.h" |
rtenneti | 8332ba5 | 2015-09-17 19:33:41 | [diff] [blame] | 22 | #include "base/time/time.h" |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 23 | #include "net/base/address_list.h" |
| 24 | #include "net/base/completion_callback.h" |
| 25 | #include "net/base/host_port_pair.h" |
[email protected] | f698a01 | 2013-05-06 20:18:59 | [diff] [blame] | 26 | #include "net/base/network_change_notifier.h" |
[email protected] | d7d1e50b | 2013-11-25 22:08:09 | [diff] [blame] | 27 | #include "net/cert/cert_database.h" |
zhongyi | 32569c6 | 2016-01-08 02:54:30 | [diff] [blame] | 28 | #include "net/http/http_server_properties.h" |
xunjieli | 2608f9b | 2016-03-14 13:39:23 | [diff] [blame] | 29 | #include "net/http/http_stream_factory.h" |
eroman | 87c53d6 | 2015-04-02 06:51:07 | [diff] [blame] | 30 | #include "net/log/net_log.h" |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 31 | #include "net/proxy/proxy_server.h" |
rtenneti | 041b299 | 2015-02-23 23:03:28 | [diff] [blame] | 32 | #include "net/quic/network_connection.h" |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 33 | #include "net/quic/quic_chromium_client_session.h" |
ckrasic | 244375a3 | 2016-02-04 21:21:22 | [diff] [blame] | 34 | #include "net/quic/quic_client_push_promise_index.h" |
[email protected] | ef95114d | 2013-04-17 17:57:01 | [diff] [blame] | 35 | #include "net/quic/quic_config.h" |
| 36 | #include "net/quic/quic_crypto_stream.h" |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 37 | #include "net/quic/quic_http_stream.h" |
| 38 | #include "net/quic/quic_protocol.h" |
rch | 02d8779 | 2015-09-09 09:05:53 | [diff] [blame] | 39 | #include "net/ssl/ssl_config_service.h" |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 40 | |
| 41 | namespace net { |
| 42 | |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 43 | class CTPolicyEnforcer; |
[email protected] | 6d1b4ed | 2013-07-10 03:57:54 | [diff] [blame] | 44 | class CertVerifier; |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 45 | class ChannelIDService; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 46 | class ClientSocketFactory; |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 47 | class CTVerifier; |
[email protected] | 6d1b4ed | 2013-07-10 03:57:54 | [diff] [blame] | 48 | class HostResolver; |
[email protected] | 77c6c16 | 2013-08-17 02:57:45 | [diff] [blame] | 49 | class HttpServerProperties; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 50 | class QuicClock; |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 51 | class QuicChromiumClientSession; |
rch | 12fef55 | 2016-01-15 16:26:31 | [diff] [blame] | 52 | class QuicChromiumConnectionHelper; |
[email protected] | e8ff2684 | 2013-03-22 21:02:05 | [diff] [blame] | 53 | class QuicCryptoClientStreamFactory; |
[email protected] | 9558c5d3 | 2012-12-22 00:08:14 | [diff] [blame] | 54 | class QuicRandom; |
[email protected] | 257f24f | 2014-04-01 09:15:37 | [diff] [blame] | 55 | class QuicServerId; |
rtenneti | 13c9d38d | 2015-10-12 21:25:01 | [diff] [blame] | 56 | class QuicServerInfo; |
| 57 | class QuicServerInfoFactory; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 58 | class QuicStreamFactory; |
tbansal | fdf5665b | 2015-09-21 22:46:40 | [diff] [blame] | 59 | class SocketPerformanceWatcherFactory; |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 60 | class TransportSecurityState; |
xunjieli | 5749218c | 2016-03-22 16:43:06 | [diff] [blame] | 61 | class BidirectionalStreamImpl; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 62 | |
[email protected] | c49ff18 | 2013-09-28 08:33:26 | [diff] [blame] | 63 | namespace test { |
| 64 | class QuicStreamFactoryPeer; |
| 65 | } // namespace test |
| 66 | |
rtenneti | 41c0999 | 2015-11-30 18:24:01 | [diff] [blame] | 67 | // When a connection is idle for 30 seconds it will be closed. |
| 68 | const int kIdleConnectionTimeoutSeconds = 30; |
| 69 | |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 70 | // Encapsulates a pending request for a QuicHttpStream. |
| 71 | // If the request is still pending when it is destroyed, it will |
| 72 | // cancel the request with the factory. |
| 73 | class NET_EXPORT_PRIVATE QuicStreamRequest { |
| 74 | public: |
| 75 | explicit QuicStreamRequest(QuicStreamFactory* factory); |
| 76 | ~QuicStreamRequest(); |
| 77 | |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 78 | // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is |
| 79 | // passed to CertVerifier::Verify. |
[email protected] | bf4ea2f | 2014-03-10 22:57:53 | [diff] [blame] | 80 | int Request(const HostPortPair& host_port_pair, |
[email protected] | 9dd3ff0f | 2014-03-26 09:51:28 | [diff] [blame] | 81 | PrivacyMode privacy_mode, |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 82 | int cert_verify_flags, |
ckrasic | 3865ee0f | 2016-02-29 22:04:56 | [diff] [blame] | 83 | const GURL& url, |
[email protected] | 974849d | 2014-02-06 01:32:59 | [diff] [blame] | 84 | base::StringPiece method, |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 85 | const BoundNetLog& net_log, |
| 86 | const CompletionCallback& callback); |
| 87 | |
| 88 | void OnRequestComplete(int rv); |
| 89 | |
rtenneti | 8332ba5 | 2015-09-17 19:33:41 | [diff] [blame] | 90 | // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It |
| 91 | // returns the amount of time waiting job should be delayed. |
| 92 | base::TimeDelta GetTimeDelayForWaitingJob() const; |
| 93 | |
xunjieli | 2608f9b | 2016-03-14 13:39:23 | [diff] [blame] | 94 | scoped_ptr<QuicHttpStream> CreateStream(); |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 95 | |
xunjieli | 5749218c | 2016-03-22 16:43:06 | [diff] [blame] | 96 | scoped_ptr<BidirectionalStreamImpl> CreateBidirectionalStreamImpl(); |
xunjieli | 2608f9b | 2016-03-14 13:39:23 | [diff] [blame] | 97 | |
| 98 | // Sets |session_|. |
| 99 | void SetSession(QuicChromiumClientSession* session); |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 100 | |
shiva.jm | d4e2adf | 2015-09-02 06:35:02 | [diff] [blame] | 101 | const std::string& origin_host() const { return origin_host_; } |
bnc | cb7ff3c | 2015-05-21 20:51:55 | [diff] [blame] | 102 | |
| 103 | PrivacyMode privacy_mode() const { return privacy_mode_; } |
| 104 | |
thestig | a0e18cd | 2015-09-25 04:58:36 | [diff] [blame] | 105 | const BoundNetLog& net_log() const { return net_log_; } |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 106 | |
| 107 | private: |
| 108 | QuicStreamFactory* factory_; |
[email protected] | bf4ea2f | 2014-03-10 22:57:53 | [diff] [blame] | 109 | HostPortPair host_port_pair_; |
bnc | cb7ff3c | 2015-05-21 20:51:55 | [diff] [blame] | 110 | std::string origin_host_; |
bnc | 614a92d3 | 2016-04-04 13:56:07 | [diff] [blame^] | 111 | std::string url_; |
bnc | cb7ff3c | 2015-05-21 20:51:55 | [diff] [blame] | 112 | PrivacyMode privacy_mode_; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 113 | BoundNetLog net_log_; |
| 114 | CompletionCallback callback_; |
xunjieli | 2608f9b | 2016-03-14 13:39:23 | [diff] [blame] | 115 | base::WeakPtr<QuicChromiumClientSession> session_; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 116 | |
| 117 | DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); |
| 118 | }; |
| 119 | |
| 120 | // A factory for creating new QuicHttpStreams on top of a pool of |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 121 | // QuicChromiumClientSessions. |
[email protected] | f698a01 | 2013-05-06 20:18:59 | [diff] [blame] | 122 | class NET_EXPORT_PRIVATE QuicStreamFactory |
[email protected] | d7d1e50b | 2013-11-25 22:08:09 | [diff] [blame] | 123 | : public NetworkChangeNotifier::IPAddressObserver, |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 124 | public NetworkChangeNotifier::NetworkObserver, |
rch | 02d8779 | 2015-09-09 09:05:53 | [diff] [blame] | 125 | public SSLConfigService::Observer, |
[email protected] | d7d1e50b | 2013-11-25 22:08:09 | [diff] [blame] | 126 | public CertDatabase::Observer { |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 127 | public: |
[email protected] | e8ff2684 | 2013-03-22 21:02:05 | [diff] [blame] | 128 | QuicStreamFactory( |
| 129 | HostResolver* host_resolver, |
| 130 | ClientSocketFactory* client_socket_factory, |
[email protected] | 77c6c16 | 2013-08-17 02:57:45 | [diff] [blame] | 131 | base::WeakPtr<HttpServerProperties> http_server_properties, |
[email protected] | 59c0bbd | 2014-03-22 04:08:12 | [diff] [blame] | 132 | CertVerifier* cert_verifier, |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 133 | CTPolicyEnforcer* ct_policy_enforcer, |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 134 | ChannelIDService* channel_id_service, |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 135 | TransportSecurityState* transport_security_state, |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 136 | CTVerifier* cert_transparency_verifier, |
tbansal | c8a94ea | 2015-11-02 23:58:51 | [diff] [blame] | 137 | SocketPerformanceWatcherFactory* socket_performance_watcher_factory, |
[email protected] | e8ff2684 | 2013-03-22 21:02:05 | [diff] [blame] | 138 | QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
| 139 | QuicRandom* random_generator, |
[email protected] | 256fe9b | 2013-11-27 01:58:02 | [diff] [blame] | 140 | QuicClock* clock, |
[email protected] | 1e96003 | 2013-12-20 19:00:20 | [diff] [blame] | 141 | size_t max_packet_length, |
[email protected] | 0c4017ca | 2014-06-06 03:30:45 | [diff] [blame] | 142 | const std::string& user_agent_id, |
[email protected] | 376d38a | 2014-01-22 03:47:35 | [diff] [blame] | 143 | const QuicVersionVector& supported_versions, |
[email protected] | c80f7c9 | 2014-02-27 13:12:02 | [diff] [blame] | 144 | bool enable_port_selection, |
jri | 2b966f2 | 2014-09-02 22:25:36 | [diff] [blame] | 145 | bool always_require_handshake_confirmation, |
jri | 584002d1 | 2014-09-09 00:51:28 | [diff] [blame] | 146 | bool disable_connection_pooling, |
rtenneti | 2912825c | 2015-01-06 01:19:46 | [diff] [blame] | 147 | float load_server_info_timeout_srtt_multiplier, |
rtenneti | 4f80997 | 2015-02-11 19:38:34 | [diff] [blame] | 148 | bool enable_connection_racing, |
qyearsley | 3257b7de | 2015-02-28 06:59:03 | [diff] [blame] | 149 | bool enable_non_blocking_io, |
rtenneti | 34dffe75 | 2015-02-24 23:27:32 | [diff] [blame] | 150 | bool disable_disk_cache, |
rch | 9976b0c | 2015-06-10 21:27:23 | [diff] [blame] | 151 | bool prefer_aes, |
rtenneti | 85dcfac2 | 2015-03-27 20:22:19 | [diff] [blame] | 152 | int max_number_of_lossy_connections, |
| 153 | float packet_loss_threshold, |
ckrasic | 1e53b64 | 2015-07-08 22:39:35 | [diff] [blame] | 154 | int max_recent_disabled_reasons, |
| 155 | int threshold_timeouts_with_streams_open, |
| 156 | int threshold_public_resets_post_handshake, |
rch | c743357 | 2015-02-27 18:16:51 | [diff] [blame] | 157 | int socket_receive_buffer_size, |
rtenneti | 8332ba5 | 2015-09-17 19:33:41 | [diff] [blame] | 158 | bool delay_tcp_race, |
rtenneti | 6971c17 | 2016-01-15 20:12:10 | [diff] [blame] | 159 | int max_server_configs_stored_in_properties, |
jri | 8c44d69 | 2015-10-23 23:53:41 | [diff] [blame] | 160 | bool close_sessions_on_ip_change, |
zhongyi | 89649c3 | 2016-01-22 00:14:01 | [diff] [blame] | 161 | bool disable_quic_on_timeout_with_open_streams, |
rtenneti | 41c0999 | 2015-11-30 18:24:01 | [diff] [blame] | 162 | int idle_connection_timeout_seconds, |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 163 | bool migrate_sessions_on_network_change, |
jri | d36ada6 | 2016-02-06 02:42:08 | [diff] [blame] | 164 | bool migrate_sessions_early, |
nharper | d5cddca | 2016-02-27 03:37:52 | [diff] [blame] | 165 | const QuicTagVector& connection_options, |
| 166 | bool enable_token_binding); |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 167 | ~QuicStreamFactory() override; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 168 | |
zhongyi | 32569c6 | 2016-01-08 02:54:30 | [diff] [blame] | 169 | // Returns true if there is an existing session to |server_id| which can be |
| 170 | // used for request to |origin_host|. |
| 171 | bool CanUseExistingSession(QuicServerId server_id, |
| 172 | PrivacyMode privacy_mode, |
| 173 | StringPiece origin_host); |
| 174 | |
[email protected] | bf4ea2f | 2014-03-10 22:57:53 | [diff] [blame] | 175 | // Creates a new QuicHttpStream to |host_port_pair| which will be |
rch | f114d98 | 2015-10-21 01:34:56 | [diff] [blame] | 176 | // owned by |request|. |
[email protected] | 0cceb92 | 2014-07-01 02:00:56 | [diff] [blame] | 177 | // If a matching session already exists, this method will return OK. If no |
| 178 | // matching session exists, this will return ERR_IO_PENDING and will invoke |
| 179 | // OnRequestComplete asynchronously. |
[email protected] | bf4ea2f | 2014-03-10 22:57:53 | [diff] [blame] | 180 | int Create(const HostPortPair& host_port_pair, |
[email protected] | 9dd3ff0f | 2014-03-26 09:51:28 | [diff] [blame] | 181 | PrivacyMode privacy_mode, |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 182 | int cert_verify_flags, |
ckrasic | 3865ee0f | 2016-02-29 22:04:56 | [diff] [blame] | 183 | const GURL& url, |
[email protected] | 974849d | 2014-02-06 01:32:59 | [diff] [blame] | 184 | base::StringPiece method, |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 185 | const BoundNetLog& net_log, |
| 186 | QuicStreamRequest* request); |
| 187 | |
rtenneti | 97137a9 | 2015-06-18 06:00:31 | [diff] [blame] | 188 | // If |packet_loss_rate| is greater than or equal to |packet_loss_threshold_| |
| 189 | // it marks QUIC as recently broken for the port of the session. Increments |
| 190 | // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_| |
| 191 | // is greater than or equal to |max_number_of_lossy_connections_| then it |
| 192 | // disables QUIC. If QUIC is disabled then it closes the connection. |
| 193 | // |
| 194 | // Returns true if QUIC is disabled for the port of the session. |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 195 | bool OnHandshakeConfirmed(QuicChromiumClientSession* session, |
| 196 | float packet_loss_rate); |
rtenneti | 85dcfac2 | 2015-03-27 20:22:19 | [diff] [blame] | 197 | |
rch | cee7beb | 2016-03-11 06:16:14 | [diff] [blame] | 198 | // Called when a TCP job completes for an origin that QUIC potentially |
| 199 | // could be used for. |
| 200 | void OnTcpJobCompleted(bool succeeded); |
| 201 | |
rtenneti | 85dcfac2 | 2015-03-27 20:22:19 | [diff] [blame] | 202 | // Returns true if QUIC is disabled for this port. |
rch | cee7beb | 2016-03-11 06:16:14 | [diff] [blame] | 203 | bool IsQuicDisabled(uint16_t port) const; |
rtenneti | 85dcfac2 | 2015-03-27 20:22:19 | [diff] [blame] | 204 | |
ckrasic | 1e53b64 | 2015-07-08 22:39:35 | [diff] [blame] | 205 | // Returns reason QUIC is disabled for this port, or QUIC_DISABLED_NOT if not. |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 206 | QuicChromiumClientSession::QuicDisabledReason QuicDisabledReason( |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 207 | uint16_t port) const; |
ckrasic | 1e53b64 | 2015-07-08 22:39:35 | [diff] [blame] | 208 | |
| 209 | // Returns reason QUIC is disabled as string for net-internals, or |
| 210 | // returns empty string if QUIC is not disabled. |
| 211 | const char* QuicDisabledReasonString() const; |
| 212 | |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 213 | // Called by a session when it becomes idle. |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 214 | void OnIdleSession(QuicChromiumClientSession* session); |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 215 | |
[email protected] | 4d283b3 | 2013-10-17 12:57:27 | [diff] [blame] | 216 | // Called by a session when it is going away and no more streams should be |
| 217 | // created on it. |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 218 | void OnSessionGoingAway(QuicChromiumClientSession* session); |
[email protected] | 4d283b3 | 2013-10-17 12:57:27 | [diff] [blame] | 219 | |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 220 | // Called by a session after it shuts down. |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 221 | void OnSessionClosed(QuicChromiumClientSession* session); |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 222 | |
[email protected] | 6576844 | 2014-06-06 23:37:03 | [diff] [blame] | 223 | // Called by a session whose connection has timed out. |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 224 | void OnSessionConnectTimeout(QuicChromiumClientSession* session); |
[email protected] | 6576844 | 2014-06-06 23:37:03 | [diff] [blame] | 225 | |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 226 | // Cancels a pending request. |
| 227 | void CancelRequest(QuicStreamRequest* request); |
| 228 | |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 229 | // Closes all current sessions with specified network and QUIC error codes. |
| 230 | void CloseAllSessions(int error, QuicErrorCode quic_error); |
[email protected] | 56dfb90 | 2013-01-03 23:17:55 | [diff] [blame] | 231 | |
payal.pandey | a18956a | 2015-05-27 05:57:55 | [diff] [blame] | 232 | scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const; |
[email protected] | c5b061b | 2013-01-05 00:31:34 | [diff] [blame] | 233 | |
[email protected] | f7e21a43 | 2014-04-21 22:17:57 | [diff] [blame] | 234 | // Delete all cached state objects in |crypto_config_|. |
[email protected] | 60cf50e | 2014-04-28 23:23:18 | [diff] [blame] | 235 | void ClearCachedStatesInCryptoConfig(); |
[email protected] | f7e21a43 | 2014-04-21 22:17:57 | [diff] [blame] | 236 | |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 237 | // Helper method that configures a DatagramClientSocket. Socket is |
| 238 | // bound to the default network if the |network| param is |
| 239 | // NetworkChangeNotifier::kInvalidNetworkHandle. |
| 240 | // Returns net_error code. |
| 241 | int ConfigureSocket(DatagramClientSocket* socket, |
| 242 | IPEndPoint addr, |
| 243 | NetworkChangeNotifier::NetworkHandle network); |
| 244 | |
jri | ae8cfdc | 2016-01-21 19:44:35 | [diff] [blame] | 245 | // Finds an alternative to |old_network| from the platform's list of connected |
| 246 | // networks. Returns NetworkChangeNotifier::kInvalidNetworkHandle if no |
| 247 | // alternative is found. |
| 248 | NetworkChangeNotifier::NetworkHandle FindAlternateNetwork( |
| 249 | NetworkChangeNotifier::NetworkHandle old_network); |
| 250 | |
| 251 | // Method that initiates migration of active sessions |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 252 | // currently bound to |network| to an alternate network, if one |
| 253 | // exists. Idle sessions bound to |network| are closed. If there is |
| 254 | // no alternate network to migrate active sessions onto, active |
| 255 | // sessions are closed if |force_close| is true, and continue using |
| 256 | // |network| otherwise. Sessions not bound to |network| are left unchanged. |
| 257 | void MaybeMigrateOrCloseSessions(NetworkChangeNotifier::NetworkHandle network, |
| 258 | bool force_close); |
| 259 | |
jri | ae8cfdc | 2016-01-21 19:44:35 | [diff] [blame] | 260 | // Method that initiates early migration of |session| if |session| is |
| 261 | // active and if there is an alternate network than the one to which |
| 262 | // |session| is currently bound. |
| 263 | void MaybeMigrateSessionEarly(QuicChromiumClientSession* session); |
| 264 | |
| 265 | // Method that migrates |session| over to using |new_network|. |
| 266 | void MigrateSessionToNetwork( |
| 267 | QuicChromiumClientSession* session, |
| 268 | NetworkChangeNotifier::NetworkHandle new_network); |
| 269 | |
[email protected] | f698a01 | 2013-05-06 20:18:59 | [diff] [blame] | 270 | // NetworkChangeNotifier::IPAddressObserver methods: |
| 271 | |
| 272 | // Until the servers support roaming, close all connections when the local |
| 273 | // IP address changes. |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 274 | void OnIPAddressChanged() override; |
[email protected] | f698a01 | 2013-05-06 20:18:59 | [diff] [blame] | 275 | |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 276 | // NetworkChangeNotifier::NetworkObserver methods: |
| 277 | void OnNetworkConnected( |
| 278 | NetworkChangeNotifier::NetworkHandle network) override; |
| 279 | void OnNetworkDisconnected( |
| 280 | NetworkChangeNotifier::NetworkHandle network) override; |
| 281 | void OnNetworkSoonToDisconnect( |
| 282 | NetworkChangeNotifier::NetworkHandle network) override; |
| 283 | void OnNetworkMadeDefault( |
| 284 | NetworkChangeNotifier::NetworkHandle network) override; |
| 285 | |
rch | 02d8779 | 2015-09-09 09:05:53 | [diff] [blame] | 286 | // SSLConfigService::Observer methods: |
| 287 | |
| 288 | // We perform the same flushing as described above when SSL settings change. |
| 289 | void OnSSLConfigChanged() override; |
| 290 | |
[email protected] | d7d1e50b | 2013-11-25 22:08:09 | [diff] [blame] | 291 | // CertDatabase::Observer methods: |
| 292 | |
| 293 | // We close all sessions when certificate database is changed. |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 294 | void OnCertAdded(const X509Certificate* cert) override; |
| 295 | void OnCACertChanged(const X509Certificate* cert) override; |
[email protected] | d7d1e50b | 2013-11-25 22:08:09 | [diff] [blame] | 296 | |
rjshade | d5ced07 | 2015-12-18 19:26:02 | [diff] [blame] | 297 | bool require_confirmation() const { return require_confirmation_; } |
[email protected] | 11c0587 | 2013-08-20 02:04:12 | [diff] [blame] | 298 | |
rtenneti | fc47e0e | 2014-09-26 02:54:05 | [diff] [blame] | 299 | void set_require_confirmation(bool require_confirmation); |
[email protected] | 11c0587 | 2013-08-20 02:04:12 | [diff] [blame] | 300 | |
rtenneti | d2e74caa | 2015-12-09 00:51:57 | [diff] [blame] | 301 | bool ZeroRTTEnabledFor(const QuicServerId& server_id); |
| 302 | |
rtenneti | 8332ba5 | 2015-09-17 19:33:41 | [diff] [blame] | 303 | // It returns the amount of time waiting job should be delayed. |
| 304 | base::TimeDelta GetTimeDelayForWaitingJob(const QuicServerId& server_id); |
| 305 | |
rch | 12fef55 | 2016-01-15 16:26:31 | [diff] [blame] | 306 | QuicChromiumConnectionHelper* helper() { return helper_.get(); } |
[email protected] | 2cfc6bb8 | 2013-10-27 03:40:44 | [diff] [blame] | 307 | |
[email protected] | 376d38a | 2014-01-22 03:47:35 | [diff] [blame] | 308 | bool enable_port_selection() const { return enable_port_selection_; } |
| 309 | |
[email protected] | a420520 | 2014-06-02 16:03:08 | [diff] [blame] | 310 | bool has_quic_server_info_factory() { |
rtenneti | 6971c17 | 2016-01-15 20:12:10 | [diff] [blame] | 311 | return quic_server_info_factory_.get() != nullptr; |
[email protected] | a420520 | 2014-06-02 16:03:08 | [diff] [blame] | 312 | } |
| 313 | |
[email protected] | e8cf7555b | 2014-02-28 23:52:53 | [diff] [blame] | 314 | void set_quic_server_info_factory( |
rtenneti | 13c9d38d | 2015-10-12 21:25:01 | [diff] [blame] | 315 | QuicServerInfoFactory* quic_server_info_factory); |
[email protected] | e8cf7555b | 2014-02-28 23:52:53 | [diff] [blame] | 316 | |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 317 | bool enable_connection_racing() const { return enable_connection_racing_; } |
| 318 | void set_enable_connection_racing(bool enable_connection_racing) { |
| 319 | enable_connection_racing_ = enable_connection_racing; |
| 320 | } |
| 321 | |
rch | 185ebee | 2015-07-14 23:56:22 | [diff] [blame] | 322 | int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } |
| 323 | |
rtenneti | 8332ba5 | 2015-09-17 19:33:41 | [diff] [blame] | 324 | bool delay_tcp_race() const { return delay_tcp_race_; } |
| 325 | |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 326 | private: |
| 327 | class Job; |
[email protected] | c49ff18 | 2013-09-28 08:33:26 | [diff] [blame] | 328 | friend class test::QuicStreamFactoryPeer; |
tbansal | a5268e2 | 2015-06-30 02:57:58 | [diff] [blame] | 329 | FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 330 | |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 331 | typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; |
| 332 | typedef std::map<QuicChromiumClientSession*, QuicServerId> SessionIdMap; |
[email protected] | 257f24f | 2014-04-01 09:15:37 | [diff] [blame] | 333 | typedef std::set<QuicServerId> AliasSet; |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 334 | typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; |
| 335 | typedef std::set<QuicChromiumClientSession*> SessionSet; |
rch | f114d98 | 2015-10-21 01:34:56 | [diff] [blame] | 336 | typedef std::map<IPEndPoint, SessionSet> IPAliasMap; |
[email protected] | 257f24f | 2014-04-01 09:15:37 | [diff] [blame] | 337 | typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 338 | typedef std::set<Job*> JobSet; |
| 339 | typedef std::map<QuicServerId, JobSet> JobMap; |
| 340 | typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 341 | typedef std::set<QuicStreamRequest*> RequestSet; |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 342 | typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 343 | typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason> |
ckrasic | 1e53b64 | 2015-07-08 22:39:35 | [diff] [blame] | 344 | DisabledReasonsQueue; |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 345 | |
rch | cee7beb | 2016-03-11 06:16:14 | [diff] [blame] | 346 | enum FactoryStatus { |
| 347 | OPEN, // New streams may be created. |
| 348 | CLOSED, // No new streams may be created temporarily. |
| 349 | DISABLED // No more streams may be created until the network changes. |
| 350 | }; |
| 351 | |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 352 | // Creates a job which doesn't wait for server config to be loaded from the |
| 353 | // disk cache. This job is started via a PostTask. |
| 354 | void CreateAuxilaryJob(const QuicServerId server_id, |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 355 | int cert_verify_flags, |
bnc | 68d401dd | 2015-05-18 20:31:48 | [diff] [blame] | 356 | bool server_and_origin_have_same_host, |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 357 | bool is_post, |
| 358 | const BoundNetLog& net_log); |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 359 | |
bnc | cb7ff3c | 2015-05-21 20:51:55 | [diff] [blame] | 360 | // Returns a newly created QuicHttpStream owned by the caller. |
thestig | a0e18cd | 2015-09-25 04:58:36 | [diff] [blame] | 361 | scoped_ptr<QuicHttpStream> CreateFromSession( |
| 362 | QuicChromiumClientSession* session); |
[email protected] | df157d9d | 2014-03-10 07:27:27 | [diff] [blame] | 363 | |
[email protected] | 257f24f | 2014-04-01 09:15:37 | [diff] [blame] | 364 | bool OnResolution(const QuicServerId& server_id, |
[email protected] | eed749f9 | 2013-12-23 18:57:38 | [diff] [blame] | 365 | const AddressList& address_list); |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 366 | void OnJobComplete(Job* job, int rv); |
[email protected] | 257f24f | 2014-04-01 09:15:37 | [diff] [blame] | 367 | bool HasActiveSession(const QuicServerId& server_id) const; |
| 368 | bool HasActiveJob(const QuicServerId& server_id) const; |
| 369 | int CreateSession(const QuicServerId& server_id, |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 370 | int cert_verify_flags, |
[email protected] | 17bf15c | 2014-03-14 10:08:04 | [diff] [blame] | 371 | scoped_ptr<QuicServerInfo> quic_server_info, |
[email protected] | 338e798 | 2013-12-13 11:15:32 | [diff] [blame] | 372 | const AddressList& address_list, |
rtenneti | f4f0885 | 2015-02-27 17:50:04 | [diff] [blame] | 373 | base::TimeTicks dns_resolution_end_time, |
[email protected] | 338e798 | 2013-12-13 11:15:32 | [diff] [blame] | 374 | const BoundNetLog& net_log, |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 375 | QuicChromiumClientSession** session); |
[email protected] | 257f24f | 2014-04-01 09:15:37 | [diff] [blame] | 376 | void ActivateSession(const QuicServerId& key, |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 377 | QuicChromiumClientSession* session); |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 378 | |
rtenneti | 2912825c | 2015-01-06 01:19:46 | [diff] [blame] | 379 | // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there |
| 380 | // is no |http_server_properties_| or if |http_server_properties_| doesn't |
| 381 | // have ServerNetworkStats for the given |server_id|. |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 382 | int64_t GetServerNetworkStatsSmoothedRttInMicroseconds( |
rtenneti | 2912825c | 2015-01-06 01:19:46 | [diff] [blame] | 383 | const QuicServerId& server_id) const; |
| 384 | |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 385 | // Helper methods. |
| 386 | bool WasQuicRecentlyBroken(const QuicServerId& server_id) const; |
rtenneti | 8332ba5 | 2015-09-17 19:33:41 | [diff] [blame] | 387 | |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 388 | bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id); |
| 389 | |
[email protected] | 257f24f | 2014-04-01 09:15:37 | [diff] [blame] | 390 | // Initializes the cached state associated with |server_id| in |
rch | f37ccc78 | 2016-01-31 05:13:50 | [diff] [blame] | 391 | // |crypto_config_| with the information in |server_info|. Populates |
| 392 | // |connection_id| with the next server designated connection id, |
| 393 | // if any, and otherwise leaves it unchanged. |
[email protected] | 60cf50e | 2014-04-28 23:23:18 | [diff] [blame] | 394 | void InitializeCachedStateInCryptoConfig( |
| 395 | const QuicServerId& server_id, |
rch | f37ccc78 | 2016-01-31 05:13:50 | [diff] [blame] | 396 | const scoped_ptr<QuicServerInfo>& server_info, |
| 397 | QuicConnectionId* connection_id); |
[email protected] | b694e48c | 2014-03-18 17:10:13 | [diff] [blame] | 398 | |
rtenneti | 8a80a6dc | 2015-09-21 19:51:13 | [diff] [blame] | 399 | // Initialize |quic_supported_servers_at_startup_| with the list of servers |
rtenneti | cd2aaa15b | 2015-10-10 20:29:33 | [diff] [blame] | 400 | // that supported QUIC at start up and also initialize in-memory cache of |
| 401 | // QuicServerInfo objects from HttpServerProperties. |
| 402 | void MaybeInitialize(); |
rtenneti | 8a80a6dc | 2015-09-21 19:51:13 | [diff] [blame] | 403 | |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 404 | void ProcessGoingAwaySession(QuicChromiumClientSession* session, |
[email protected] | eb71ab6 | 2014-05-23 07:57:53 | [diff] [blame] | 405 | const QuicServerId& server_id, |
| 406 | bool was_session_active); |
[email protected] | 4d590c9c | 2014-05-02 05:14:33 | [diff] [blame] | 407 | |
ckrasic | 1e53b64 | 2015-07-08 22:39:35 | [diff] [blame] | 408 | // Collect stats from recent connections, possibly disabling Quic. |
ckrasic | 4f9d88d | 2015-07-22 22:23:16 | [diff] [blame] | 409 | void MaybeDisableQuic(QuicChromiumClientSession* session); |
ckrasic | 1e53b64 | 2015-07-08 22:39:35 | [diff] [blame] | 410 | |
rch | cee7beb | 2016-03-11 06:16:14 | [diff] [blame] | 411 | void MaybeDisableQuic(uint16_t port); |
| 412 | |
[email protected] | 11c0587 | 2013-08-20 02:04:12 | [diff] [blame] | 413 | bool require_confirmation_; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 414 | HostResolver* host_resolver_; |
| 415 | ClientSocketFactory* client_socket_factory_; |
[email protected] | 77c6c16 | 2013-08-17 02:57:45 | [diff] [blame] | 416 | base::WeakPtr<HttpServerProperties> http_server_properties_; |
[email protected] | 5db45220 | 2014-08-19 05:22:15 | [diff] [blame] | 417 | TransportSecurityState* transport_security_state_; |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 418 | CTVerifier* cert_transparency_verifier_; |
rtenneti | 13c9d38d | 2015-10-12 21:25:01 | [diff] [blame] | 419 | scoped_ptr<QuicServerInfoFactory> quic_server_info_factory_; |
[email protected] | e8ff2684 | 2013-03-22 21:02:05 | [diff] [blame] | 420 | QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; |
[email protected] | 9558c5d3 | 2012-12-22 00:08:14 | [diff] [blame] | 421 | QuicRandom* random_generator_; |
[email protected] | f1e97e9 | 2012-12-16 04:53:25 | [diff] [blame] | 422 | scoped_ptr<QuicClock> clock_; |
[email protected] | 256fe9b | 2013-11-27 01:58:02 | [diff] [blame] | 423 | const size_t max_packet_length_; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 424 | |
tbansal | fdf5665b | 2015-09-21 22:46:40 | [diff] [blame] | 425 | // Factory which is used to create socket performance watcher. A new watcher |
| 426 | // is created for every QUIC connection. |
| 427 | // |socket_performance_watcher_factory_| may be null. |
tbansal | c8a94ea | 2015-11-02 23:58:51 | [diff] [blame] | 428 | SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; |
tbansal | fdf5665b | 2015-09-21 22:46:40 | [diff] [blame] | 429 | |
[email protected] | 2cfc6bb8 | 2013-10-27 03:40:44 | [diff] [blame] | 430 | // The helper used for all connections. |
rch | 12fef55 | 2016-01-15 16:26:31 | [diff] [blame] | 431 | scoped_ptr<QuicChromiumConnectionHelper> helper_; |
[email protected] | 2cfc6bb8 | 2013-10-27 03:40:44 | [diff] [blame] | 432 | |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 433 | // Contains owning pointers to all sessions that currently exist. |
[email protected] | 4d590c9c | 2014-05-02 05:14:33 | [diff] [blame] | 434 | SessionIdMap all_sessions_; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 435 | // Contains non-owning pointers to currently active session |
| 436 | // (not going away session, once they're implemented). |
| 437 | SessionMap active_sessions_; |
[email protected] | eed749f9 | 2013-12-23 18:57:38 | [diff] [blame] | 438 | // Map from session to set of aliases that this session is known by. |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 439 | SessionAliasMap session_aliases_; |
[email protected] | eed749f9 | 2013-12-23 18:57:38 | [diff] [blame] | 440 | // Map from IP address to sessions which are connected to this address. |
| 441 | IPAliasMap ip_aliases_; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 442 | |
[email protected] | d8e2abf8 | 2014-03-06 10:30:10 | [diff] [blame] | 443 | // Origins which have gone away recently. |
| 444 | AliasSet gone_away_aliases_; |
| 445 | |
[email protected] | fd276a28 | 2014-06-11 04:26:14 | [diff] [blame] | 446 | const QuicConfig config_; |
[email protected] | 59c0bbd | 2014-03-22 04:08:12 | [diff] [blame] | 447 | QuicCryptoClientConfig crypto_config_; |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 448 | |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 449 | JobMap active_jobs_; |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 450 | ServerIDRequestsMap job_requests_map_; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 451 | RequestMap active_requests_; |
| 452 | |
[email protected] | 1e96003 | 2013-12-20 19:00:20 | [diff] [blame] | 453 | QuicVersionVector supported_versions_; |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 454 | |
[email protected] | 376d38a | 2014-01-22 03:47:35 | [diff] [blame] | 455 | // Determine if we should consistently select a client UDP port. If false, |
| 456 | // then we will just let the OS select a random client port for each new |
| 457 | // connection. |
| 458 | bool enable_port_selection_; |
| 459 | |
jri | 2b966f2 | 2014-09-02 22:25:36 | [diff] [blame] | 460 | // Set if we always require handshake confirmation. If true, this will |
| 461 | // introduce at least one RTT for the handshake before the client sends data. |
| 462 | bool always_require_handshake_confirmation_; |
| 463 | |
jri | 584002d1 | 2014-09-09 00:51:28 | [diff] [blame] | 464 | // Set if we do not want connection pooling. |
| 465 | bool disable_connection_pooling_; |
| 466 | |
rtenneti | 2912825c | 2015-01-06 01:19:46 | [diff] [blame] | 467 | // Specifies the ratio between time to load QUIC server information from disk |
| 468 | // cache to 'smoothed RTT'. This ratio is used to calculate the timeout in |
| 469 | // milliseconds to wait for loading of QUIC server information. If we don't |
| 470 | // want to timeout, set |load_server_info_timeout_srtt_multiplier_| to 0. |
| 471 | float load_server_info_timeout_srtt_multiplier_; |
| 472 | |
rtenneti | 14abd31 | 2015-02-06 21:56:01 | [diff] [blame] | 473 | // Set if we want to race connections - one connection that sends |
| 474 | // INCHOATE_HELLO and another connection that sends CHLO after loading server |
| 475 | // config from the disk cache. |
| 476 | bool enable_connection_racing_; |
| 477 | |
qyearsley | 3257b7de | 2015-02-28 06:59:03 | [diff] [blame] | 478 | // Set if experimental non-blocking IO should be used on windows sockets. |
| 479 | bool enable_non_blocking_io_; |
| 480 | |
rtenneti | 34dffe75 | 2015-02-24 23:27:32 | [diff] [blame] | 481 | // Set if we do not want to load server config from the disk cache. |
| 482 | bool disable_disk_cache_; |
| 483 | |
rch | 9976b0c | 2015-06-10 21:27:23 | [diff] [blame] | 484 | // Set if AES-GCM should be preferred, even if there is no hardware support. |
| 485 | bool prefer_aes_; |
| 486 | |
rtenneti | 85dcfac2 | 2015-03-27 20:22:19 | [diff] [blame] | 487 | // Set if we want to disable QUIC when there is high packet loss rate. |
| 488 | // Specifies the maximum number of connections with high packet loss in a row |
| 489 | // after which QUIC will be disabled. |
| 490 | int max_number_of_lossy_connections_; |
rtenneti | 374e5688 | 2015-03-28 13:49:54 | [diff] [blame] | 491 | // Specifies packet loss rate in fraction after which a connection is closed |
rtenneti | 85dcfac2 | 2015-03-27 20:22:19 | [diff] [blame] | 492 | // and is considered as a lossy connection. |
| 493 | float packet_loss_threshold_; |
| 494 | // Count number of lossy connections by port. |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 495 | std::map<uint16_t, int> number_of_lossy_connections_; |
rtenneti | 85dcfac2 | 2015-03-27 20:22:19 | [diff] [blame] | 496 | |
ckrasic | 1e53b64 | 2015-07-08 22:39:35 | [diff] [blame] | 497 | // Keep track of stats for recently closed connections, using a |
| 498 | // bounded queue. |
| 499 | int max_disabled_reasons_; |
| 500 | DisabledReasonsQueue disabled_reasons_; |
| 501 | // Events that can trigger disabling QUIC |
| 502 | int num_public_resets_post_handshake_; |
| 503 | int num_timeouts_with_open_streams_; |
| 504 | // Keep track the largest values for UMA histograms, that will help |
| 505 | // determine good threshold values. |
| 506 | int max_public_resets_post_handshake_; |
| 507 | int max_timeouts_with_open_streams_; |
| 508 | // Thresholds if greater than zero, determine when to |
| 509 | int threshold_timeouts_with_open_streams_; |
| 510 | int threshold_public_resets_post_handshake_; |
| 511 | |
rch | c743357 | 2015-02-27 18:16:51 | [diff] [blame] | 512 | // Size of the UDP receive buffer. |
| 513 | int socket_receive_buffer_size_; |
| 514 | |
rtenneti | 8332ba5 | 2015-09-17 19:33:41 | [diff] [blame] | 515 | // Set if we do want to delay TCP connection when it is racing with QUIC. |
| 516 | bool delay_tcp_race_; |
| 517 | |
rtenneti | 1cd3b16 | 2015-09-29 02:58:28 | [diff] [blame] | 518 | // If more than |yield_after_packets_| packets have been read or more than |
| 519 | // |yield_after_duration_| time has passed, then |
rch | a02807b4 | 2016-01-29 21:56:15 | [diff] [blame] | 520 | // QuicChromiumPacketReader::StartReading() yields by doing a PostTask(). |
rtenneti | 1cd3b16 | 2015-09-29 02:58:28 | [diff] [blame] | 521 | int yield_after_packets_; |
| 522 | QuicTime::Delta yield_after_duration_; |
| 523 | |
jri | 8c44d69 | 2015-10-23 23:53:41 | [diff] [blame] | 524 | // Set if all sessions should be closed when any local IP address changes. |
| 525 | const bool close_sessions_on_ip_change_; |
| 526 | |
jri | 7e63664 | 2016-01-14 06:57:08 | [diff] [blame] | 527 | // Set if migration should be attempted on active sessions when primary |
| 528 | // interface changes. |
| 529 | const bool migrate_sessions_on_network_change_; |
| 530 | |
jri | d36ada6 | 2016-02-06 02:42:08 | [diff] [blame] | 531 | // Set if early migration should be attempted when the connection |
| 532 | // experiences poor connectivity. |
| 533 | const bool migrate_sessions_early_; |
| 534 | |
rch | c743357 | 2015-02-27 18:16:51 | [diff] [blame] | 535 | // Each profile will (probably) have a unique port_seed_ value. This value |
| 536 | // is used to help seed a pseudo-random number generator (PortSuggester) so |
| 537 | // that we consistently (within this profile) suggest the same ephemeral |
| 538 | // port when we re-connect to any given server/port. The differences between |
| 539 | // profiles (probablistically) prevent two profiles from colliding in their |
| 540 | // ephemeral port requests. |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 541 | uint64_t port_seed_; |
[email protected] | 7034cf1 | 2013-12-13 22:47:07 | [diff] [blame] | 542 | |
rtenneti | fc47e0e | 2014-09-26 02:54:05 | [diff] [blame] | 543 | // Local address of socket that was created in CreateSession. |
| 544 | IPEndPoint local_address_; |
| 545 | bool check_persisted_supports_quic_; |
rtenneti | cd2aaa15b | 2015-10-10 20:29:33 | [diff] [blame] | 546 | bool has_initialized_data_; |
rtenneti | 1681f85 | 2014-11-13 20:34:03 | [diff] [blame] | 547 | std::set<HostPortPair> quic_supported_servers_at_startup_; |
rtenneti | fc47e0e | 2014-09-26 02:54:05 | [diff] [blame] | 548 | |
rtenneti | 041b299 | 2015-02-23 23:03:28 | [diff] [blame] | 549 | NetworkConnection network_connection_; |
| 550 | |
ckrasic | 3865ee0f | 2016-02-29 22:04:56 | [diff] [blame] | 551 | int num_push_streams_created_; |
| 552 | |
ckrasic | 244375a3 | 2016-02-04 21:21:22 | [diff] [blame] | 553 | QuicClientPushPromiseIndex push_promise_index_; |
jri | c533399b | 2016-01-29 07:36:01 | [diff] [blame] | 554 | |
rch | cee7beb | 2016-03-11 06:16:14 | [diff] [blame] | 555 | // Current status of the factory's ability to create streams. |
| 556 | FactoryStatus status_; |
| 557 | |
rtenneti | 38f5cd5 | 2014-10-28 20:28:28 | [diff] [blame] | 558 | base::TaskRunner* task_runner_; |
| 559 | |
[email protected] | 1e96003 | 2013-12-20 19:00:20 | [diff] [blame] | 560 | base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
| 561 | |
[email protected] | e13201d8 | 2012-12-12 05:00:32 | [diff] [blame] | 562 | DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
| 563 | }; |
| 564 | |
| 565 | } // namespace net |
| 566 | |
| 567 | #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |