blob: fd317d669d690757c537aae0a95b21f20f763961 [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
Avi Drissman13fc8932015-12-20 04:40:468#include <stddef.h>
9#include <stdint.h>
10
[email protected]1cd2a5f2014-03-14 06:33:2511#include <list>
[email protected]e13201d82012-12-12 05:00:3212#include <map>
[email protected]41d6b172013-01-29 16:10:5713#include <string>
[email protected]6e12d702013-11-13 00:17:1714#include <vector>
[email protected]e13201d82012-12-12 05:00:3215
thestiga0e18cd2015-09-25 04:58:3616#include "base/gtest_prod_util.h"
[email protected]e8cf7555b2014-02-28 23:52:5317#include "base/logging.h"
Avi Drissman13fc8932015-12-20 04:40:4618#include "base/macros.h"
[email protected]e13201d82012-12-12 05:00:3219#include "base/memory/weak_ptr.h"
rtenneti8332ba52015-09-17 19:33:4120#include "base/time/time.h"
[email protected]e13201d82012-12-12 05:00:3221#include "net/base/address_list.h"
22#include "net/base/completion_callback.h"
23#include "net/base/host_port_pair.h"
[email protected]f698a012013-05-06 20:18:5924#include "net/base/network_change_notifier.h"
[email protected]d7d1e50b2013-11-25 22:08:0925#include "net/cert/cert_database.h"
eroman87c53d62015-04-02 06:51:0726#include "net/log/net_log.h"
[email protected]e13201d82012-12-12 05:00:3227#include "net/proxy/proxy_server.h"
rtenneti041b2992015-02-23 23:03:2828#include "net/quic/network_connection.h"
ckrasic4f9d88d2015-07-22 22:23:1629#include "net/quic/quic_chromium_client_session.h"
[email protected]ef95114d2013-04-17 17:57:0130#include "net/quic/quic_config.h"
31#include "net/quic/quic_crypto_stream.h"
[email protected]e13201d82012-12-12 05:00:3232#include "net/quic/quic_http_stream.h"
33#include "net/quic/quic_protocol.h"
rch02d87792015-09-09 09:05:5334#include "net/ssl/ssl_config_service.h"
[email protected]e13201d82012-12-12 05:00:3235
36namespace net {
37
rsleevi9541f8632015-07-31 00:07:0038class CertPolicyEnforcer;
[email protected]6d1b4ed2013-07-10 03:57:5439class CertVerifier;
[email protected]6b8a3c742014-07-25 00:25:3540class ChannelIDService;
[email protected]e13201d82012-12-12 05:00:3241class ClientSocketFactory;
rtenneti052774e2015-11-24 21:00:1242class CTVerifier;
[email protected]6d1b4ed2013-07-10 03:57:5443class HostResolver;
[email protected]77c6c162013-08-17 02:57:4544class HttpServerProperties;
[email protected]e13201d82012-12-12 05:00:3245class QuicClock;
ckrasic4f9d88d2015-07-22 22:23:1646class QuicChromiumClientSession;
[email protected]2cfc6bb82013-10-27 03:40:4447class QuicConnectionHelper;
[email protected]e8ff26842013-03-22 21:02:0548class QuicCryptoClientStreamFactory;
[email protected]9558c5d32012-12-22 00:08:1449class QuicRandom;
[email protected]257f24f2014-04-01 09:15:3750class QuicServerId;
rtenneti13c9d38d2015-10-12 21:25:0151class QuicServerInfo;
52class QuicServerInfoFactory;
[email protected]e13201d82012-12-12 05:00:3253class QuicStreamFactory;
tbansalfdf5665b2015-09-21 22:46:4054class SocketPerformanceWatcherFactory;
[email protected]080b77932014-08-04 01:22:4655class TransportSecurityState;
[email protected]e13201d82012-12-12 05:00:3256
[email protected]c49ff182013-09-28 08:33:2657namespace test {
58class QuicStreamFactoryPeer;
59} // namespace test
60
rtenneti41c09992015-11-30 18:24:0161// When a connection is idle for 30 seconds it will be closed.
62const int kIdleConnectionTimeoutSeconds = 30;
63
[email protected]e13201d82012-12-12 05:00:3264// Encapsulates a pending request for a QuicHttpStream.
65// If the request is still pending when it is destroyed, it will
66// cancel the request with the factory.
67class NET_EXPORT_PRIVATE QuicStreamRequest {
68 public:
69 explicit QuicStreamRequest(QuicStreamFactory* factory);
70 ~QuicStreamRequest();
71
rtennetia75df622015-06-21 23:59:5072 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is
73 // passed to CertVerifier::Verify.
[email protected]bf4ea2f2014-03-10 22:57:5374 int Request(const HostPortPair& host_port_pair,
[email protected]9dd3ff0f2014-03-26 09:51:2875 PrivacyMode privacy_mode,
rtennetia75df622015-06-21 23:59:5076 int cert_verify_flags,
bnc68d401dd2015-05-18 20:31:4877 base::StringPiece origin_host,
[email protected]974849d2014-02-06 01:32:5978 base::StringPiece method,
[email protected]e13201d82012-12-12 05:00:3279 const BoundNetLog& net_log,
80 const CompletionCallback& callback);
81
82 void OnRequestComplete(int rv);
83
rtenneti8332ba52015-09-17 19:33:4184 // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It
85 // returns the amount of time waiting job should be delayed.
86 base::TimeDelta GetTimeDelayForWaitingJob() const;
87
[email protected]e13201d82012-12-12 05:00:3288 scoped_ptr<QuicHttpStream> ReleaseStream();
89
90 void set_stream(scoped_ptr<QuicHttpStream> stream);
91
shiva.jmd4e2adf2015-09-02 06:35:0292 const std::string& origin_host() const { return origin_host_; }
bnccb7ff3c2015-05-21 20:51:5593
94 PrivacyMode privacy_mode() const { return privacy_mode_; }
95
thestiga0e18cd2015-09-25 04:58:3696 const BoundNetLog& net_log() const { return net_log_; }
[email protected]e13201d82012-12-12 05:00:3297
98 private:
99 QuicStreamFactory* factory_;
[email protected]bf4ea2f2014-03-10 22:57:53100 HostPortPair host_port_pair_;
bnccb7ff3c2015-05-21 20:51:55101 std::string origin_host_;
102 PrivacyMode privacy_mode_;
[email protected]e13201d82012-12-12 05:00:32103 BoundNetLog net_log_;
104 CompletionCallback callback_;
105 scoped_ptr<QuicHttpStream> stream_;
106
107 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest);
108};
109
110// A factory for creating new QuicHttpStreams on top of a pool of
ckrasic4f9d88d2015-07-22 22:23:16111// QuicChromiumClientSessions.
[email protected]f698a012013-05-06 20:18:59112class NET_EXPORT_PRIVATE QuicStreamFactory
[email protected]d7d1e50b2013-11-25 22:08:09113 : public NetworkChangeNotifier::IPAddressObserver,
rch02d87792015-09-09 09:05:53114 public SSLConfigService::Observer,
[email protected]d7d1e50b2013-11-25 22:08:09115 public CertDatabase::Observer {
[email protected]e13201d82012-12-12 05:00:32116 public:
[email protected]e8ff26842013-03-22 21:02:05117 QuicStreamFactory(
118 HostResolver* host_resolver,
119 ClientSocketFactory* client_socket_factory,
[email protected]77c6c162013-08-17 02:57:45120 base::WeakPtr<HttpServerProperties> http_server_properties,
[email protected]59c0bbd2014-03-22 04:08:12121 CertVerifier* cert_verifier,
rsleevi9541f8632015-07-31 00:07:00122 CertPolicyEnforcer* cert_policy_enforcer,
[email protected]6b8a3c742014-07-25 00:25:35123 ChannelIDService* channel_id_service,
[email protected]080b77932014-08-04 01:22:46124 TransportSecurityState* transport_security_state,
rtenneti052774e2015-11-24 21:00:12125 CTVerifier* cert_transparency_verifier,
tbansalc8a94ea2015-11-02 23:58:51126 SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
[email protected]e8ff26842013-03-22 21:02:05127 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory,
128 QuicRandom* random_generator,
[email protected]256fe9b2013-11-27 01:58:02129 QuicClock* clock,
[email protected]1e960032013-12-20 19:00:20130 size_t max_packet_length,
[email protected]0c4017ca2014-06-06 03:30:45131 const std::string& user_agent_id,
[email protected]376d38a2014-01-22 03:47:35132 const QuicVersionVector& supported_versions,
[email protected]c80f7c92014-02-27 13:12:02133 bool enable_port_selection,
jri2b966f22014-09-02 22:25:36134 bool always_require_handshake_confirmation,
jri584002d12014-09-09 00:51:28135 bool disable_connection_pooling,
rtenneti2912825c2015-01-06 01:19:46136 float load_server_info_timeout_srtt_multiplier,
rtenneti4f809972015-02-11 19:38:34137 bool enable_connection_racing,
qyearsley3257b7de2015-02-28 06:59:03138 bool enable_non_blocking_io,
rtenneti34dffe752015-02-24 23:27:32139 bool disable_disk_cache,
rch9976b0c2015-06-10 21:27:23140 bool prefer_aes,
rtenneti85dcfac22015-03-27 20:22:19141 int max_number_of_lossy_connections,
142 float packet_loss_threshold,
ckrasic1e53b642015-07-08 22:39:35143 int max_recent_disabled_reasons,
144 int threshold_timeouts_with_streams_open,
145 int threshold_public_resets_post_handshake,
rchc7433572015-02-27 18:16:51146 int socket_receive_buffer_size,
rtenneti8332ba52015-09-17 19:33:41147 bool delay_tcp_race,
rtenneticd2aaa15b2015-10-10 20:29:33148 bool store_server_configs_in_properties,
jri8c44d692015-10-23 23:53:41149 bool close_sessions_on_ip_change,
rtenneti41c09992015-11-30 18:24:01150 int idle_connection_timeout_seconds,
[email protected]4b4efab32014-07-01 02:36:16151 const QuicTagVector& connection_options);
dchengb03027d2014-10-21 12:00:20152 ~QuicStreamFactory() override;
[email protected]e13201d82012-12-12 05:00:32153
[email protected]bf4ea2f2014-03-10 22:57:53154 // Creates a new QuicHttpStream to |host_port_pair| which will be
rchf114d982015-10-21 01:34:56155 // owned by |request|.
[email protected]0cceb922014-07-01 02:00:56156 // If a matching session already exists, this method will return OK. If no
157 // matching session exists, this will return ERR_IO_PENDING and will invoke
158 // OnRequestComplete asynchronously.
[email protected]bf4ea2f2014-03-10 22:57:53159 int Create(const HostPortPair& host_port_pair,
[email protected]9dd3ff0f2014-03-26 09:51:28160 PrivacyMode privacy_mode,
rtennetia75df622015-06-21 23:59:50161 int cert_verify_flags,
bnccb7ff3c2015-05-21 20:51:55162 base::StringPiece origin_host,
[email protected]974849d2014-02-06 01:32:59163 base::StringPiece method,
[email protected]e13201d82012-12-12 05:00:32164 const BoundNetLog& net_log,
165 QuicStreamRequest* request);
166
rtenneti97137a92015-06-18 06:00:31167 // If |packet_loss_rate| is greater than or equal to |packet_loss_threshold_|
168 // it marks QUIC as recently broken for the port of the session. Increments
169 // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_|
170 // is greater than or equal to |max_number_of_lossy_connections_| then it
171 // disables QUIC. If QUIC is disabled then it closes the connection.
172 //
173 // Returns true if QUIC is disabled for the port of the session.
ckrasic4f9d88d2015-07-22 22:23:16174 bool OnHandshakeConfirmed(QuicChromiumClientSession* session,
175 float packet_loss_rate);
rtenneti85dcfac22015-03-27 20:22:19176
177 // Returns true if QUIC is disabled for this port.
Avi Drissman13fc8932015-12-20 04:40:46178 bool IsQuicDisabled(uint16_t port);
rtenneti85dcfac22015-03-27 20:22:19179
ckrasic1e53b642015-07-08 22:39:35180 // Returns reason QUIC is disabled for this port, or QUIC_DISABLED_NOT if not.
ckrasic4f9d88d2015-07-22 22:23:16181 QuicChromiumClientSession::QuicDisabledReason QuicDisabledReason(
Avi Drissman13fc8932015-12-20 04:40:46182 uint16_t port) const;
ckrasic1e53b642015-07-08 22:39:35183
184 // Returns reason QUIC is disabled as string for net-internals, or
185 // returns empty string if QUIC is not disabled.
186 const char* QuicDisabledReasonString() const;
187
[email protected]e13201d82012-12-12 05:00:32188 // Called by a session when it becomes idle.
ckrasic4f9d88d2015-07-22 22:23:16189 void OnIdleSession(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32190
[email protected]4d283b32013-10-17 12:57:27191 // Called by a session when it is going away and no more streams should be
192 // created on it.
ckrasic4f9d88d2015-07-22 22:23:16193 void OnSessionGoingAway(QuicChromiumClientSession* session);
[email protected]4d283b32013-10-17 12:57:27194
[email protected]e13201d82012-12-12 05:00:32195 // Called by a session after it shuts down.
ckrasic4f9d88d2015-07-22 22:23:16196 void OnSessionClosed(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32197
[email protected]65768442014-06-06 23:37:03198 // Called by a session whose connection has timed out.
ckrasic4f9d88d2015-07-22 22:23:16199 void OnSessionConnectTimeout(QuicChromiumClientSession* session);
[email protected]65768442014-06-06 23:37:03200
[email protected]e13201d82012-12-12 05:00:32201 // Cancels a pending request.
202 void CancelRequest(QuicStreamRequest* request);
203
[email protected]56dfb902013-01-03 23:17:55204 // Closes all current sessions.
205 void CloseAllSessions(int error);
206
payal.pandeya18956a2015-05-27 05:57:55207 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const;
[email protected]c5b061b2013-01-05 00:31:34208
[email protected]f7e21a432014-04-21 22:17:57209 // Delete all cached state objects in |crypto_config_|.
[email protected]60cf50e2014-04-28 23:23:18210 void ClearCachedStatesInCryptoConfig();
[email protected]f7e21a432014-04-21 22:17:57211
[email protected]f698a012013-05-06 20:18:59212 // NetworkChangeNotifier::IPAddressObserver methods:
213
214 // Until the servers support roaming, close all connections when the local
215 // IP address changes.
dchengb03027d2014-10-21 12:00:20216 void OnIPAddressChanged() override;
[email protected]f698a012013-05-06 20:18:59217
rch02d87792015-09-09 09:05:53218 // SSLConfigService::Observer methods:
219
220 // We perform the same flushing as described above when SSL settings change.
221 void OnSSLConfigChanged() override;
222
[email protected]d7d1e50b2013-11-25 22:08:09223 // CertDatabase::Observer methods:
224
225 // We close all sessions when certificate database is changed.
dchengb03027d2014-10-21 12:00:20226 void OnCertAdded(const X509Certificate* cert) override;
227 void OnCACertChanged(const X509Certificate* cert) override;
[email protected]d7d1e50b2013-11-25 22:08:09228
rjshaded5ced072015-12-18 19:26:02229 bool require_confirmation() const { return require_confirmation_; }
[email protected]11c05872013-08-20 02:04:12230
rtennetifc47e0e2014-09-26 02:54:05231 void set_require_confirmation(bool require_confirmation);
[email protected]11c05872013-08-20 02:04:12232
rtennetid2e74caa2015-12-09 00:51:57233 bool ZeroRTTEnabledFor(const QuicServerId& server_id);
234
rtenneti8332ba52015-09-17 19:33:41235 // It returns the amount of time waiting job should be delayed.
236 base::TimeDelta GetTimeDelayForWaitingJob(const QuicServerId& server_id);
237
[email protected]2cfc6bb82013-10-27 03:40:44238 QuicConnectionHelper* helper() { return helper_.get(); }
239
[email protected]376d38a2014-01-22 03:47:35240 bool enable_port_selection() const { return enable_port_selection_; }
241
[email protected]a4205202014-06-02 16:03:08242 bool has_quic_server_info_factory() {
rtenneti13c9d38d2015-10-12 21:25:01243 return !quic_server_info_factory_.get();
[email protected]a4205202014-06-02 16:03:08244 }
245
[email protected]e8cf7555b2014-02-28 23:52:53246 void set_quic_server_info_factory(
rtenneti13c9d38d2015-10-12 21:25:01247 QuicServerInfoFactory* quic_server_info_factory);
[email protected]e8cf7555b2014-02-28 23:52:53248
rtenneti14abd312015-02-06 21:56:01249 bool enable_connection_racing() const { return enable_connection_racing_; }
250 void set_enable_connection_racing(bool enable_connection_racing) {
251 enable_connection_racing_ = enable_connection_racing;
252 }
253
rch185ebee2015-07-14 23:56:22254 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; }
255
rtenneti8332ba52015-09-17 19:33:41256 bool delay_tcp_race() const { return delay_tcp_race_; }
257
rtenneticd2aaa15b2015-10-10 20:29:33258 bool store_server_configs_in_properties() const {
259 return store_server_configs_in_properties_;
260 }
261
[email protected]e13201d82012-12-12 05:00:32262 private:
263 class Job;
[email protected]c49ff182013-09-28 08:33:26264 friend class test::QuicStreamFactoryPeer;
tbansala5268e22015-06-30 02:57:58265 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad);
[email protected]e13201d82012-12-12 05:00:32266
ckrasic4f9d88d2015-07-22 22:23:16267 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap;
268 typedef std::map<QuicChromiumClientSession*, QuicServerId> SessionIdMap;
[email protected]257f24f2014-04-01 09:15:37269 typedef std::set<QuicServerId> AliasSet;
ckrasic4f9d88d2015-07-22 22:23:16270 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap;
271 typedef std::set<QuicChromiumClientSession*> SessionSet;
rchf114d982015-10-21 01:34:56272 typedef std::map<IPEndPoint, SessionSet> IPAliasMap;
[email protected]257f24f2014-04-01 09:15:37273 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap;
rtenneti14abd312015-02-06 21:56:01274 typedef std::set<Job*> JobSet;
275 typedef std::map<QuicServerId, JobSet> JobMap;
276 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap;
[email protected]e13201d82012-12-12 05:00:32277 typedef std::set<QuicStreamRequest*> RequestSet;
rtenneti14abd312015-02-06 21:56:01278 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap;
ckrasic4f9d88d2015-07-22 22:23:16279 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason>
ckrasic1e53b642015-07-08 22:39:35280 DisabledReasonsQueue;
rtenneti14abd312015-02-06 21:56:01281
282 // Creates a job which doesn't wait for server config to be loaded from the
283 // disk cache. This job is started via a PostTask.
284 void CreateAuxilaryJob(const QuicServerId server_id,
rtennetia75df622015-06-21 23:59:50285 int cert_verify_flags,
bnc68d401dd2015-05-18 20:31:48286 bool server_and_origin_have_same_host,
rtenneti14abd312015-02-06 21:56:01287 bool is_post,
288 const BoundNetLog& net_log);
[email protected]e13201d82012-12-12 05:00:32289
bnccb7ff3c2015-05-21 20:51:55290 // Returns a newly created QuicHttpStream owned by the caller.
thestiga0e18cd2015-09-25 04:58:36291 scoped_ptr<QuicHttpStream> CreateFromSession(
292 QuicChromiumClientSession* session);
[email protected]df157d9d2014-03-10 07:27:27293
[email protected]257f24f2014-04-01 09:15:37294 bool OnResolution(const QuicServerId& server_id,
[email protected]eed749f92013-12-23 18:57:38295 const AddressList& address_list);
[email protected]e13201d82012-12-12 05:00:32296 void OnJobComplete(Job* job, int rv);
[email protected]257f24f2014-04-01 09:15:37297 bool HasActiveSession(const QuicServerId& server_id) const;
298 bool HasActiveJob(const QuicServerId& server_id) const;
299 int CreateSession(const QuicServerId& server_id,
rtennetia75df622015-06-21 23:59:50300 int cert_verify_flags,
[email protected]17bf15c2014-03-14 10:08:04301 scoped_ptr<QuicServerInfo> quic_server_info,
[email protected]338e7982013-12-13 11:15:32302 const AddressList& address_list,
rtennetif4f08852015-02-27 17:50:04303 base::TimeTicks dns_resolution_end_time,
[email protected]338e7982013-12-13 11:15:32304 const BoundNetLog& net_log,
ckrasic4f9d88d2015-07-22 22:23:16305 QuicChromiumClientSession** session);
[email protected]257f24f2014-04-01 09:15:37306 void ActivateSession(const QuicServerId& key,
ckrasic4f9d88d2015-07-22 22:23:16307 QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32308
rtenneti2912825c2015-01-06 01:19:46309 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there
310 // is no |http_server_properties_| or if |http_server_properties_| doesn't
311 // have ServerNetworkStats for the given |server_id|.
Avi Drissman13fc8932015-12-20 04:40:46312 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds(
rtenneti2912825c2015-01-06 01:19:46313 const QuicServerId& server_id) const;
314
bnccacc0992015-03-20 20:22:22315 // Helper methods.
316 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const;
rtenneti8332ba52015-09-17 19:33:41317
rtenneti14abd312015-02-06 21:56:01318 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id);
319
[email protected]257f24f2014-04-01 09:15:37320 // Initializes the cached state associated with |server_id| in
[email protected]59c0bbd2014-03-22 04:08:12321 // |crypto_config_| with the information in |server_info|.
[email protected]60cf50e2014-04-28 23:23:18322 void InitializeCachedStateInCryptoConfig(
323 const QuicServerId& server_id,
324 const scoped_ptr<QuicServerInfo>& server_info);
[email protected]b694e48c2014-03-18 17:10:13325
rtenneti8a80a6dc2015-09-21 19:51:13326 // Initialize |quic_supported_servers_at_startup_| with the list of servers
rtenneticd2aaa15b2015-10-10 20:29:33327 // that supported QUIC at start up and also initialize in-memory cache of
328 // QuicServerInfo objects from HttpServerProperties.
329 void MaybeInitialize();
rtenneti8a80a6dc2015-09-21 19:51:13330
ckrasic4f9d88d2015-07-22 22:23:16331 void ProcessGoingAwaySession(QuicChromiumClientSession* session,
[email protected]eb71ab62014-05-23 07:57:53332 const QuicServerId& server_id,
333 bool was_session_active);
[email protected]4d590c9c2014-05-02 05:14:33334
ckrasic1e53b642015-07-08 22:39:35335 // Collect stats from recent connections, possibly disabling Quic.
ckrasic4f9d88d2015-07-22 22:23:16336 void MaybeDisableQuic(QuicChromiumClientSession* session);
ckrasic1e53b642015-07-08 22:39:35337
[email protected]11c05872013-08-20 02:04:12338 bool require_confirmation_;
[email protected]e13201d82012-12-12 05:00:32339 HostResolver* host_resolver_;
340 ClientSocketFactory* client_socket_factory_;
[email protected]77c6c162013-08-17 02:57:45341 base::WeakPtr<HttpServerProperties> http_server_properties_;
[email protected]5db452202014-08-19 05:22:15342 TransportSecurityState* transport_security_state_;
rtenneti052774e2015-11-24 21:00:12343 CTVerifier* cert_transparency_verifier_;
rtenneti13c9d38d2015-10-12 21:25:01344 scoped_ptr<QuicServerInfoFactory> quic_server_info_factory_;
[email protected]e8ff26842013-03-22 21:02:05345 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_;
[email protected]9558c5d32012-12-22 00:08:14346 QuicRandom* random_generator_;
[email protected]f1e97e92012-12-16 04:53:25347 scoped_ptr<QuicClock> clock_;
[email protected]256fe9b2013-11-27 01:58:02348 const size_t max_packet_length_;
[email protected]e13201d82012-12-12 05:00:32349
tbansalfdf5665b2015-09-21 22:46:40350 // Factory which is used to create socket performance watcher. A new watcher
351 // is created for every QUIC connection.
352 // |socket_performance_watcher_factory_| may be null.
tbansalc8a94ea2015-11-02 23:58:51353 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
tbansalfdf5665b2015-09-21 22:46:40354
[email protected]2cfc6bb82013-10-27 03:40:44355 // The helper used for all connections.
356 scoped_ptr<QuicConnectionHelper> helper_;
357
[email protected]e13201d82012-12-12 05:00:32358 // Contains owning pointers to all sessions that currently exist.
[email protected]4d590c9c2014-05-02 05:14:33359 SessionIdMap all_sessions_;
[email protected]e13201d82012-12-12 05:00:32360 // Contains non-owning pointers to currently active session
361 // (not going away session, once they're implemented).
362 SessionMap active_sessions_;
[email protected]eed749f92013-12-23 18:57:38363 // Map from session to set of aliases that this session is known by.
[email protected]e13201d82012-12-12 05:00:32364 SessionAliasMap session_aliases_;
[email protected]eed749f92013-12-23 18:57:38365 // Map from IP address to sessions which are connected to this address.
366 IPAliasMap ip_aliases_;
[email protected]e13201d82012-12-12 05:00:32367
[email protected]d8e2abf82014-03-06 10:30:10368 // Origins which have gone away recently.
369 AliasSet gone_away_aliases_;
370
[email protected]fd276a282014-06-11 04:26:14371 const QuicConfig config_;
[email protected]59c0bbd2014-03-22 04:08:12372 QuicCryptoClientConfig crypto_config_;
[email protected]b064310782013-05-30 21:12:17373
[email protected]e13201d82012-12-12 05:00:32374 JobMap active_jobs_;
rtenneti14abd312015-02-06 21:56:01375 ServerIDRequestsMap job_requests_map_;
[email protected]e13201d82012-12-12 05:00:32376 RequestMap active_requests_;
377
[email protected]1e960032013-12-20 19:00:20378 QuicVersionVector supported_versions_;
[email protected]e13201d82012-12-12 05:00:32379
[email protected]376d38a2014-01-22 03:47:35380 // Determine if we should consistently select a client UDP port. If false,
381 // then we will just let the OS select a random client port for each new
382 // connection.
383 bool enable_port_selection_;
384
jri2b966f22014-09-02 22:25:36385 // Set if we always require handshake confirmation. If true, this will
386 // introduce at least one RTT for the handshake before the client sends data.
387 bool always_require_handshake_confirmation_;
388
jri584002d12014-09-09 00:51:28389 // Set if we do not want connection pooling.
390 bool disable_connection_pooling_;
391
rtenneti2912825c2015-01-06 01:19:46392 // Specifies the ratio between time to load QUIC server information from disk
393 // cache to 'smoothed RTT'. This ratio is used to calculate the timeout in
394 // milliseconds to wait for loading of QUIC server information. If we don't
395 // want to timeout, set |load_server_info_timeout_srtt_multiplier_| to 0.
396 float load_server_info_timeout_srtt_multiplier_;
397
rtenneti14abd312015-02-06 21:56:01398 // Set if we want to race connections - one connection that sends
399 // INCHOATE_HELLO and another connection that sends CHLO after loading server
400 // config from the disk cache.
401 bool enable_connection_racing_;
402
qyearsley3257b7de2015-02-28 06:59:03403 // Set if experimental non-blocking IO should be used on windows sockets.
404 bool enable_non_blocking_io_;
405
rtenneti34dffe752015-02-24 23:27:32406 // Set if we do not want to load server config from the disk cache.
407 bool disable_disk_cache_;
408
rch9976b0c2015-06-10 21:27:23409 // Set if AES-GCM should be preferred, even if there is no hardware support.
410 bool prefer_aes_;
411
rtenneti85dcfac22015-03-27 20:22:19412 // Set if we want to disable QUIC when there is high packet loss rate.
413 // Specifies the maximum number of connections with high packet loss in a row
414 // after which QUIC will be disabled.
415 int max_number_of_lossy_connections_;
rtenneti374e56882015-03-28 13:49:54416 // Specifies packet loss rate in fraction after which a connection is closed
rtenneti85dcfac22015-03-27 20:22:19417 // and is considered as a lossy connection.
418 float packet_loss_threshold_;
419 // Count number of lossy connections by port.
Avi Drissman13fc8932015-12-20 04:40:46420 std::map<uint16_t, int> number_of_lossy_connections_;
rtenneti85dcfac22015-03-27 20:22:19421
ckrasic1e53b642015-07-08 22:39:35422 // Keep track of stats for recently closed connections, using a
423 // bounded queue.
424 int max_disabled_reasons_;
425 DisabledReasonsQueue disabled_reasons_;
426 // Events that can trigger disabling QUIC
427 int num_public_resets_post_handshake_;
428 int num_timeouts_with_open_streams_;
429 // Keep track the largest values for UMA histograms, that will help
430 // determine good threshold values.
431 int max_public_resets_post_handshake_;
432 int max_timeouts_with_open_streams_;
433 // Thresholds if greater than zero, determine when to
434 int threshold_timeouts_with_open_streams_;
435 int threshold_public_resets_post_handshake_;
436
rchc7433572015-02-27 18:16:51437 // Size of the UDP receive buffer.
438 int socket_receive_buffer_size_;
439
rtenneti8332ba52015-09-17 19:33:41440 // Set if we do want to delay TCP connection when it is racing with QUIC.
441 bool delay_tcp_race_;
442
rtenneti1cd3b162015-09-29 02:58:28443 // If more than |yield_after_packets_| packets have been read or more than
444 // |yield_after_duration_| time has passed, then
445 // QuicPacketReader::StartReading() yields by doing a PostTask().
446 int yield_after_packets_;
447 QuicTime::Delta yield_after_duration_;
448
rtenneticd2aaa15b2015-10-10 20:29:33449 // Set if server configs are to be stored in HttpServerProperties.
450 bool store_server_configs_in_properties_;
451
jri8c44d692015-10-23 23:53:41452 // Set if all sessions should be closed when any local IP address changes.
453 const bool close_sessions_on_ip_change_;
454
rchc7433572015-02-27 18:16:51455 // Each profile will (probably) have a unique port_seed_ value. This value
456 // is used to help seed a pseudo-random number generator (PortSuggester) so
457 // that we consistently (within this profile) suggest the same ephemeral
458 // port when we re-connect to any given server/port. The differences between
459 // profiles (probablistically) prevent two profiles from colliding in their
460 // ephemeral port requests.
Avi Drissman13fc8932015-12-20 04:40:46461 uint64_t port_seed_;
[email protected]7034cf12013-12-13 22:47:07462
rtennetifc47e0e2014-09-26 02:54:05463 // Local address of socket that was created in CreateSession.
464 IPEndPoint local_address_;
465 bool check_persisted_supports_quic_;
rtenneticd2aaa15b2015-10-10 20:29:33466 bool has_initialized_data_;
rtenneti1681f852014-11-13 20:34:03467 std::set<HostPortPair> quic_supported_servers_at_startup_;
rtennetifc47e0e2014-09-26 02:54:05468
rtenneti041b2992015-02-23 23:03:28469 NetworkConnection network_connection_;
470
rtenneti38f5cd52014-10-28 20:28:28471 base::TaskRunner* task_runner_;
472
[email protected]1e960032013-12-20 19:00:20473 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
474
[email protected]e13201d82012-12-12 05:00:32475 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
476};
477
478} // namespace net
479
480#endif // NET_QUIC_QUIC_STREAM_FACTORY_H_