blob: 42d688abba9c2b9db256ec327656e6e7a94ba77d [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;
[email protected]6d1b4ed2013-07-10 03:57:5438class HostResolver;
[email protected]77c6c162013-08-17 02:57:4539class HttpServerProperties;
[email protected]e13201d82012-12-12 05:00:3240class QuicClock;
ckrasic4f9d88d2015-07-22 22:23:1641class QuicChromiumClientSession;
[email protected]2cfc6bb82013-10-27 03:40:4442class QuicConnectionHelper;
[email protected]e8ff26842013-03-22 21:02:0543class QuicCryptoClientStreamFactory;
[email protected]9558c5d32012-12-22 00:08:1444class QuicRandom;
[email protected]257f24f2014-04-01 09:15:3745class QuicServerId;
rtenneti13c9d38d2015-10-12 21:25:0146class QuicServerInfo;
47class QuicServerInfoFactory;
[email protected]e13201d82012-12-12 05:00:3248class QuicStreamFactory;
tbansalfdf5665b2015-09-21 22:46:4049class SocketPerformanceWatcherFactory;
[email protected]080b77932014-08-04 01:22:4650class TransportSecurityState;
[email protected]e13201d82012-12-12 05:00:3251
[email protected]c49ff182013-09-28 08:33:2652namespace test {
53class QuicStreamFactoryPeer;
54} // namespace test
55
[email protected]e13201d82012-12-12 05:00:3256// Encapsulates a pending request for a QuicHttpStream.
57// If the request is still pending when it is destroyed, it will
58// cancel the request with the factory.
59class NET_EXPORT_PRIVATE QuicStreamRequest {
60 public:
61 explicit QuicStreamRequest(QuicStreamFactory* factory);
62 ~QuicStreamRequest();
63
rtennetia75df622015-06-21 23:59:5064 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is
65 // passed to CertVerifier::Verify.
[email protected]bf4ea2f2014-03-10 22:57:5366 int Request(const HostPortPair& host_port_pair,
[email protected]9dd3ff0f2014-03-26 09:51:2867 PrivacyMode privacy_mode,
rtennetia75df622015-06-21 23:59:5068 int cert_verify_flags,
bnc68d401dd2015-05-18 20:31:4869 base::StringPiece origin_host,
[email protected]974849d2014-02-06 01:32:5970 base::StringPiece method,
[email protected]e13201d82012-12-12 05:00:3271 const BoundNetLog& net_log,
72 const CompletionCallback& callback);
73
74 void OnRequestComplete(int rv);
75
rtenneti8332ba52015-09-17 19:33:4176 // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It
77 // returns the amount of time waiting job should be delayed.
78 base::TimeDelta GetTimeDelayForWaitingJob() const;
79
[email protected]e13201d82012-12-12 05:00:3280 scoped_ptr<QuicHttpStream> ReleaseStream();
81
82 void set_stream(scoped_ptr<QuicHttpStream> stream);
83
shiva.jmd4e2adf2015-09-02 06:35:0284 const std::string& origin_host() const { return origin_host_; }
bnccb7ff3c2015-05-21 20:51:5585
86 PrivacyMode privacy_mode() const { return privacy_mode_; }
87
thestiga0e18cd2015-09-25 04:58:3688 const BoundNetLog& net_log() const { return net_log_; }
[email protected]e13201d82012-12-12 05:00:3289
90 private:
91 QuicStreamFactory* factory_;
[email protected]bf4ea2f2014-03-10 22:57:5392 HostPortPair host_port_pair_;
bnccb7ff3c2015-05-21 20:51:5593 std::string origin_host_;
94 PrivacyMode privacy_mode_;
[email protected]e13201d82012-12-12 05:00:3295 BoundNetLog net_log_;
96 CompletionCallback callback_;
97 scoped_ptr<QuicHttpStream> stream_;
98
99 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest);
100};
101
102// A factory for creating new QuicHttpStreams on top of a pool of
ckrasic4f9d88d2015-07-22 22:23:16103// QuicChromiumClientSessions.
[email protected]f698a012013-05-06 20:18:59104class NET_EXPORT_PRIVATE QuicStreamFactory
[email protected]d7d1e50b2013-11-25 22:08:09105 : public NetworkChangeNotifier::IPAddressObserver,
rch02d87792015-09-09 09:05:53106 public SSLConfigService::Observer,
[email protected]d7d1e50b2013-11-25 22:08:09107 public CertDatabase::Observer {
[email protected]e13201d82012-12-12 05:00:32108 public:
[email protected]e8ff26842013-03-22 21:02:05109 QuicStreamFactory(
110 HostResolver* host_resolver,
111 ClientSocketFactory* client_socket_factory,
[email protected]77c6c162013-08-17 02:57:45112 base::WeakPtr<HttpServerProperties> http_server_properties,
[email protected]59c0bbd2014-03-22 04:08:12113 CertVerifier* cert_verifier,
rsleevi9541f8632015-07-31 00:07:00114 CertPolicyEnforcer* cert_policy_enforcer,
[email protected]6b8a3c742014-07-25 00:25:35115 ChannelIDService* channel_id_service,
[email protected]080b77932014-08-04 01:22:46116 TransportSecurityState* transport_security_state,
tbansalfdf5665b2015-09-21 22:46:40117 const SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
[email protected]e8ff26842013-03-22 21:02:05118 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory,
119 QuicRandom* random_generator,
[email protected]256fe9b2013-11-27 01:58:02120 QuicClock* clock,
[email protected]1e960032013-12-20 19:00:20121 size_t max_packet_length,
[email protected]0c4017ca2014-06-06 03:30:45122 const std::string& user_agent_id,
[email protected]376d38a2014-01-22 03:47:35123 const QuicVersionVector& supported_versions,
[email protected]c80f7c92014-02-27 13:12:02124 bool enable_port_selection,
jri2b966f22014-09-02 22:25:36125 bool always_require_handshake_confirmation,
jri584002d12014-09-09 00:51:28126 bool disable_connection_pooling,
rtenneti2912825c2015-01-06 01:19:46127 float load_server_info_timeout_srtt_multiplier,
rtenneti4f809972015-02-11 19:38:34128 bool enable_connection_racing,
qyearsley3257b7de2015-02-28 06:59:03129 bool enable_non_blocking_io,
rtenneti34dffe752015-02-24 23:27:32130 bool disable_disk_cache,
rch9976b0c2015-06-10 21:27:23131 bool prefer_aes,
rtenneti85dcfac22015-03-27 20:22:19132 int max_number_of_lossy_connections,
133 float packet_loss_threshold,
ckrasic1e53b642015-07-08 22:39:35134 int max_recent_disabled_reasons,
135 int threshold_timeouts_with_streams_open,
136 int threshold_public_resets_post_handshake,
rchc7433572015-02-27 18:16:51137 int socket_receive_buffer_size,
rtenneti8332ba52015-09-17 19:33:41138 bool delay_tcp_race,
rtenneticd2aaa15b2015-10-10 20:29:33139 bool store_server_configs_in_properties,
[email protected]4b4efab32014-07-01 02:36:16140 const QuicTagVector& connection_options);
dchengb03027d2014-10-21 12:00:20141 ~QuicStreamFactory() override;
[email protected]e13201d82012-12-12 05:00:32142
[email protected]bf4ea2f2014-03-10 22:57:53143 // Creates a new QuicHttpStream to |host_port_pair| which will be
rchf114d982015-10-21 01:34:56144 // owned by |request|.
[email protected]0cceb922014-07-01 02:00:56145 // If a matching session already exists, this method will return OK. If no
146 // matching session exists, this will return ERR_IO_PENDING and will invoke
147 // OnRequestComplete asynchronously.
[email protected]bf4ea2f2014-03-10 22:57:53148 int Create(const HostPortPair& host_port_pair,
[email protected]9dd3ff0f2014-03-26 09:51:28149 PrivacyMode privacy_mode,
rtennetia75df622015-06-21 23:59:50150 int cert_verify_flags,
bnccb7ff3c2015-05-21 20:51:55151 base::StringPiece origin_host,
[email protected]974849d2014-02-06 01:32:59152 base::StringPiece method,
[email protected]e13201d82012-12-12 05:00:32153 const BoundNetLog& net_log,
154 QuicStreamRequest* request);
155
rtenneti97137a92015-06-18 06:00:31156 // If |packet_loss_rate| is greater than or equal to |packet_loss_threshold_|
157 // it marks QUIC as recently broken for the port of the session. Increments
158 // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_|
159 // is greater than or equal to |max_number_of_lossy_connections_| then it
160 // disables QUIC. If QUIC is disabled then it closes the connection.
161 //
162 // Returns true if QUIC is disabled for the port of the session.
ckrasic4f9d88d2015-07-22 22:23:16163 bool OnHandshakeConfirmed(QuicChromiumClientSession* session,
164 float packet_loss_rate);
rtenneti85dcfac22015-03-27 20:22:19165
166 // Returns true if QUIC is disabled for this port.
167 bool IsQuicDisabled(uint16 port);
168
ckrasic1e53b642015-07-08 22:39:35169 // Returns reason QUIC is disabled for this port, or QUIC_DISABLED_NOT if not.
ckrasic4f9d88d2015-07-22 22:23:16170 QuicChromiumClientSession::QuicDisabledReason QuicDisabledReason(
171 uint16 port) const;
ckrasic1e53b642015-07-08 22:39:35172
173 // Returns reason QUIC is disabled as string for net-internals, or
174 // returns empty string if QUIC is not disabled.
175 const char* QuicDisabledReasonString() const;
176
[email protected]e13201d82012-12-12 05:00:32177 // Called by a session when it becomes idle.
ckrasic4f9d88d2015-07-22 22:23:16178 void OnIdleSession(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32179
[email protected]4d283b32013-10-17 12:57:27180 // Called by a session when it is going away and no more streams should be
181 // created on it.
ckrasic4f9d88d2015-07-22 22:23:16182 void OnSessionGoingAway(QuicChromiumClientSession* session);
[email protected]4d283b32013-10-17 12:57:27183
[email protected]e13201d82012-12-12 05:00:32184 // Called by a session after it shuts down.
ckrasic4f9d88d2015-07-22 22:23:16185 void OnSessionClosed(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32186
[email protected]65768442014-06-06 23:37:03187 // Called by a session whose connection has timed out.
ckrasic4f9d88d2015-07-22 22:23:16188 void OnSessionConnectTimeout(QuicChromiumClientSession* session);
[email protected]65768442014-06-06 23:37:03189
[email protected]e13201d82012-12-12 05:00:32190 // Cancels a pending request.
191 void CancelRequest(QuicStreamRequest* request);
192
[email protected]56dfb902013-01-03 23:17:55193 // Closes all current sessions.
194 void CloseAllSessions(int error);
195
payal.pandeya18956a2015-05-27 05:57:55196 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const;
[email protected]c5b061b2013-01-05 00:31:34197
[email protected]f7e21a432014-04-21 22:17:57198 // Delete all cached state objects in |crypto_config_|.
[email protected]60cf50e2014-04-28 23:23:18199 void ClearCachedStatesInCryptoConfig();
[email protected]f7e21a432014-04-21 22:17:57200
[email protected]f698a012013-05-06 20:18:59201 // NetworkChangeNotifier::IPAddressObserver methods:
202
203 // Until the servers support roaming, close all connections when the local
204 // IP address changes.
dchengb03027d2014-10-21 12:00:20205 void OnIPAddressChanged() override;
[email protected]f698a012013-05-06 20:18:59206
rch02d87792015-09-09 09:05:53207 // SSLConfigService::Observer methods:
208
209 // We perform the same flushing as described above when SSL settings change.
210 void OnSSLConfigChanged() override;
211
[email protected]d7d1e50b2013-11-25 22:08:09212 // CertDatabase::Observer methods:
213
214 // We close all sessions when certificate database is changed.
dchengb03027d2014-10-21 12:00:20215 void OnCertAdded(const X509Certificate* cert) override;
216 void OnCACertChanged(const X509Certificate* cert) override;
[email protected]d7d1e50b2013-11-25 22:08:09217
jri2b966f22014-09-02 22:25:36218 bool require_confirmation() const {
219 return require_confirmation_;
220 }
[email protected]11c05872013-08-20 02:04:12221
rtennetifc47e0e2014-09-26 02:54:05222 void set_require_confirmation(bool require_confirmation);
[email protected]11c05872013-08-20 02:04:12223
rtenneti8332ba52015-09-17 19:33:41224 // It returns the amount of time waiting job should be delayed.
225 base::TimeDelta GetTimeDelayForWaitingJob(const QuicServerId& server_id);
226
[email protected]2cfc6bb82013-10-27 03:40:44227 QuicConnectionHelper* helper() { return helper_.get(); }
228
[email protected]376d38a2014-01-22 03:47:35229 bool enable_port_selection() const { return enable_port_selection_; }
230
[email protected]a4205202014-06-02 16:03:08231 bool has_quic_server_info_factory() {
rtenneti13c9d38d2015-10-12 21:25:01232 return !quic_server_info_factory_.get();
[email protected]a4205202014-06-02 16:03:08233 }
234
[email protected]e8cf7555b2014-02-28 23:52:53235 void set_quic_server_info_factory(
rtenneti13c9d38d2015-10-12 21:25:01236 QuicServerInfoFactory* quic_server_info_factory);
[email protected]e8cf7555b2014-02-28 23:52:53237
rtenneti14abd312015-02-06 21:56:01238 bool enable_connection_racing() const { return enable_connection_racing_; }
239 void set_enable_connection_racing(bool enable_connection_racing) {
240 enable_connection_racing_ = enable_connection_racing;
241 }
242
rch185ebee2015-07-14 23:56:22243 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; }
244
rtenneti8332ba52015-09-17 19:33:41245 bool delay_tcp_race() const { return delay_tcp_race_; }
246
rtenneticd2aaa15b2015-10-10 20:29:33247 bool store_server_configs_in_properties() const {
248 return store_server_configs_in_properties_;
249 }
250
[email protected]e13201d82012-12-12 05:00:32251 private:
252 class Job;
[email protected]c49ff182013-09-28 08:33:26253 friend class test::QuicStreamFactoryPeer;
tbansala5268e22015-06-30 02:57:58254 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad);
[email protected]e13201d82012-12-12 05:00:32255
ckrasic4f9d88d2015-07-22 22:23:16256 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap;
257 typedef std::map<QuicChromiumClientSession*, QuicServerId> SessionIdMap;
[email protected]257f24f2014-04-01 09:15:37258 typedef std::set<QuicServerId> AliasSet;
ckrasic4f9d88d2015-07-22 22:23:16259 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap;
260 typedef std::set<QuicChromiumClientSession*> SessionSet;
rchf114d982015-10-21 01:34:56261 typedef std::map<IPEndPoint, SessionSet> IPAliasMap;
[email protected]257f24f2014-04-01 09:15:37262 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap;
rtenneti14abd312015-02-06 21:56:01263 typedef std::set<Job*> JobSet;
264 typedef std::map<QuicServerId, JobSet> JobMap;
265 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap;
[email protected]e13201d82012-12-12 05:00:32266 typedef std::set<QuicStreamRequest*> RequestSet;
rtenneti14abd312015-02-06 21:56:01267 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap;
ckrasic4f9d88d2015-07-22 22:23:16268 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason>
ckrasic1e53b642015-07-08 22:39:35269 DisabledReasonsQueue;
rtenneti14abd312015-02-06 21:56:01270
271 // Creates a job which doesn't wait for server config to be loaded from the
272 // disk cache. This job is started via a PostTask.
273 void CreateAuxilaryJob(const QuicServerId server_id,
rtennetia75df622015-06-21 23:59:50274 int cert_verify_flags,
bnc68d401dd2015-05-18 20:31:48275 bool server_and_origin_have_same_host,
rtenneti14abd312015-02-06 21:56:01276 bool is_post,
277 const BoundNetLog& net_log);
[email protected]e13201d82012-12-12 05:00:32278
bnccb7ff3c2015-05-21 20:51:55279 // Returns a newly created QuicHttpStream owned by the caller.
thestiga0e18cd2015-09-25 04:58:36280 scoped_ptr<QuicHttpStream> CreateFromSession(
281 QuicChromiumClientSession* session);
[email protected]df157d9d2014-03-10 07:27:27282
[email protected]257f24f2014-04-01 09:15:37283 bool OnResolution(const QuicServerId& server_id,
[email protected]eed749f92013-12-23 18:57:38284 const AddressList& address_list);
[email protected]e13201d82012-12-12 05:00:32285 void OnJobComplete(Job* job, int rv);
[email protected]257f24f2014-04-01 09:15:37286 bool HasActiveSession(const QuicServerId& server_id) const;
287 bool HasActiveJob(const QuicServerId& server_id) const;
288 int CreateSession(const QuicServerId& server_id,
rtennetia75df622015-06-21 23:59:50289 int cert_verify_flags,
[email protected]17bf15c2014-03-14 10:08:04290 scoped_ptr<QuicServerInfo> quic_server_info,
[email protected]338e7982013-12-13 11:15:32291 const AddressList& address_list,
rtennetif4f08852015-02-27 17:50:04292 base::TimeTicks dns_resolution_end_time,
[email protected]338e7982013-12-13 11:15:32293 const BoundNetLog& net_log,
ckrasic4f9d88d2015-07-22 22:23:16294 QuicChromiumClientSession** session);
[email protected]257f24f2014-04-01 09:15:37295 void ActivateSession(const QuicServerId& key,
ckrasic4f9d88d2015-07-22 22:23:16296 QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32297
rtenneti2912825c2015-01-06 01:19:46298 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there
299 // is no |http_server_properties_| or if |http_server_properties_| doesn't
300 // have ServerNetworkStats for the given |server_id|.
301 int64 GetServerNetworkStatsSmoothedRttInMicroseconds(
302 const QuicServerId& server_id) const;
303
bnccacc0992015-03-20 20:22:22304 // Helper methods.
305 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const;
rtenneti8332ba52015-09-17 19:33:41306
rtenneti14abd312015-02-06 21:56:01307 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id);
308
[email protected]257f24f2014-04-01 09:15:37309 // Initializes the cached state associated with |server_id| in
[email protected]59c0bbd2014-03-22 04:08:12310 // |crypto_config_| with the information in |server_info|.
[email protected]60cf50e2014-04-28 23:23:18311 void InitializeCachedStateInCryptoConfig(
312 const QuicServerId& server_id,
313 const scoped_ptr<QuicServerInfo>& server_info);
[email protected]b694e48c2014-03-18 17:10:13314
rtenneti8a80a6dc2015-09-21 19:51:13315 // Initialize |quic_supported_servers_at_startup_| with the list of servers
rtenneticd2aaa15b2015-10-10 20:29:33316 // that supported QUIC at start up and also initialize in-memory cache of
317 // QuicServerInfo objects from HttpServerProperties.
318 void MaybeInitialize();
rtenneti8a80a6dc2015-09-21 19:51:13319
ckrasic4f9d88d2015-07-22 22:23:16320 void ProcessGoingAwaySession(QuicChromiumClientSession* session,
[email protected]eb71ab62014-05-23 07:57:53321 const QuicServerId& server_id,
322 bool was_session_active);
[email protected]4d590c9c2014-05-02 05:14:33323
ckrasic1e53b642015-07-08 22:39:35324 // Collect stats from recent connections, possibly disabling Quic.
ckrasic4f9d88d2015-07-22 22:23:16325 void MaybeDisableQuic(QuicChromiumClientSession* session);
ckrasic1e53b642015-07-08 22:39:35326
[email protected]11c05872013-08-20 02:04:12327 bool require_confirmation_;
[email protected]e13201d82012-12-12 05:00:32328 HostResolver* host_resolver_;
329 ClientSocketFactory* client_socket_factory_;
[email protected]77c6c162013-08-17 02:57:45330 base::WeakPtr<HttpServerProperties> http_server_properties_;
[email protected]5db452202014-08-19 05:22:15331 TransportSecurityState* transport_security_state_;
rtenneti13c9d38d2015-10-12 21:25:01332 scoped_ptr<QuicServerInfoFactory> quic_server_info_factory_;
[email protected]e8ff26842013-03-22 21:02:05333 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_;
[email protected]9558c5d32012-12-22 00:08:14334 QuicRandom* random_generator_;
[email protected]f1e97e92012-12-16 04:53:25335 scoped_ptr<QuicClock> clock_;
[email protected]256fe9b2013-11-27 01:58:02336 const size_t max_packet_length_;
[email protected]e13201d82012-12-12 05:00:32337
tbansalfdf5665b2015-09-21 22:46:40338 // Factory which is used to create socket performance watcher. A new watcher
339 // is created for every QUIC connection.
340 // |socket_performance_watcher_factory_| may be null.
341 const SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
342
[email protected]2cfc6bb82013-10-27 03:40:44343 // The helper used for all connections.
344 scoped_ptr<QuicConnectionHelper> helper_;
345
[email protected]e13201d82012-12-12 05:00:32346 // Contains owning pointers to all sessions that currently exist.
[email protected]4d590c9c2014-05-02 05:14:33347 SessionIdMap all_sessions_;
[email protected]e13201d82012-12-12 05:00:32348 // Contains non-owning pointers to currently active session
349 // (not going away session, once they're implemented).
350 SessionMap active_sessions_;
[email protected]eed749f92013-12-23 18:57:38351 // Map from session to set of aliases that this session is known by.
[email protected]e13201d82012-12-12 05:00:32352 SessionAliasMap session_aliases_;
[email protected]eed749f92013-12-23 18:57:38353 // Map from IP address to sessions which are connected to this address.
354 IPAliasMap ip_aliases_;
[email protected]e13201d82012-12-12 05:00:32355
[email protected]d8e2abf82014-03-06 10:30:10356 // Origins which have gone away recently.
357 AliasSet gone_away_aliases_;
358
[email protected]fd276a282014-06-11 04:26:14359 const QuicConfig config_;
[email protected]59c0bbd2014-03-22 04:08:12360 QuicCryptoClientConfig crypto_config_;
[email protected]b064310782013-05-30 21:12:17361
[email protected]e13201d82012-12-12 05:00:32362 JobMap active_jobs_;
rtenneti14abd312015-02-06 21:56:01363 ServerIDRequestsMap job_requests_map_;
[email protected]e13201d82012-12-12 05:00:32364 RequestMap active_requests_;
365
[email protected]1e960032013-12-20 19:00:20366 QuicVersionVector supported_versions_;
[email protected]e13201d82012-12-12 05:00:32367
[email protected]376d38a2014-01-22 03:47:35368 // Determine if we should consistently select a client UDP port. If false,
369 // then we will just let the OS select a random client port for each new
370 // connection.
371 bool enable_port_selection_;
372
jri2b966f22014-09-02 22:25:36373 // Set if we always require handshake confirmation. If true, this will
374 // introduce at least one RTT for the handshake before the client sends data.
375 bool always_require_handshake_confirmation_;
376
jri584002d12014-09-09 00:51:28377 // Set if we do not want connection pooling.
378 bool disable_connection_pooling_;
379
rtenneti2912825c2015-01-06 01:19:46380 // Specifies the ratio between time to load QUIC server information from disk
381 // cache to 'smoothed RTT'. This ratio is used to calculate the timeout in
382 // milliseconds to wait for loading of QUIC server information. If we don't
383 // want to timeout, set |load_server_info_timeout_srtt_multiplier_| to 0.
384 float load_server_info_timeout_srtt_multiplier_;
385
rtenneti14abd312015-02-06 21:56:01386 // Set if we want to race connections - one connection that sends
387 // INCHOATE_HELLO and another connection that sends CHLO after loading server
388 // config from the disk cache.
389 bool enable_connection_racing_;
390
qyearsley3257b7de2015-02-28 06:59:03391 // Set if experimental non-blocking IO should be used on windows sockets.
392 bool enable_non_blocking_io_;
393
rtenneti34dffe752015-02-24 23:27:32394 // Set if we do not want to load server config from the disk cache.
395 bool disable_disk_cache_;
396
rch9976b0c2015-06-10 21:27:23397 // Set if AES-GCM should be preferred, even if there is no hardware support.
398 bool prefer_aes_;
399
rtenneti85dcfac22015-03-27 20:22:19400 // Set if we want to disable QUIC when there is high packet loss rate.
401 // Specifies the maximum number of connections with high packet loss in a row
402 // after which QUIC will be disabled.
403 int max_number_of_lossy_connections_;
rtenneti374e56882015-03-28 13:49:54404 // Specifies packet loss rate in fraction after which a connection is closed
rtenneti85dcfac22015-03-27 20:22:19405 // and is considered as a lossy connection.
406 float packet_loss_threshold_;
407 // Count number of lossy connections by port.
408 std::map<uint16, int> number_of_lossy_connections_;
409
ckrasic1e53b642015-07-08 22:39:35410 // Keep track of stats for recently closed connections, using a
411 // bounded queue.
412 int max_disabled_reasons_;
413 DisabledReasonsQueue disabled_reasons_;
414 // Events that can trigger disabling QUIC
415 int num_public_resets_post_handshake_;
416 int num_timeouts_with_open_streams_;
417 // Keep track the largest values for UMA histograms, that will help
418 // determine good threshold values.
419 int max_public_resets_post_handshake_;
420 int max_timeouts_with_open_streams_;
421 // Thresholds if greater than zero, determine when to
422 int threshold_timeouts_with_open_streams_;
423 int threshold_public_resets_post_handshake_;
424
rchc7433572015-02-27 18:16:51425 // Size of the UDP receive buffer.
426 int socket_receive_buffer_size_;
427
rtenneti8332ba52015-09-17 19:33:41428 // Set if we do want to delay TCP connection when it is racing with QUIC.
429 bool delay_tcp_race_;
430
rtenneti1cd3b162015-09-29 02:58:28431 // If more than |yield_after_packets_| packets have been read or more than
432 // |yield_after_duration_| time has passed, then
433 // QuicPacketReader::StartReading() yields by doing a PostTask().
434 int yield_after_packets_;
435 QuicTime::Delta yield_after_duration_;
436
rtenneticd2aaa15b2015-10-10 20:29:33437 // Set if server configs are to be stored in HttpServerProperties.
438 bool store_server_configs_in_properties_;
439
rchc7433572015-02-27 18:16:51440 // Each profile will (probably) have a unique port_seed_ value. This value
441 // is used to help seed a pseudo-random number generator (PortSuggester) so
442 // that we consistently (within this profile) suggest the same ephemeral
443 // port when we re-connect to any given server/port. The differences between
444 // profiles (probablistically) prevent two profiles from colliding in their
445 // ephemeral port requests.
[email protected]337e1452013-12-16 23:57:50446 uint64 port_seed_;
[email protected]7034cf12013-12-13 22:47:07447
rtennetifc47e0e2014-09-26 02:54:05448 // Local address of socket that was created in CreateSession.
449 IPEndPoint local_address_;
450 bool check_persisted_supports_quic_;
rtenneticd2aaa15b2015-10-10 20:29:33451 bool has_initialized_data_;
rtenneti1681f852014-11-13 20:34:03452 std::set<HostPortPair> quic_supported_servers_at_startup_;
rtennetifc47e0e2014-09-26 02:54:05453
rtenneti041b2992015-02-23 23:03:28454 NetworkConnection network_connection_;
455
rtenneti38f5cd52014-10-28 20:28:28456 base::TaskRunner* task_runner_;
457
[email protected]1e960032013-12-20 19:00:20458 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
459
[email protected]e13201d82012-12-12 05:00:32460 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
461};
462
463} // namespace net
464
465#endif // NET_QUIC_QUIC_STREAM_FACTORY_H_