blob: 9eea4199058cd44df468d66518fd5361ea2c5f0a [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
thestiga0e18cd2015-09-25 04:58:3613#include "base/gtest_prod_util.h"
[email protected]e8cf7555b2014-02-28 23:52:5314#include "base/logging.h"
[email protected]e13201d82012-12-12 05:00:3215#include "base/memory/weak_ptr.h"
rtenneti8332ba52015-09-17 19:33:4116#include "base/time/time.h"
[email protected]e13201d82012-12-12 05:00:3217#include "net/base/address_list.h"
18#include "net/base/completion_callback.h"
19#include "net/base/host_port_pair.h"
[email protected]f698a012013-05-06 20:18:5920#include "net/base/network_change_notifier.h"
[email protected]d7d1e50b2013-11-25 22:08:0921#include "net/cert/cert_database.h"
eroman87c53d62015-04-02 06:51:0722#include "net/log/net_log.h"
[email protected]e13201d82012-12-12 05:00:3223#include "net/proxy/proxy_server.h"
rtenneti041b2992015-02-23 23:03:2824#include "net/quic/network_connection.h"
ckrasic4f9d88d2015-07-22 22:23:1625#include "net/quic/quic_chromium_client_session.h"
[email protected]ef95114d2013-04-17 17:57:0126#include "net/quic/quic_config.h"
27#include "net/quic/quic_crypto_stream.h"
[email protected]e13201d82012-12-12 05:00:3228#include "net/quic/quic_http_stream.h"
29#include "net/quic/quic_protocol.h"
rch02d87792015-09-09 09:05:5330#include "net/ssl/ssl_config_service.h"
[email protected]e13201d82012-12-12 05:00:3231
32namespace net {
33
rsleevi9541f8632015-07-31 00:07:0034class CertPolicyEnforcer;
[email protected]6d1b4ed2013-07-10 03:57:5435class CertVerifier;
[email protected]6b8a3c742014-07-25 00:25:3536class ChannelIDService;
[email protected]e13201d82012-12-12 05:00:3237class ClientSocketFactory;
rtenneti052774e2015-11-24 21:00:1238class CTVerifier;
[email protected]6d1b4ed2013-07-10 03:57:5439class HostResolver;
[email protected]77c6c162013-08-17 02:57:4540class HttpServerProperties;
[email protected]e13201d82012-12-12 05:00:3241class QuicClock;
ckrasic4f9d88d2015-07-22 22:23:1642class QuicChromiumClientSession;
[email protected]2cfc6bb82013-10-27 03:40:4443class QuicConnectionHelper;
[email protected]e8ff26842013-03-22 21:02:0544class QuicCryptoClientStreamFactory;
[email protected]9558c5d32012-12-22 00:08:1445class QuicRandom;
[email protected]257f24f2014-04-01 09:15:3746class QuicServerId;
rtenneti13c9d38d2015-10-12 21:25:0147class QuicServerInfo;
48class QuicServerInfoFactory;
[email protected]e13201d82012-12-12 05:00:3249class QuicStreamFactory;
tbansalfdf5665b2015-09-21 22:46:4050class SocketPerformanceWatcherFactory;
[email protected]080b77932014-08-04 01:22:4651class TransportSecurityState;
[email protected]e13201d82012-12-12 05:00:3252
[email protected]c49ff182013-09-28 08:33:2653namespace test {
54class QuicStreamFactoryPeer;
55} // namespace test
56
rtenneti41c09992015-11-30 18:24:0157// When a connection is idle for 30 seconds it will be closed.
58const int kIdleConnectionTimeoutSeconds = 30;
59
[email protected]e13201d82012-12-12 05:00:3260// Encapsulates a pending request for a QuicHttpStream.
61// If the request is still pending when it is destroyed, it will
62// cancel the request with the factory.
63class NET_EXPORT_PRIVATE QuicStreamRequest {
64 public:
65 explicit QuicStreamRequest(QuicStreamFactory* factory);
66 ~QuicStreamRequest();
67
rtennetia75df622015-06-21 23:59:5068 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is
69 // passed to CertVerifier::Verify.
[email protected]bf4ea2f2014-03-10 22:57:5370 int Request(const HostPortPair& host_port_pair,
[email protected]9dd3ff0f2014-03-26 09:51:2871 PrivacyMode privacy_mode,
rtennetia75df622015-06-21 23:59:5072 int cert_verify_flags,
bnc68d401dd2015-05-18 20:31:4873 base::StringPiece origin_host,
[email protected]974849d2014-02-06 01:32:5974 base::StringPiece method,
[email protected]e13201d82012-12-12 05:00:3275 const BoundNetLog& net_log,
76 const CompletionCallback& callback);
77
78 void OnRequestComplete(int rv);
79
rtenneti8332ba52015-09-17 19:33:4180 // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It
81 // returns the amount of time waiting job should be delayed.
82 base::TimeDelta GetTimeDelayForWaitingJob() const;
83
[email protected]e13201d82012-12-12 05:00:3284 scoped_ptr<QuicHttpStream> ReleaseStream();
85
86 void set_stream(scoped_ptr<QuicHttpStream> stream);
87
shiva.jmd4e2adf2015-09-02 06:35:0288 const std::string& origin_host() const { return origin_host_; }
bnccb7ff3c2015-05-21 20:51:5589
90 PrivacyMode privacy_mode() const { return privacy_mode_; }
91
thestiga0e18cd2015-09-25 04:58:3692 const BoundNetLog& net_log() const { return net_log_; }
[email protected]e13201d82012-12-12 05:00:3293
94 private:
95 QuicStreamFactory* factory_;
[email protected]bf4ea2f2014-03-10 22:57:5396 HostPortPair host_port_pair_;
bnccb7ff3c2015-05-21 20:51:5597 std::string origin_host_;
98 PrivacyMode privacy_mode_;
[email protected]e13201d82012-12-12 05:00:3299 BoundNetLog net_log_;
100 CompletionCallback callback_;
101 scoped_ptr<QuicHttpStream> stream_;
102
103 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest);
104};
105
106// A factory for creating new QuicHttpStreams on top of a pool of
ckrasic4f9d88d2015-07-22 22:23:16107// QuicChromiumClientSessions.
[email protected]f698a012013-05-06 20:18:59108class NET_EXPORT_PRIVATE QuicStreamFactory
[email protected]d7d1e50b2013-11-25 22:08:09109 : public NetworkChangeNotifier::IPAddressObserver,
rch02d87792015-09-09 09:05:53110 public SSLConfigService::Observer,
[email protected]d7d1e50b2013-11-25 22:08:09111 public CertDatabase::Observer {
[email protected]e13201d82012-12-12 05:00:32112 public:
[email protected]e8ff26842013-03-22 21:02:05113 QuicStreamFactory(
114 HostResolver* host_resolver,
115 ClientSocketFactory* client_socket_factory,
[email protected]77c6c162013-08-17 02:57:45116 base::WeakPtr<HttpServerProperties> http_server_properties,
[email protected]59c0bbd2014-03-22 04:08:12117 CertVerifier* cert_verifier,
rsleevi9541f8632015-07-31 00:07:00118 CertPolicyEnforcer* cert_policy_enforcer,
[email protected]6b8a3c742014-07-25 00:25:35119 ChannelIDService* channel_id_service,
[email protected]080b77932014-08-04 01:22:46120 TransportSecurityState* transport_security_state,
rtenneti052774e2015-11-24 21:00:12121 CTVerifier* cert_transparency_verifier,
tbansalc8a94ea2015-11-02 23:58:51122 SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
[email protected]e8ff26842013-03-22 21:02:05123 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory,
124 QuicRandom* random_generator,
[email protected]256fe9b2013-11-27 01:58:02125 QuicClock* clock,
[email protected]1e960032013-12-20 19:00:20126 size_t max_packet_length,
[email protected]0c4017ca2014-06-06 03:30:45127 const std::string& user_agent_id,
[email protected]376d38a2014-01-22 03:47:35128 const QuicVersionVector& supported_versions,
[email protected]c80f7c92014-02-27 13:12:02129 bool enable_port_selection,
jri2b966f22014-09-02 22:25:36130 bool always_require_handshake_confirmation,
jri584002d12014-09-09 00:51:28131 bool disable_connection_pooling,
rtenneti2912825c2015-01-06 01:19:46132 float load_server_info_timeout_srtt_multiplier,
rtenneti4f809972015-02-11 19:38:34133 bool enable_connection_racing,
qyearsley3257b7de2015-02-28 06:59:03134 bool enable_non_blocking_io,
rtenneti34dffe752015-02-24 23:27:32135 bool disable_disk_cache,
rch9976b0c2015-06-10 21:27:23136 bool prefer_aes,
rtenneti85dcfac22015-03-27 20:22:19137 int max_number_of_lossy_connections,
138 float packet_loss_threshold,
ckrasic1e53b642015-07-08 22:39:35139 int max_recent_disabled_reasons,
140 int threshold_timeouts_with_streams_open,
141 int threshold_public_resets_post_handshake,
rchc7433572015-02-27 18:16:51142 int socket_receive_buffer_size,
rtenneti8332ba52015-09-17 19:33:41143 bool delay_tcp_race,
rtenneticd2aaa15b2015-10-10 20:29:33144 bool store_server_configs_in_properties,
jri8c44d692015-10-23 23:53:41145 bool close_sessions_on_ip_change,
rtenneti41c09992015-11-30 18:24:01146 int idle_connection_timeout_seconds,
[email protected]4b4efab32014-07-01 02:36:16147 const QuicTagVector& connection_options);
dchengb03027d2014-10-21 12:00:20148 ~QuicStreamFactory() override;
[email protected]e13201d82012-12-12 05:00:32149
[email protected]bf4ea2f2014-03-10 22:57:53150 // Creates a new QuicHttpStream to |host_port_pair| which will be
rchf114d982015-10-21 01:34:56151 // owned by |request|.
[email protected]0cceb922014-07-01 02:00:56152 // If a matching session already exists, this method will return OK. If no
153 // matching session exists, this will return ERR_IO_PENDING and will invoke
154 // OnRequestComplete asynchronously.
[email protected]bf4ea2f2014-03-10 22:57:53155 int Create(const HostPortPair& host_port_pair,
[email protected]9dd3ff0f2014-03-26 09:51:28156 PrivacyMode privacy_mode,
rtennetia75df622015-06-21 23:59:50157 int cert_verify_flags,
bnccb7ff3c2015-05-21 20:51:55158 base::StringPiece origin_host,
[email protected]974849d2014-02-06 01:32:59159 base::StringPiece method,
[email protected]e13201d82012-12-12 05:00:32160 const BoundNetLog& net_log,
161 QuicStreamRequest* request);
162
rtenneti97137a92015-06-18 06:00:31163 // If |packet_loss_rate| is greater than or equal to |packet_loss_threshold_|
164 // it marks QUIC as recently broken for the port of the session. Increments
165 // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_|
166 // is greater than or equal to |max_number_of_lossy_connections_| then it
167 // disables QUIC. If QUIC is disabled then it closes the connection.
168 //
169 // Returns true if QUIC is disabled for the port of the session.
ckrasic4f9d88d2015-07-22 22:23:16170 bool OnHandshakeConfirmed(QuicChromiumClientSession* session,
171 float packet_loss_rate);
rtenneti85dcfac22015-03-27 20:22:19172
173 // Returns true if QUIC is disabled for this port.
174 bool IsQuicDisabled(uint16 port);
175
ckrasic1e53b642015-07-08 22:39:35176 // Returns reason QUIC is disabled for this port, or QUIC_DISABLED_NOT if not.
ckrasic4f9d88d2015-07-22 22:23:16177 QuicChromiumClientSession::QuicDisabledReason QuicDisabledReason(
178 uint16 port) const;
ckrasic1e53b642015-07-08 22:39:35179
180 // Returns reason QUIC is disabled as string for net-internals, or
181 // returns empty string if QUIC is not disabled.
182 const char* QuicDisabledReasonString() const;
183
[email protected]e13201d82012-12-12 05:00:32184 // Called by a session when it becomes idle.
ckrasic4f9d88d2015-07-22 22:23:16185 void OnIdleSession(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32186
[email protected]4d283b32013-10-17 12:57:27187 // Called by a session when it is going away and no more streams should be
188 // created on it.
ckrasic4f9d88d2015-07-22 22:23:16189 void OnSessionGoingAway(QuicChromiumClientSession* session);
[email protected]4d283b32013-10-17 12:57:27190
[email protected]e13201d82012-12-12 05:00:32191 // Called by a session after it shuts down.
ckrasic4f9d88d2015-07-22 22:23:16192 void OnSessionClosed(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32193
[email protected]65768442014-06-06 23:37:03194 // Called by a session whose connection has timed out.
ckrasic4f9d88d2015-07-22 22:23:16195 void OnSessionConnectTimeout(QuicChromiumClientSession* session);
[email protected]65768442014-06-06 23:37:03196
[email protected]e13201d82012-12-12 05:00:32197 // Cancels a pending request.
198 void CancelRequest(QuicStreamRequest* request);
199
[email protected]56dfb902013-01-03 23:17:55200 // Closes all current sessions.
201 void CloseAllSessions(int error);
202
payal.pandeya18956a2015-05-27 05:57:55203 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const;
[email protected]c5b061b2013-01-05 00:31:34204
[email protected]f7e21a432014-04-21 22:17:57205 // Delete all cached state objects in |crypto_config_|.
[email protected]60cf50e2014-04-28 23:23:18206 void ClearCachedStatesInCryptoConfig();
[email protected]f7e21a432014-04-21 22:17:57207
[email protected]f698a012013-05-06 20:18:59208 // NetworkChangeNotifier::IPAddressObserver methods:
209
210 // Until the servers support roaming, close all connections when the local
211 // IP address changes.
dchengb03027d2014-10-21 12:00:20212 void OnIPAddressChanged() override;
[email protected]f698a012013-05-06 20:18:59213
rch02d87792015-09-09 09:05:53214 // SSLConfigService::Observer methods:
215
216 // We perform the same flushing as described above when SSL settings change.
217 void OnSSLConfigChanged() override;
218
[email protected]d7d1e50b2013-11-25 22:08:09219 // CertDatabase::Observer methods:
220
221 // We close all sessions when certificate database is changed.
dchengb03027d2014-10-21 12:00:20222 void OnCertAdded(const X509Certificate* cert) override;
223 void OnCACertChanged(const X509Certificate* cert) override;
[email protected]d7d1e50b2013-11-25 22:08:09224
rjshaded5ced072015-12-18 19:26:02225 bool require_confirmation() const { return require_confirmation_; }
[email protected]11c05872013-08-20 02:04:12226
rtennetifc47e0e2014-09-26 02:54:05227 void set_require_confirmation(bool require_confirmation);
[email protected]11c05872013-08-20 02:04:12228
rtennetid2e74caa2015-12-09 00:51:57229 bool ZeroRTTEnabledFor(const QuicServerId& server_id);
230
rtenneti8332ba52015-09-17 19:33:41231 // It returns the amount of time waiting job should be delayed.
232 base::TimeDelta GetTimeDelayForWaitingJob(const QuicServerId& server_id);
233
[email protected]2cfc6bb82013-10-27 03:40:44234 QuicConnectionHelper* helper() { return helper_.get(); }
235
[email protected]376d38a2014-01-22 03:47:35236 bool enable_port_selection() const { return enable_port_selection_; }
237
[email protected]a4205202014-06-02 16:03:08238 bool has_quic_server_info_factory() {
rtenneti13c9d38d2015-10-12 21:25:01239 return !quic_server_info_factory_.get();
[email protected]a4205202014-06-02 16:03:08240 }
241
[email protected]e8cf7555b2014-02-28 23:52:53242 void set_quic_server_info_factory(
rtenneti13c9d38d2015-10-12 21:25:01243 QuicServerInfoFactory* quic_server_info_factory);
[email protected]e8cf7555b2014-02-28 23:52:53244
rtenneti14abd312015-02-06 21:56:01245 bool enable_connection_racing() const { return enable_connection_racing_; }
246 void set_enable_connection_racing(bool enable_connection_racing) {
247 enable_connection_racing_ = enable_connection_racing;
248 }
249
rch185ebee2015-07-14 23:56:22250 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; }
251
rtenneti8332ba52015-09-17 19:33:41252 bool delay_tcp_race() const { return delay_tcp_race_; }
253
rtenneticd2aaa15b2015-10-10 20:29:33254 bool store_server_configs_in_properties() const {
255 return store_server_configs_in_properties_;
256 }
257
[email protected]e13201d82012-12-12 05:00:32258 private:
259 class Job;
[email protected]c49ff182013-09-28 08:33:26260 friend class test::QuicStreamFactoryPeer;
tbansala5268e22015-06-30 02:57:58261 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad);
[email protected]e13201d82012-12-12 05:00:32262
ckrasic4f9d88d2015-07-22 22:23:16263 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap;
264 typedef std::map<QuicChromiumClientSession*, QuicServerId> SessionIdMap;
[email protected]257f24f2014-04-01 09:15:37265 typedef std::set<QuicServerId> AliasSet;
ckrasic4f9d88d2015-07-22 22:23:16266 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap;
267 typedef std::set<QuicChromiumClientSession*> SessionSet;
rchf114d982015-10-21 01:34:56268 typedef std::map<IPEndPoint, SessionSet> IPAliasMap;
[email protected]257f24f2014-04-01 09:15:37269 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap;
rtenneti14abd312015-02-06 21:56:01270 typedef std::set<Job*> JobSet;
271 typedef std::map<QuicServerId, JobSet> JobMap;
272 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap;
[email protected]e13201d82012-12-12 05:00:32273 typedef std::set<QuicStreamRequest*> RequestSet;
rtenneti14abd312015-02-06 21:56:01274 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap;
ckrasic4f9d88d2015-07-22 22:23:16275 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason>
ckrasic1e53b642015-07-08 22:39:35276 DisabledReasonsQueue;
rtenneti14abd312015-02-06 21:56:01277
278 // Creates a job which doesn't wait for server config to be loaded from the
279 // disk cache. This job is started via a PostTask.
280 void CreateAuxilaryJob(const QuicServerId server_id,
rtennetia75df622015-06-21 23:59:50281 int cert_verify_flags,
bnc68d401dd2015-05-18 20:31:48282 bool server_and_origin_have_same_host,
rtenneti14abd312015-02-06 21:56:01283 bool is_post,
284 const BoundNetLog& net_log);
[email protected]e13201d82012-12-12 05:00:32285
bnccb7ff3c2015-05-21 20:51:55286 // Returns a newly created QuicHttpStream owned by the caller.
thestiga0e18cd2015-09-25 04:58:36287 scoped_ptr<QuicHttpStream> CreateFromSession(
288 QuicChromiumClientSession* session);
[email protected]df157d9d2014-03-10 07:27:27289
[email protected]257f24f2014-04-01 09:15:37290 bool OnResolution(const QuicServerId& server_id,
[email protected]eed749f92013-12-23 18:57:38291 const AddressList& address_list);
[email protected]e13201d82012-12-12 05:00:32292 void OnJobComplete(Job* job, int rv);
[email protected]257f24f2014-04-01 09:15:37293 bool HasActiveSession(const QuicServerId& server_id) const;
294 bool HasActiveJob(const QuicServerId& server_id) const;
295 int CreateSession(const QuicServerId& server_id,
rtennetia75df622015-06-21 23:59:50296 int cert_verify_flags,
[email protected]17bf15c2014-03-14 10:08:04297 scoped_ptr<QuicServerInfo> quic_server_info,
[email protected]338e7982013-12-13 11:15:32298 const AddressList& address_list,
rtennetif4f08852015-02-27 17:50:04299 base::TimeTicks dns_resolution_end_time,
[email protected]338e7982013-12-13 11:15:32300 const BoundNetLog& net_log,
ckrasic4f9d88d2015-07-22 22:23:16301 QuicChromiumClientSession** session);
[email protected]257f24f2014-04-01 09:15:37302 void ActivateSession(const QuicServerId& key,
ckrasic4f9d88d2015-07-22 22:23:16303 QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32304
rtenneti2912825c2015-01-06 01:19:46305 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there
306 // is no |http_server_properties_| or if |http_server_properties_| doesn't
307 // have ServerNetworkStats for the given |server_id|.
308 int64 GetServerNetworkStatsSmoothedRttInMicroseconds(
309 const QuicServerId& server_id) const;
310
bnccacc0992015-03-20 20:22:22311 // Helper methods.
312 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const;
rtenneti8332ba52015-09-17 19:33:41313
rtenneti14abd312015-02-06 21:56:01314 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id);
315
[email protected]257f24f2014-04-01 09:15:37316 // Initializes the cached state associated with |server_id| in
[email protected]59c0bbd2014-03-22 04:08:12317 // |crypto_config_| with the information in |server_info|.
[email protected]60cf50e2014-04-28 23:23:18318 void InitializeCachedStateInCryptoConfig(
319 const QuicServerId& server_id,
320 const scoped_ptr<QuicServerInfo>& server_info);
[email protected]b694e48c2014-03-18 17:10:13321
rtenneti8a80a6dc2015-09-21 19:51:13322 // Initialize |quic_supported_servers_at_startup_| with the list of servers
rtenneticd2aaa15b2015-10-10 20:29:33323 // that supported QUIC at start up and also initialize in-memory cache of
324 // QuicServerInfo objects from HttpServerProperties.
325 void MaybeInitialize();
rtenneti8a80a6dc2015-09-21 19:51:13326
ckrasic4f9d88d2015-07-22 22:23:16327 void ProcessGoingAwaySession(QuicChromiumClientSession* session,
[email protected]eb71ab62014-05-23 07:57:53328 const QuicServerId& server_id,
329 bool was_session_active);
[email protected]4d590c9c2014-05-02 05:14:33330
ckrasic1e53b642015-07-08 22:39:35331 // Collect stats from recent connections, possibly disabling Quic.
ckrasic4f9d88d2015-07-22 22:23:16332 void MaybeDisableQuic(QuicChromiumClientSession* session);
ckrasic1e53b642015-07-08 22:39:35333
[email protected]11c05872013-08-20 02:04:12334 bool require_confirmation_;
[email protected]e13201d82012-12-12 05:00:32335 HostResolver* host_resolver_;
336 ClientSocketFactory* client_socket_factory_;
[email protected]77c6c162013-08-17 02:57:45337 base::WeakPtr<HttpServerProperties> http_server_properties_;
[email protected]5db452202014-08-19 05:22:15338 TransportSecurityState* transport_security_state_;
rtenneti052774e2015-11-24 21:00:12339 CTVerifier* cert_transparency_verifier_;
rtenneti13c9d38d2015-10-12 21:25:01340 scoped_ptr<QuicServerInfoFactory> quic_server_info_factory_;
[email protected]e8ff26842013-03-22 21:02:05341 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_;
[email protected]9558c5d32012-12-22 00:08:14342 QuicRandom* random_generator_;
[email protected]f1e97e92012-12-16 04:53:25343 scoped_ptr<QuicClock> clock_;
[email protected]256fe9b2013-11-27 01:58:02344 const size_t max_packet_length_;
[email protected]e13201d82012-12-12 05:00:32345
tbansalfdf5665b2015-09-21 22:46:40346 // Factory which is used to create socket performance watcher. A new watcher
347 // is created for every QUIC connection.
348 // |socket_performance_watcher_factory_| may be null.
tbansalc8a94ea2015-11-02 23:58:51349 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
tbansalfdf5665b2015-09-21 22:46:40350
[email protected]2cfc6bb82013-10-27 03:40:44351 // The helper used for all connections.
352 scoped_ptr<QuicConnectionHelper> helper_;
353
[email protected]e13201d82012-12-12 05:00:32354 // Contains owning pointers to all sessions that currently exist.
[email protected]4d590c9c2014-05-02 05:14:33355 SessionIdMap all_sessions_;
[email protected]e13201d82012-12-12 05:00:32356 // Contains non-owning pointers to currently active session
357 // (not going away session, once they're implemented).
358 SessionMap active_sessions_;
[email protected]eed749f92013-12-23 18:57:38359 // Map from session to set of aliases that this session is known by.
[email protected]e13201d82012-12-12 05:00:32360 SessionAliasMap session_aliases_;
[email protected]eed749f92013-12-23 18:57:38361 // Map from IP address to sessions which are connected to this address.
362 IPAliasMap ip_aliases_;
[email protected]e13201d82012-12-12 05:00:32363
[email protected]d8e2abf82014-03-06 10:30:10364 // Origins which have gone away recently.
365 AliasSet gone_away_aliases_;
366
[email protected]fd276a282014-06-11 04:26:14367 const QuicConfig config_;
[email protected]59c0bbd2014-03-22 04:08:12368 QuicCryptoClientConfig crypto_config_;
[email protected]b064310782013-05-30 21:12:17369
[email protected]e13201d82012-12-12 05:00:32370 JobMap active_jobs_;
rtenneti14abd312015-02-06 21:56:01371 ServerIDRequestsMap job_requests_map_;
[email protected]e13201d82012-12-12 05:00:32372 RequestMap active_requests_;
373
[email protected]1e960032013-12-20 19:00:20374 QuicVersionVector supported_versions_;
[email protected]e13201d82012-12-12 05:00:32375
[email protected]376d38a2014-01-22 03:47:35376 // Determine if we should consistently select a client UDP port. If false,
377 // then we will just let the OS select a random client port for each new
378 // connection.
379 bool enable_port_selection_;
380
jri2b966f22014-09-02 22:25:36381 // Set if we always require handshake confirmation. If true, this will
382 // introduce at least one RTT for the handshake before the client sends data.
383 bool always_require_handshake_confirmation_;
384
jri584002d12014-09-09 00:51:28385 // Set if we do not want connection pooling.
386 bool disable_connection_pooling_;
387
rtenneti2912825c2015-01-06 01:19:46388 // Specifies the ratio between time to load QUIC server information from disk
389 // cache to 'smoothed RTT'. This ratio is used to calculate the timeout in
390 // milliseconds to wait for loading of QUIC server information. If we don't
391 // want to timeout, set |load_server_info_timeout_srtt_multiplier_| to 0.
392 float load_server_info_timeout_srtt_multiplier_;
393
rtenneti14abd312015-02-06 21:56:01394 // Set if we want to race connections - one connection that sends
395 // INCHOATE_HELLO and another connection that sends CHLO after loading server
396 // config from the disk cache.
397 bool enable_connection_racing_;
398
qyearsley3257b7de2015-02-28 06:59:03399 // Set if experimental non-blocking IO should be used on windows sockets.
400 bool enable_non_blocking_io_;
401
rtenneti34dffe752015-02-24 23:27:32402 // Set if we do not want to load server config from the disk cache.
403 bool disable_disk_cache_;
404
rch9976b0c2015-06-10 21:27:23405 // Set if AES-GCM should be preferred, even if there is no hardware support.
406 bool prefer_aes_;
407
rtenneti85dcfac22015-03-27 20:22:19408 // Set if we want to disable QUIC when there is high packet loss rate.
409 // Specifies the maximum number of connections with high packet loss in a row
410 // after which QUIC will be disabled.
411 int max_number_of_lossy_connections_;
rtenneti374e56882015-03-28 13:49:54412 // Specifies packet loss rate in fraction after which a connection is closed
rtenneti85dcfac22015-03-27 20:22:19413 // and is considered as a lossy connection.
414 float packet_loss_threshold_;
415 // Count number of lossy connections by port.
416 std::map<uint16, int> number_of_lossy_connections_;
417
ckrasic1e53b642015-07-08 22:39:35418 // Keep track of stats for recently closed connections, using a
419 // bounded queue.
420 int max_disabled_reasons_;
421 DisabledReasonsQueue disabled_reasons_;
422 // Events that can trigger disabling QUIC
423 int num_public_resets_post_handshake_;
424 int num_timeouts_with_open_streams_;
425 // Keep track the largest values for UMA histograms, that will help
426 // determine good threshold values.
427 int max_public_resets_post_handshake_;
428 int max_timeouts_with_open_streams_;
429 // Thresholds if greater than zero, determine when to
430 int threshold_timeouts_with_open_streams_;
431 int threshold_public_resets_post_handshake_;
432
rchc7433572015-02-27 18:16:51433 // Size of the UDP receive buffer.
434 int socket_receive_buffer_size_;
435
rtenneti8332ba52015-09-17 19:33:41436 // Set if we do want to delay TCP connection when it is racing with QUIC.
437 bool delay_tcp_race_;
438
rtenneti1cd3b162015-09-29 02:58:28439 // If more than |yield_after_packets_| packets have been read or more than
440 // |yield_after_duration_| time has passed, then
441 // QuicPacketReader::StartReading() yields by doing a PostTask().
442 int yield_after_packets_;
443 QuicTime::Delta yield_after_duration_;
444
rtenneticd2aaa15b2015-10-10 20:29:33445 // Set if server configs are to be stored in HttpServerProperties.
446 bool store_server_configs_in_properties_;
447
jri8c44d692015-10-23 23:53:41448 // Set if all sessions should be closed when any local IP address changes.
449 const bool close_sessions_on_ip_change_;
450
rchc7433572015-02-27 18:16:51451 // Each profile will (probably) have a unique port_seed_ value. This value
452 // is used to help seed a pseudo-random number generator (PortSuggester) so
453 // that we consistently (within this profile) suggest the same ephemeral
454 // port when we re-connect to any given server/port. The differences between
455 // profiles (probablistically) prevent two profiles from colliding in their
456 // ephemeral port requests.
[email protected]337e1452013-12-16 23:57:50457 uint64 port_seed_;
[email protected]7034cf12013-12-13 22:47:07458
rtennetifc47e0e2014-09-26 02:54:05459 // Local address of socket that was created in CreateSession.
460 IPEndPoint local_address_;
461 bool check_persisted_supports_quic_;
rtenneticd2aaa15b2015-10-10 20:29:33462 bool has_initialized_data_;
rtenneti1681f852014-11-13 20:34:03463 std::set<HostPortPair> quic_supported_servers_at_startup_;
rtennetifc47e0e2014-09-26 02:54:05464
rtenneti041b2992015-02-23 23:03:28465 NetworkConnection network_connection_;
466
rtenneti38f5cd52014-10-28 20:28:28467 base::TaskRunner* task_runner_;
468
[email protected]1e960032013-12-20 19:00:20469 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
470
[email protected]e13201d82012-12-12 05:00:32471 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
472};
473
474} // namespace net
475
476#endif // NET_QUIC_QUIC_STREAM_FACTORY_H_