blob: b1dd20a0542a09e6f4b58890bfdad5e72d5ae396 [file] [log] [blame]
[email protected]e13201d82012-12-12 05:00:321// 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
[email protected]1cd2a5f2014-03-14 06:33:258#include <list>
[email protected]e13201d82012-12-12 05:00:329#include <map>
[email protected]41d6b172013-01-29 16:10:5710#include <string>
[email protected]6e12d702013-11-13 00:17:1711#include <vector>
[email protected]e13201d82012-12-12 05:00:3212
[email protected]e8cf7555b2014-02-28 23:52:5313#include "base/logging.h"
[email protected]e13201d82012-12-12 05:00:3214#include "base/memory/weak_ptr.h"
15#include "net/base/address_list.h"
16#include "net/base/completion_callback.h"
17#include "net/base/host_port_pair.h"
[email protected]f698a012013-05-06 20:18:5918#include "net/base/network_change_notifier.h"
[email protected]d7d1e50b2013-11-25 22:08:0919#include "net/cert/cert_database.h"
eroman87c53d62015-04-02 06:51:0720#include "net/log/net_log.h"
[email protected]e13201d82012-12-12 05:00:3221#include "net/proxy/proxy_server.h"
rtenneti041b2992015-02-23 23:03:2822#include "net/quic/network_connection.h"
ckrasic4f9d88d2015-07-22 22:23:1623#include "net/quic/quic_chromium_client_session.h"
[email protected]ef95114d2013-04-17 17:57:0124#include "net/quic/quic_config.h"
25#include "net/quic/quic_crypto_stream.h"
[email protected]e13201d82012-12-12 05:00:3226#include "net/quic/quic_http_stream.h"
27#include "net/quic/quic_protocol.h"
28
29namespace net {
30
rsleevi9541f8632015-07-31 00:07:0031class CertPolicyEnforcer;
[email protected]6d1b4ed2013-07-10 03:57:5432class CertVerifier;
[email protected]6b8a3c742014-07-25 00:25:3533class ChannelIDService;
[email protected]e13201d82012-12-12 05:00:3234class ClientSocketFactory;
[email protected]6d1b4ed2013-07-10 03:57:5435class HostResolver;
[email protected]77c6c162013-08-17 02:57:4536class HttpServerProperties;
[email protected]e13201d82012-12-12 05:00:3237class QuicClock;
ckrasic4f9d88d2015-07-22 22:23:1638class QuicChromiumClientSession;
[email protected]2cfc6bb82013-10-27 03:40:4439class QuicConnectionHelper;
[email protected]e8ff26842013-03-22 21:02:0540class QuicCryptoClientStreamFactory;
[email protected]9558c5d32012-12-22 00:08:1441class QuicRandom;
[email protected]7832eeb2014-01-25 10:10:4342class QuicServerInfoFactory;
[email protected]257f24f2014-04-01 09:15:3743class QuicServerId;
[email protected]e13201d82012-12-12 05:00:3244class QuicStreamFactory;
[email protected]080b77932014-08-04 01:22:4645class TransportSecurityState;
[email protected]e13201d82012-12-12 05:00:3246
[email protected]c49ff182013-09-28 08:33:2647namespace test {
48class QuicStreamFactoryPeer;
49} // namespace test
50
[email protected]e13201d82012-12-12 05:00:3251// Encapsulates a pending request for a QuicHttpStream.
52// If the request is still pending when it is destroyed, it will
53// cancel the request with the factory.
54class NET_EXPORT_PRIVATE QuicStreamRequest {
55 public:
56 explicit QuicStreamRequest(QuicStreamFactory* factory);
57 ~QuicStreamRequest();
58
[email protected]0cceb922014-07-01 02:00:5659 // For http, |is_https| is false.
rtennetia75df622015-06-21 23:59:5060 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is
61 // passed to CertVerifier::Verify.
[email protected]bf4ea2f2014-03-10 22:57:5362 int Request(const HostPortPair& host_port_pair,
[email protected]6d1b4ed2013-07-10 03:57:5463 bool is_https,
[email protected]9dd3ff0f2014-03-26 09:51:2864 PrivacyMode privacy_mode,
rtennetia75df622015-06-21 23:59:5065 int cert_verify_flags,
bnc68d401dd2015-05-18 20:31:4866 base::StringPiece origin_host,
[email protected]974849d2014-02-06 01:32:5967 base::StringPiece method,
[email protected]e13201d82012-12-12 05:00:3268 const BoundNetLog& net_log,
69 const CompletionCallback& callback);
70
71 void OnRequestComplete(int rv);
72
73 scoped_ptr<QuicHttpStream> ReleaseStream();
74
75 void set_stream(scoped_ptr<QuicHttpStream> stream);
76
shiva.jmd4e2adf2015-09-02 06:35:0277 const std::string& origin_host() const { return origin_host_; }
bnccb7ff3c2015-05-21 20:51:5578
79 PrivacyMode privacy_mode() const { return privacy_mode_; }
80
[email protected]e13201d82012-12-12 05:00:3281 const BoundNetLog& net_log() const{
82 return net_log_;
83 }
84
85 private:
86 QuicStreamFactory* factory_;
[email protected]bf4ea2f2014-03-10 22:57:5387 HostPortPair host_port_pair_;
bnccb7ff3c2015-05-21 20:51:5588 std::string origin_host_;
89 PrivacyMode privacy_mode_;
[email protected]e13201d82012-12-12 05:00:3290 BoundNetLog net_log_;
91 CompletionCallback callback_;
92 scoped_ptr<QuicHttpStream> stream_;
93
94 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest);
95};
96
97// A factory for creating new QuicHttpStreams on top of a pool of
ckrasic4f9d88d2015-07-22 22:23:1698// QuicChromiumClientSessions.
[email protected]f698a012013-05-06 20:18:5999class NET_EXPORT_PRIVATE QuicStreamFactory
[email protected]d7d1e50b2013-11-25 22:08:09100 : public NetworkChangeNotifier::IPAddressObserver,
101 public CertDatabase::Observer {
[email protected]e13201d82012-12-12 05:00:32102 public:
[email protected]e8ff26842013-03-22 21:02:05103 QuicStreamFactory(
104 HostResolver* host_resolver,
105 ClientSocketFactory* client_socket_factory,
[email protected]77c6c162013-08-17 02:57:45106 base::WeakPtr<HttpServerProperties> http_server_properties,
[email protected]59c0bbd2014-03-22 04:08:12107 CertVerifier* cert_verifier,
rsleevi9541f8632015-07-31 00:07:00108 CertPolicyEnforcer* cert_policy_enforcer,
[email protected]6b8a3c742014-07-25 00:25:35109 ChannelIDService* channel_id_service,
[email protected]080b77932014-08-04 01:22:46110 TransportSecurityState* transport_security_state,
[email protected]e8ff26842013-03-22 21:02:05111 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory,
112 QuicRandom* random_generator,
[email protected]256fe9b2013-11-27 01:58:02113 QuicClock* clock,
[email protected]1e960032013-12-20 19:00:20114 size_t max_packet_length,
[email protected]0c4017ca2014-06-06 03:30:45115 const std::string& user_agent_id,
[email protected]376d38a2014-01-22 03:47:35116 const QuicVersionVector& supported_versions,
[email protected]c80f7c92014-02-27 13:12:02117 bool enable_port_selection,
jri2b966f22014-09-02 22:25:36118 bool always_require_handshake_confirmation,
jri584002d12014-09-09 00:51:28119 bool disable_connection_pooling,
rtenneti2912825c2015-01-06 01:19:46120 float load_server_info_timeout_srtt_multiplier,
rtenneti4f809972015-02-11 19:38:34121 bool enable_connection_racing,
qyearsley3257b7de2015-02-28 06:59:03122 bool enable_non_blocking_io,
rtenneti34dffe752015-02-24 23:27:32123 bool disable_disk_cache,
rch9976b0c2015-06-10 21:27:23124 bool prefer_aes,
rtenneti85dcfac22015-03-27 20:22:19125 int max_number_of_lossy_connections,
126 float packet_loss_threshold,
ckrasic1e53b642015-07-08 22:39:35127 int max_recent_disabled_reasons,
128 int threshold_timeouts_with_streams_open,
129 int threshold_public_resets_post_handshake,
rchc7433572015-02-27 18:16:51130 int socket_receive_buffer_size,
[email protected]4b4efab32014-07-01 02:36:16131 const QuicTagVector& connection_options);
dchengb03027d2014-10-21 12:00:20132 ~QuicStreamFactory() override;
[email protected]e13201d82012-12-12 05:00:32133
[email protected]bf4ea2f2014-03-10 22:57:53134 // Creates a new QuicHttpStream to |host_port_pair| which will be
[email protected]6d1b4ed2013-07-10 03:57:54135 // owned by |request|. |is_https| specifies if the protocol is https or not.
[email protected]0cceb922014-07-01 02:00:56136 // If a matching session already exists, this method will return OK. If no
137 // matching session exists, this will return ERR_IO_PENDING and will invoke
138 // OnRequestComplete asynchronously.
[email protected]bf4ea2f2014-03-10 22:57:53139 int Create(const HostPortPair& host_port_pair,
[email protected]6d1b4ed2013-07-10 03:57:54140 bool is_https,
[email protected]9dd3ff0f2014-03-26 09:51:28141 PrivacyMode privacy_mode,
rtennetia75df622015-06-21 23:59:50142 int cert_verify_flags,
bnccb7ff3c2015-05-21 20:51:55143 base::StringPiece origin_host,
[email protected]974849d2014-02-06 01:32:59144 base::StringPiece method,
[email protected]e13201d82012-12-12 05:00:32145 const BoundNetLog& net_log,
146 QuicStreamRequest* request);
147
rtenneti97137a92015-06-18 06:00:31148 // If |packet_loss_rate| is greater than or equal to |packet_loss_threshold_|
149 // it marks QUIC as recently broken for the port of the session. Increments
150 // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_|
151 // is greater than or equal to |max_number_of_lossy_connections_| then it
152 // disables QUIC. If QUIC is disabled then it closes the connection.
153 //
154 // Returns true if QUIC is disabled for the port of the session.
ckrasic4f9d88d2015-07-22 22:23:16155 bool OnHandshakeConfirmed(QuicChromiumClientSession* session,
156 float packet_loss_rate);
rtenneti85dcfac22015-03-27 20:22:19157
158 // Returns true if QUIC is disabled for this port.
159 bool IsQuicDisabled(uint16 port);
160
ckrasic1e53b642015-07-08 22:39:35161 // Returns reason QUIC is disabled for this port, or QUIC_DISABLED_NOT if not.
ckrasic4f9d88d2015-07-22 22:23:16162 QuicChromiumClientSession::QuicDisabledReason QuicDisabledReason(
163 uint16 port) const;
ckrasic1e53b642015-07-08 22:39:35164
165 // Returns reason QUIC is disabled as string for net-internals, or
166 // returns empty string if QUIC is not disabled.
167 const char* QuicDisabledReasonString() const;
168
[email protected]e13201d82012-12-12 05:00:32169 // Called by a session when it becomes idle.
ckrasic4f9d88d2015-07-22 22:23:16170 void OnIdleSession(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32171
[email protected]4d283b32013-10-17 12:57:27172 // Called by a session when it is going away and no more streams should be
173 // created on it.
ckrasic4f9d88d2015-07-22 22:23:16174 void OnSessionGoingAway(QuicChromiumClientSession* session);
[email protected]4d283b32013-10-17 12:57:27175
[email protected]e13201d82012-12-12 05:00:32176 // Called by a session after it shuts down.
ckrasic4f9d88d2015-07-22 22:23:16177 void OnSessionClosed(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32178
[email protected]65768442014-06-06 23:37:03179 // Called by a session whose connection has timed out.
ckrasic4f9d88d2015-07-22 22:23:16180 void OnSessionConnectTimeout(QuicChromiumClientSession* session);
[email protected]65768442014-06-06 23:37:03181
[email protected]e13201d82012-12-12 05:00:32182 // Cancels a pending request.
183 void CancelRequest(QuicStreamRequest* request);
184
[email protected]56dfb902013-01-03 23:17:55185 // Closes all current sessions.
186 void CloseAllSessions(int error);
187
payal.pandeya18956a2015-05-27 05:57:55188 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const;
[email protected]c5b061b2013-01-05 00:31:34189
[email protected]f7e21a432014-04-21 22:17:57190 // Delete all cached state objects in |crypto_config_|.
[email protected]60cf50e2014-04-28 23:23:18191 void ClearCachedStatesInCryptoConfig();
[email protected]f7e21a432014-04-21 22:17:57192
[email protected]f698a012013-05-06 20:18:59193 // NetworkChangeNotifier::IPAddressObserver methods:
194
195 // Until the servers support roaming, close all connections when the local
196 // IP address changes.
dchengb03027d2014-10-21 12:00:20197 void OnIPAddressChanged() override;
[email protected]f698a012013-05-06 20:18:59198
[email protected]d7d1e50b2013-11-25 22:08:09199 // CertDatabase::Observer methods:
200
201 // We close all sessions when certificate database is changed.
dchengb03027d2014-10-21 12:00:20202 void OnCertAdded(const X509Certificate* cert) override;
203 void OnCACertChanged(const X509Certificate* cert) override;
[email protected]d7d1e50b2013-11-25 22:08:09204
jri2b966f22014-09-02 22:25:36205 bool require_confirmation() const {
206 return require_confirmation_;
207 }
[email protected]11c05872013-08-20 02:04:12208
rtennetifc47e0e2014-09-26 02:54:05209 void set_require_confirmation(bool require_confirmation);
[email protected]11c05872013-08-20 02:04:12210
[email protected]2cfc6bb82013-10-27 03:40:44211 QuicConnectionHelper* helper() { return helper_.get(); }
212
[email protected]376d38a2014-01-22 03:47:35213 bool enable_port_selection() const { return enable_port_selection_; }
214
[email protected]a4205202014-06-02 16:03:08215 bool has_quic_server_info_factory() {
216 return quic_server_info_factory_ != NULL;
217 }
218
[email protected]e8cf7555b2014-02-28 23:52:53219 void set_quic_server_info_factory(
220 QuicServerInfoFactory* quic_server_info_factory) {
221 DCHECK(!quic_server_info_factory_);
222 quic_server_info_factory_ = quic_server_info_factory;
223 }
224
rtenneti14abd312015-02-06 21:56:01225 bool enable_connection_racing() const { return enable_connection_racing_; }
226 void set_enable_connection_racing(bool enable_connection_racing) {
227 enable_connection_racing_ = enable_connection_racing;
228 }
229
rch185ebee2015-07-14 23:56:22230 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; }
231
[email protected]e13201d82012-12-12 05:00:32232 private:
233 class Job;
[email protected]c49ff182013-09-28 08:33:26234 friend class test::QuicStreamFactoryPeer;
tbansala5268e22015-06-30 02:57:58235 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad);
[email protected]e13201d82012-12-12 05:00:32236
[email protected]9dd3ff0f2014-03-26 09:51:28237 // The key used to find session by ip. Includes
[email protected]df157d9d2014-03-10 07:27:27238 // the ip address, port, and scheme.
239 struct NET_EXPORT_PRIVATE IpAliasKey {
240 IpAliasKey();
241 IpAliasKey(IPEndPoint ip_endpoint, bool is_https);
242 ~IpAliasKey();
243
244 IPEndPoint ip_endpoint;
245 bool is_https;
246
247 // Needed to be an element of std::set.
248 bool operator<(const IpAliasKey &other) const;
249 bool operator==(const IpAliasKey &other) const;
250 };
251
ckrasic4f9d88d2015-07-22 22:23:16252 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap;
253 typedef std::map<QuicChromiumClientSession*, QuicServerId> SessionIdMap;
[email protected]257f24f2014-04-01 09:15:37254 typedef std::set<QuicServerId> AliasSet;
ckrasic4f9d88d2015-07-22 22:23:16255 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap;
256 typedef std::set<QuicChromiumClientSession*> SessionSet;
[email protected]df157d9d2014-03-10 07:27:27257 typedef std::map<IpAliasKey, SessionSet> IPAliasMap;
[email protected]257f24f2014-04-01 09:15:37258 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap;
rtenneti14abd312015-02-06 21:56:01259 typedef std::set<Job*> JobSet;
260 typedef std::map<QuicServerId, JobSet> JobMap;
261 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap;
[email protected]e13201d82012-12-12 05:00:32262 typedef std::set<QuicStreamRequest*> RequestSet;
rtenneti14abd312015-02-06 21:56:01263 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap;
ckrasic4f9d88d2015-07-22 22:23:16264 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason>
ckrasic1e53b642015-07-08 22:39:35265 DisabledReasonsQueue;
rtenneti14abd312015-02-06 21:56:01266
267 // Creates a job which doesn't wait for server config to be loaded from the
268 // disk cache. This job is started via a PostTask.
269 void CreateAuxilaryJob(const QuicServerId server_id,
rtennetia75df622015-06-21 23:59:50270 int cert_verify_flags,
bnc68d401dd2015-05-18 20:31:48271 bool server_and_origin_have_same_host,
rtenneti14abd312015-02-06 21:56:01272 bool is_post,
273 const BoundNetLog& net_log);
[email protected]e13201d82012-12-12 05:00:32274
bnccb7ff3c2015-05-21 20:51:55275 // Returns a newly created QuicHttpStream owned by the caller.
ckrasic4f9d88d2015-07-22 22:23:16276 scoped_ptr<QuicHttpStream> CreateFromSession(QuicChromiumClientSession*);
[email protected]df157d9d2014-03-10 07:27:27277
[email protected]257f24f2014-04-01 09:15:37278 bool OnResolution(const QuicServerId& server_id,
[email protected]eed749f92013-12-23 18:57:38279 const AddressList& address_list);
[email protected]e13201d82012-12-12 05:00:32280 void OnJobComplete(Job* job, int rv);
[email protected]257f24f2014-04-01 09:15:37281 bool HasActiveSession(const QuicServerId& server_id) const;
282 bool HasActiveJob(const QuicServerId& server_id) const;
283 int CreateSession(const QuicServerId& server_id,
rtennetia75df622015-06-21 23:59:50284 int cert_verify_flags,
[email protected]17bf15c2014-03-14 10:08:04285 scoped_ptr<QuicServerInfo> quic_server_info,
[email protected]338e7982013-12-13 11:15:32286 const AddressList& address_list,
rtennetif4f08852015-02-27 17:50:04287 base::TimeTicks dns_resolution_end_time,
[email protected]338e7982013-12-13 11:15:32288 const BoundNetLog& net_log,
ckrasic4f9d88d2015-07-22 22:23:16289 QuicChromiumClientSession** session);
[email protected]257f24f2014-04-01 09:15:37290 void ActivateSession(const QuicServerId& key,
ckrasic4f9d88d2015-07-22 22:23:16291 QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32292
rtenneti2912825c2015-01-06 01:19:46293 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there
294 // is no |http_server_properties_| or if |http_server_properties_| doesn't
295 // have ServerNetworkStats for the given |server_id|.
296 int64 GetServerNetworkStatsSmoothedRttInMicroseconds(
297 const QuicServerId& server_id) const;
298
bnccacc0992015-03-20 20:22:22299 // Helper methods.
300 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const;
rtenneti14abd312015-02-06 21:56:01301 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id);
302
[email protected]257f24f2014-04-01 09:15:37303 // Initializes the cached state associated with |server_id| in
[email protected]59c0bbd2014-03-22 04:08:12304 // |crypto_config_| with the information in |server_info|.
[email protected]60cf50e2014-04-28 23:23:18305 void InitializeCachedStateInCryptoConfig(
306 const QuicServerId& server_id,
307 const scoped_ptr<QuicServerInfo>& server_info);
[email protected]b694e48c2014-03-18 17:10:13308
ckrasic4f9d88d2015-07-22 22:23:16309 void ProcessGoingAwaySession(QuicChromiumClientSession* session,
[email protected]eb71ab62014-05-23 07:57:53310 const QuicServerId& server_id,
311 bool was_session_active);
[email protected]4d590c9c2014-05-02 05:14:33312
ckrasic1e53b642015-07-08 22:39:35313 // Collect stats from recent connections, possibly disabling Quic.
ckrasic4f9d88d2015-07-22 22:23:16314 void MaybeDisableQuic(QuicChromiumClientSession* session);
ckrasic1e53b642015-07-08 22:39:35315
[email protected]11c05872013-08-20 02:04:12316 bool require_confirmation_;
[email protected]e13201d82012-12-12 05:00:32317 HostResolver* host_resolver_;
318 ClientSocketFactory* client_socket_factory_;
[email protected]77c6c162013-08-17 02:57:45319 base::WeakPtr<HttpServerProperties> http_server_properties_;
[email protected]5db452202014-08-19 05:22:15320 TransportSecurityState* transport_security_state_;
[email protected]7832eeb2014-01-25 10:10:43321 QuicServerInfoFactory* quic_server_info_factory_;
[email protected]e8ff26842013-03-22 21:02:05322 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_;
[email protected]9558c5d32012-12-22 00:08:14323 QuicRandom* random_generator_;
[email protected]f1e97e92012-12-16 04:53:25324 scoped_ptr<QuicClock> clock_;
[email protected]256fe9b2013-11-27 01:58:02325 const size_t max_packet_length_;
[email protected]e13201d82012-12-12 05:00:32326
[email protected]2cfc6bb82013-10-27 03:40:44327 // The helper used for all connections.
328 scoped_ptr<QuicConnectionHelper> helper_;
329
[email protected]e13201d82012-12-12 05:00:32330 // Contains owning pointers to all sessions that currently exist.
[email protected]4d590c9c2014-05-02 05:14:33331 SessionIdMap all_sessions_;
[email protected]e13201d82012-12-12 05:00:32332 // Contains non-owning pointers to currently active session
333 // (not going away session, once they're implemented).
334 SessionMap active_sessions_;
[email protected]eed749f92013-12-23 18:57:38335 // Map from session to set of aliases that this session is known by.
[email protected]e13201d82012-12-12 05:00:32336 SessionAliasMap session_aliases_;
[email protected]eed749f92013-12-23 18:57:38337 // Map from IP address to sessions which are connected to this address.
338 IPAliasMap ip_aliases_;
[email protected]e13201d82012-12-12 05:00:32339
[email protected]d8e2abf82014-03-06 10:30:10340 // Origins which have gone away recently.
341 AliasSet gone_away_aliases_;
342
[email protected]fd276a282014-06-11 04:26:14343 const QuicConfig config_;
[email protected]59c0bbd2014-03-22 04:08:12344 QuicCryptoClientConfig crypto_config_;
[email protected]b064310782013-05-30 21:12:17345
[email protected]e13201d82012-12-12 05:00:32346 JobMap active_jobs_;
rtenneti14abd312015-02-06 21:56:01347 ServerIDRequestsMap job_requests_map_;
[email protected]e13201d82012-12-12 05:00:32348 RequestMap active_requests_;
349
[email protected]1e960032013-12-20 19:00:20350 QuicVersionVector supported_versions_;
[email protected]e13201d82012-12-12 05:00:32351
[email protected]376d38a2014-01-22 03:47:35352 // Determine if we should consistently select a client UDP port. If false,
353 // then we will just let the OS select a random client port for each new
354 // connection.
355 bool enable_port_selection_;
356
jri2b966f22014-09-02 22:25:36357 // Set if we always require handshake confirmation. If true, this will
358 // introduce at least one RTT for the handshake before the client sends data.
359 bool always_require_handshake_confirmation_;
360
jri584002d12014-09-09 00:51:28361 // Set if we do not want connection pooling.
362 bool disable_connection_pooling_;
363
rtenneti2912825c2015-01-06 01:19:46364 // Specifies the ratio between time to load QUIC server information from disk
365 // cache to 'smoothed RTT'. This ratio is used to calculate the timeout in
366 // milliseconds to wait for loading of QUIC server information. If we don't
367 // want to timeout, set |load_server_info_timeout_srtt_multiplier_| to 0.
368 float load_server_info_timeout_srtt_multiplier_;
369
rtenneti14abd312015-02-06 21:56:01370 // Set if we want to race connections - one connection that sends
371 // INCHOATE_HELLO and another connection that sends CHLO after loading server
372 // config from the disk cache.
373 bool enable_connection_racing_;
374
qyearsley3257b7de2015-02-28 06:59:03375 // Set if experimental non-blocking IO should be used on windows sockets.
376 bool enable_non_blocking_io_;
377
rtenneti34dffe752015-02-24 23:27:32378 // Set if we do not want to load server config from the disk cache.
379 bool disable_disk_cache_;
380
rch9976b0c2015-06-10 21:27:23381 // Set if AES-GCM should be preferred, even if there is no hardware support.
382 bool prefer_aes_;
383
rtenneti85dcfac22015-03-27 20:22:19384 // Set if we want to disable QUIC when there is high packet loss rate.
385 // Specifies the maximum number of connections with high packet loss in a row
386 // after which QUIC will be disabled.
387 int max_number_of_lossy_connections_;
rtenneti374e56882015-03-28 13:49:54388 // Specifies packet loss rate in fraction after which a connection is closed
rtenneti85dcfac22015-03-27 20:22:19389 // and is considered as a lossy connection.
390 float packet_loss_threshold_;
391 // Count number of lossy connections by port.
392 std::map<uint16, int> number_of_lossy_connections_;
393
ckrasic1e53b642015-07-08 22:39:35394 // Keep track of stats for recently closed connections, using a
395 // bounded queue.
396 int max_disabled_reasons_;
397 DisabledReasonsQueue disabled_reasons_;
398 // Events that can trigger disabling QUIC
399 int num_public_resets_post_handshake_;
400 int num_timeouts_with_open_streams_;
401 // Keep track the largest values for UMA histograms, that will help
402 // determine good threshold values.
403 int max_public_resets_post_handshake_;
404 int max_timeouts_with_open_streams_;
405 // Thresholds if greater than zero, determine when to
406 int threshold_timeouts_with_open_streams_;
407 int threshold_public_resets_post_handshake_;
408
rchc7433572015-02-27 18:16:51409 // Size of the UDP receive buffer.
410 int socket_receive_buffer_size_;
411
412 // Each profile will (probably) have a unique port_seed_ value. This value
413 // is used to help seed a pseudo-random number generator (PortSuggester) so
414 // that we consistently (within this profile) suggest the same ephemeral
415 // port when we re-connect to any given server/port. The differences between
416 // profiles (probablistically) prevent two profiles from colliding in their
417 // ephemeral port requests.
[email protected]337e1452013-12-16 23:57:50418 uint64 port_seed_;
[email protected]7034cf12013-12-13 22:47:07419
rtennetifc47e0e2014-09-26 02:54:05420 // Local address of socket that was created in CreateSession.
421 IPEndPoint local_address_;
422 bool check_persisted_supports_quic_;
rtenneti1681f852014-11-13 20:34:03423 std::set<HostPortPair> quic_supported_servers_at_startup_;
rtennetifc47e0e2014-09-26 02:54:05424
rtenneti041b2992015-02-23 23:03:28425 NetworkConnection network_connection_;
426
rtenneti38f5cd52014-10-28 20:28:28427 base::TaskRunner* task_runner_;
428
[email protected]1e960032013-12-20 19:00:20429 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
430
[email protected]e13201d82012-12-12 05:00:32431 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
432};
433
434} // namespace net
435
436#endif // NET_QUIC_QUIC_STREAM_FACTORY_H_