blob: 134812109bd96fb75edd08fd809ad337af526b7b [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
Ryan Hamiltona3ee93a72018-08-01 22:03:085#ifndef NET_QUIC_QUIC_STREAM_FACTORY_H_
6#define NET_QUIC_QUIC_STREAM_FACTORY_H_
[email protected]e13201d82012-12-12 05:00:327
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>
Matt Menkefca05b62019-09-20 23:15:5613#include <memory>
bnc614a92d32016-04-04 13:56:0714#include <set>
[email protected]41d6b172013-01-29 16:10:5715#include <string>
[email protected]6e12d702013-11-13 00:17:1716#include <vector>
[email protected]e13201d82012-12-12 05:00:3217
Matt Menkefca05b62019-09-20 23:15:5618#include "base/containers/mru_cache.h"
thestiga0e18cd2015-09-25 04:58:3619#include "base/gtest_prod_util.h"
[email protected]e8cf7555b2014-02-28 23:52:5320#include "base/logging.h"
Avi Drissman13fc8932015-12-20 04:40:4621#include "base/macros.h"
[email protected]e13201d82012-12-12 05:00:3222#include "base/memory/weak_ptr.h"
Zhongyi Shic16b4102019-02-12 00:37:4023#include "base/time/tick_clock.h"
rtenneti8332ba52015-09-17 19:33:4124#include "base/time/time.h"
[email protected]e13201d82012-12-12 05:00:3225#include "net/base/address_list.h"
Bence Békyd8a21fc32018-06-27 18:29:5826#include "net/base/completion_once_callback.h"
[email protected]e13201d82012-12-12 05:00:3227#include "net/base/host_port_pair.h"
bnc81c46c1f2016-10-04 16:25:5928#include "net/base/net_export.h"
[email protected]f698a012013-05-06 20:18:5929#include "net/base/network_change_notifier.h"
Lily Houghton582d4622018-01-22 22:43:4030#include "net/base/proxy_server.h"
[email protected]d7d1e50b2013-11-25 22:08:0931#include "net/cert/cert_database.h"
zhongyi32569c62016-01-08 02:54:3032#include "net/http/http_server_properties.h"
xunjieli2608f9b2016-03-14 13:39:2333#include "net/http/http_stream_factory.h"
mikecironef22f9812016-10-04 03:40:1934#include "net/log/net_log_with_source.h"
Ryan Hamiltona3ee93a72018-08-01 22:03:0835#include "net/quic/network_connection.h"
36#include "net/quic/quic_chromium_client_session.h"
37#include "net/quic/quic_clock_skew_detector.h"
Matt Menkefca05b62019-09-20 23:15:5638#include "net/quic/quic_crypto_client_config_handle.h"
Ryan Hamiltona3ee93a72018-08-01 22:03:0839#include "net/quic/quic_session_key.h"
Yixin Wang7f3cdc3f2017-11-10 01:44:1440#include "net/socket/client_socket_pool.h"
rch02d87792015-09-09 09:05:5341#include "net/ssl/ssl_config_service.h"
Victor Vasiliev6bb59d22019-03-08 21:34:5142#include "net/third_party/quiche/src/quic/core/http/quic_client_push_promise_index.h"
43#include "net/third_party/quiche/src/quic/core/quic_config.h"
44#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h"
45#include "net/third_party/quiche/src/quic/core/quic_packets.h"
46#include "net/third_party/quiche/src/quic/core/quic_server_id.h"
47#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
[email protected]e13201d82012-12-12 05:00:3248
mikecironef22f9812016-10-04 03:40:1949namespace base {
50class Value;
xunjieli69720dd2017-01-30 15:36:2951namespace trace_event {
52class ProcessMemoryDump;
53}
Ryan Hamiltona3ee93a72018-08-01 22:03:0854} // namespace base
mikecironef22f9812016-10-04 03:40:1955
Ryan Hamilton9835e662018-08-02 05:36:2756namespace quic {
57class QuicAlarmFactory;
58class QuicClock;
59class QuicRandom;
60} // namespace quic
61
[email protected]e13201d82012-12-12 05:00:3262namespace net {
63
estark6f9b3d82016-01-12 21:37:0564class CTPolicyEnforcer;
[email protected]6d1b4ed2013-07-10 03:57:5465class CertVerifier;
[email protected]e13201d82012-12-12 05:00:3266class ClientSocketFactory;
rtenneti052774e2015-11-24 21:00:1267class CTVerifier;
[email protected]6d1b4ed2013-07-10 03:57:5468class HostResolver;
[email protected]77c6c162013-08-17 02:57:4569class HttpServerProperties;
mikecironef22f9812016-10-04 03:40:1970class NetLog;
Matt Menke26e41542019-06-05 01:09:5171class NetworkIsolationKey;
rch12fef552016-01-15 16:26:3172class QuicChromiumConnectionHelper;
[email protected]e8ff26842013-03-22 21:02:0573class QuicCryptoClientStreamFactory;
rtenneti13c9d38d2015-10-12 21:25:0174class QuicServerInfo;
[email protected]e13201d82012-12-12 05:00:3275class QuicStreamFactory;
Victor Vasiliev7752898d2019-11-14 21:30:2276class QuicContext;
tbansalfdf5665b2015-09-21 22:46:4077class SocketPerformanceWatcherFactory;
Paul Jensen8e3c5d32018-02-19 17:06:3378class SocketTag;
[email protected]080b77932014-08-04 01:22:4679class TransportSecurityState;
[email protected]e13201d82012-12-12 05:00:3280
[email protected]c49ff182013-09-28 08:33:2681namespace test {
82class QuicStreamFactoryPeer;
83} // namespace test
84
rtenneti41c09992015-11-30 18:24:0185// When a connection is idle for 30 seconds it will be closed.
Ryan Sleevi2e8255b2019-07-17 21:02:2186constexpr base::TimeDelta kIdleConnectionTimeout =
87 base::TimeDelta::FromSeconds(30);
rtenneti41c09992015-11-30 18:24:0188
Zhongyi Shic16b4102019-02-12 00:37:4089// Sessions can migrate if they have been idle for less than this period.
Ryan Sleevi2e8255b2019-07-17 21:02:2190constexpr base::TimeDelta kDefaultIdleSessionMigrationPeriod =
91 base::TimeDelta::FromSeconds(30);
Zhongyi Shic16b4102019-02-12 00:37:4092
Zhongyi Shi99d0cdd2019-05-21 01:18:4293// The default maximum time allowed to have no retransmittable packets on the
94// wire (after sending the first retransmittable packet) if
Zhongyi Shie01f2db2019-02-22 19:53:2395// |migrate_session_early_v2_| is true. PING frames will be sent as needed to
96// enforce this.
Ryan Sleevi2e8255b2019-07-17 21:02:2197constexpr base::TimeDelta kDefaultRetransmittableOnWireTimeout =
Zhongyi Shi1d96b872019-10-15 21:49:0798 base::TimeDelta::FromMilliseconds(200);
Zhongyi Shie01f2db2019-02-22 19:53:2399
Zhongyi Shi0e52ce72018-03-20 22:31:00100// The default maximum time QUIC session could be on non-default network before
101// migrate back to default network.
Ryan Sleevi2e8255b2019-07-17 21:02:21102constexpr base::TimeDelta kMaxTimeOnNonDefaultNetwork =
103 base::TimeDelta::FromSeconds(128);
Zhongyi Shi0e52ce72018-03-20 22:31:00104
Zhongyi Shiee760762018-08-01 00:54:29105// The default maximum number of migrations to non default network on write
106// error per network.
107const int64_t kMaxMigrationsToNonDefaultNetworkOnWriteError = 5;
108
Zhongyi Shi0e52ce72018-03-20 22:31:00109// The default maximum number of migrations to non default network on path
Zhongyi Shiee760762018-08-01 00:54:29110// degrading per network.
Zhongyi Shi0e52ce72018-03-20 22:31:00111const int64_t kMaxMigrationsToNonDefaultNetworkOnPathDegrading = 5;
112
Matt Menkefca05b62019-09-20 23:15:56113// Maximum number of not currently in use QuicCryptoClientConfig that can be
114// stored in |recent_crypto_config_map_|.
115//
116// TODO(mmenke): Should figure out a reasonable value of this, using field
117// trials. The optimal value may increase over time, as QUIC becomes more
118// prevalent. Whether or not NetworkIsolationKeys end up including subframe URLs
119// will also influence the ideal value.
120const int kMaxRecentCryptoConfigs = 100;
121
Nick Harper72ade192019-07-17 03:30:42122// Structure containing simple configuration options and experiments for QUIC.
123struct NET_EXPORT QuicParams {
124 QuicParams();
125 QuicParams(const QuicParams& other);
126 ~QuicParams();
127
128 // QUIC runtime configuration options.
129
130 // Versions of QUIC which may be used.
131 quic::ParsedQuicVersionVector supported_versions;
132 // User agent description to send in the QUIC handshake.
133 std::string user_agent_id;
134 // Limit on the size of QUIC packets.
135 size_t max_packet_length;
136 // Maximum number of server configs that are to be stored in
137 // HttpServerProperties, instead of the disk cache.
Ryan Sleevi2e8255b2019-07-17 21:02:21138 size_t max_server_configs_stored_in_properties = 0u;
Nick Harper72ade192019-07-17 03:30:42139 // QUIC will be used for all connections in this set.
140 std::set<HostPortPair> origins_to_force_quic_on;
141 // Set of QUIC tags to send in the handshake's connection options.
142 quic::QuicTagVector connection_options;
143 // Set of QUIC tags to send in the handshake's connection options that only
144 // affect the client.
145 quic::QuicTagVector client_connection_options;
146 // Enables experimental optimization for receiving data in UDPSocket.
Ryan Sleevi2e8255b2019-07-17 21:02:21147 bool enable_socket_recv_optimization = false;
Bence Béky1ceba552019-07-19 17:11:05148 // Initial value of QuicSpdyClientSessionBase::max_allowed_push_id_.
149 quic::QuicStreamId max_allowed_push_id = 0;
Nick Harper72ade192019-07-17 03:30:42150
151 // Active QUIC experiments
152
Nick Harper72ade192019-07-17 03:30:42153 // Retry requests which fail with QUIC_PROTOCOL_ERROR, and mark QUIC
154 // broken if the retry succeeds.
Ryan Sleevi2e8255b2019-07-17 21:02:21155 bool retry_without_alt_svc_on_quic_errors = true;
Nick Harper72ade192019-07-17 03:30:42156 // If true, all QUIC sessions are closed when any local IP address changes.
Ryan Sleevi2e8255b2019-07-17 21:02:21157 bool close_sessions_on_ip_change = false;
Nick Harper72ade192019-07-17 03:30:42158 // If true, all QUIC sessions are marked as goaway when any local IP address
159 // changes.
Ryan Sleevi2e8255b2019-07-17 21:02:21160 bool goaway_sessions_on_ip_change = false;
Nick Harper72ade192019-07-17 03:30:42161 // Specifies QUIC idle connection state lifetime.
Ryan Sleevi2e8255b2019-07-17 21:02:21162 base::TimeDelta idle_connection_timeout = kIdleConnectionTimeout;
Nick Harper72ade192019-07-17 03:30:42163 // Specifies the reduced ping timeout subsequent connections should use when
164 // a connection was timed out with open streams.
Ryan Sleevi2e8255b2019-07-17 21:02:21165 base::TimeDelta reduced_ping_timeout;
Nick Harper72ade192019-07-17 03:30:42166 // Maximum time that a session can have no retransmittable packets on the
167 // wire. Set to zero if not specified and no retransmittable PING will be
168 // sent to peer when the wire has no retransmittable packets.
Ryan Sleevi2e8255b2019-07-17 21:02:21169 base::TimeDelta retransmittable_on_wire_timeout;
Nick Harper72ade192019-07-17 03:30:42170 // Maximum time the session can be alive before crypto handshake is
171 // finished.
Ryan Sleevi2e8255b2019-07-17 21:02:21172 base::TimeDelta max_time_before_crypto_handshake;
Nick Harper72ade192019-07-17 03:30:42173 // Maximum idle time before the crypto handshake has completed.
Ryan Sleevi2e8255b2019-07-17 21:02:21174 base::TimeDelta max_idle_time_before_crypto_handshake;
Nick Harper72ade192019-07-17 03:30:42175 // If true, connection migration v2 will be used to migrate existing
176 // sessions to network when the platform indicates that the default network
177 // is changing.
Ryan Sleevi2e8255b2019-07-17 21:02:21178 bool migrate_sessions_on_network_change_v2 = false;
Nick Harper72ade192019-07-17 03:30:42179 // If true, connection migration v2 may be used to migrate active QUIC
180 // sessions to alternative network if current network connectivity is poor.
Ryan Sleevi2e8255b2019-07-17 21:02:21181 bool migrate_sessions_early_v2 = false;
Nick Harper72ade192019-07-17 03:30:42182 // If true, a new connection may be kicked off on an alternate network when
183 // a connection fails on the default network before handshake is confirmed.
Ryan Sleevi2e8255b2019-07-17 21:02:21184 bool retry_on_alternate_network_before_handshake = false;
Nick Harper72ade192019-07-17 03:30:42185 // If true, an idle session will be migrated within the idle migration
186 // period.
Ryan Sleevi2e8255b2019-07-17 21:02:21187 bool migrate_idle_sessions = false;
Zhongyi Shiaf38c4e42019-08-29 22:49:05188 // If true, sessions with open streams will attempt to migrate to a different
189 // port when the current path is poor.
190 bool allow_port_migration = false;
Nick Harper72ade192019-07-17 03:30:42191 // A session can be migrated if its idle time is within this period.
Ryan Sleevi2e8255b2019-07-17 21:02:21192 base::TimeDelta idle_session_migration_period =
193 kDefaultIdleSessionMigrationPeriod;
Nick Harper72ade192019-07-17 03:30:42194 // Maximum time the session could be on the non-default network before
195 // migrates back to default network. Defaults to
196 // kMaxTimeOnNonDefaultNetwork.
Ryan Sleevi2e8255b2019-07-17 21:02:21197 base::TimeDelta max_time_on_non_default_network = kMaxTimeOnNonDefaultNetwork;
Nick Harper72ade192019-07-17 03:30:42198 // Maximum number of migrations to the non-default network on write error
199 // per network for each session.
Ryan Sleevi2e8255b2019-07-17 21:02:21200 int max_migrations_to_non_default_network_on_write_error =
201 kMaxMigrationsToNonDefaultNetworkOnWriteError;
Nick Harper72ade192019-07-17 03:30:42202 // Maximum number of migrations to the non-default network on path
203 // degrading per network for each session.
Ryan Sleevi2e8255b2019-07-17 21:02:21204 int max_migrations_to_non_default_network_on_path_degrading =
205 kMaxMigrationsToNonDefaultNetworkOnPathDegrading;
Nick Harper72ade192019-07-17 03:30:42206 // If true, allows migration of QUIC connections to a server-specified
207 // alternate server address.
Ryan Sleevi2e8255b2019-07-17 21:02:21208 bool allow_server_migration = false;
Nick Harper72ade192019-07-17 03:30:42209 // If true, allows QUIC to use alternative services with a different
210 // hostname from the origin.
Ryan Sleevi2e8255b2019-07-17 21:02:21211 bool allow_remote_alt_svc = true;
Nick Harper72ade192019-07-17 03:30:42212 // If true, the quic stream factory may race connection from stale dns
213 // result with the original dns resolution
Ryan Sleevi2e8255b2019-07-17 21:02:21214 bool race_stale_dns_on_connection = false;
Nick Harper72ade192019-07-17 03:30:42215 // If true, the quic session may mark itself as GOAWAY on path degrading.
Ryan Sleevi2e8255b2019-07-17 21:02:21216 bool go_away_on_path_degrading = false;
Nick Harper72ade192019-07-17 03:30:42217 // If true, bidirectional streams over QUIC will be disabled.
Ryan Sleevi2e8255b2019-07-17 21:02:21218 bool disable_bidirectional_streams = false;
Nick Harper72ade192019-07-17 03:30:42219 // If true, race cert verification with host resolution.
Ryan Sleevi2e8255b2019-07-17 21:02:21220 bool race_cert_verification = false;
Nick Harper72ade192019-07-17 03:30:42221 // If true, estimate the initial RTT for QUIC connections based on network.
Ryan Sleevi2e8255b2019-07-17 21:02:21222 bool estimate_initial_rtt = false;
Nick Harper72ade192019-07-17 03:30:42223 // If true, client headers will include HTTP/2 stream dependency info
224 // derived from the request priority.
Ryan Sleevi2e8255b2019-07-17 21:02:21225 bool headers_include_h2_stream_dependency = false;
Nick Harper72ade192019-07-17 03:30:42226 // The initial rtt that will be used in crypto handshake if no cached
227 // smoothed rtt is present.
Ryan Sleevi2e8255b2019-07-17 21:02:21228 base::TimeDelta initial_rtt_for_handshake;
Nick Harper72ade192019-07-17 03:30:42229};
230
Zhongyi Shib4737c62017-09-28 00:49:31231enum QuicPlatformNotification {
232 NETWORK_CONNECTED,
233 NETWORK_MADE_DEFAULT,
234 NETWORK_DISCONNECTED,
235 NETWORK_SOON_TO_DISCONNECT,
236 NETWORK_IP_ADDRESS_CHANGED,
237 NETWORK_NOTIFICATION_MAX
238};
239
Yixin Wang7891a39d2017-11-08 20:59:24240// Encapsulates a pending request for a QuicChromiumClientSession.
[email protected]e13201d82012-12-12 05:00:32241// If the request is still pending when it is destroyed, it will
242// cancel the request with the factory.
243class NET_EXPORT_PRIVATE QuicStreamRequest {
244 public:
zhongyi98d6a9262017-05-19 02:47:45245 explicit QuicStreamRequest(QuicStreamFactory* factory);
[email protected]e13201d82012-12-12 05:00:32246 ~QuicStreamRequest();
247
rtennetia75df622015-06-21 23:59:50248 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is
249 // passed to CertVerifier::Verify.
bnc359ed2a2016-04-29 20:43:45250 // |destination| will be resolved and resulting IPEndPoint used to open a
Ryan Hamilton8d9ee76e2018-05-29 23:52:52251 // quic::QuicConnection. This can be different than
252 // HostPortPair::FromURL(url).
bnc359ed2a2016-04-29 20:43:45253 int Request(const HostPortPair& destination,
Ryan Hamilton9ef8c102019-06-28 03:58:52254 quic::ParsedQuicVersion quic_version,
[email protected]9dd3ff0f2014-03-26 09:51:28255 PrivacyMode privacy_mode,
Yixin Wang247ea642017-11-15 01:15:50256 RequestPriority priority,
Paul Jensen8e3c5d32018-02-19 17:06:33257 const SocketTag& socket_tag,
Matt Menke26e41542019-06-05 01:09:51258 const NetworkIsolationKey& network_isolation_key,
dalyka92863972019-10-14 20:25:58259 bool disable_secure_dns,
rtennetia75df622015-06-21 23:59:50260 int cert_verify_flags,
ckrasic3865ee0f2016-02-29 22:04:56261 const GURL& url,
tfarina42834112016-09-22 13:38:20262 const NetLogWithSource& net_log,
Ryan Hamilton75f197262017-08-17 14:00:07263 NetErrorDetails* net_error_details,
Zhongyi Shia6b68d112018-09-24 07:49:03264 CompletionOnceCallback failed_on_default_network_callback,
Bence Békyd8a21fc32018-06-27 18:29:58265 CompletionOnceCallback callback);
[email protected]e13201d82012-12-12 05:00:32266
Yixin Wang7c5d11a82017-12-21 02:40:00267 // This function must be called after Request() returns ERR_IO_PENDING.
268 // Returns true if Request() requires host resolution and it hasn't completed
269 // yet. If true is returned, |callback| will run when host resolution
270 // completes. It will be called with the result after host resolution during
271 // the connection process. For example, if host resolution returns OK and then
272 // crypto handshake returns ERR_IO_PENDING, then |callback| will run with
273 // ERR_IO_PENDING.
Bence Békyd8a21fc32018-06-27 18:29:58274 bool WaitForHostResolution(CompletionOnceCallback callback);
Yixin Wang7c5d11a82017-12-21 02:40:00275
276 // Tells QuicStreamRequest it should expect OnHostResolutionComplete()
277 // to be called in the future.
278 void ExpectOnHostResolution();
279
280 // Will be called by the associated QuicStreamFactory::Job when host
281 // resolution completes asynchronously after Request().
282 void OnHostResolutionComplete(int rv);
283
[email protected]e13201d82012-12-12 05:00:32284 void OnRequestComplete(int rv);
285
Zhongyi Shia6b68d112018-09-24 07:49:03286 // Called when the original connection created on the default network for
287 // |this| fails and a new connection has been created on the alternate
288 // network.
289 void OnConnectionFailedOnDefaultNetwork();
290
rtenneti8332ba52015-09-17 19:33:41291 // Helper method that calls |factory_|'s GetTimeDelayForWaitingJob(). It
292 // returns the amount of time waiting job should be delayed.
293 base::TimeDelta GetTimeDelayForWaitingJob() const;
294
Lily Chenf11e1292018-11-29 16:42:09295 // If host resolution is underway, changes the priority of the host resolver
296 // request.
297 void SetPriority(RequestPriority priority);
298
Yixin Wang7891a39d2017-11-08 20:59:24299 // Releases the handle to the QUIC session retrieved as a result of Request().
300 std::unique_ptr<QuicChromiumClientSession::Handle> ReleaseSessionHandle();
xunjieli2608f9b2016-03-14 13:39:23301
302 // Sets |session_|.
rchf0b18c8a2017-05-05 19:31:57303 void SetSession(std::unique_ptr<QuicChromiumClientSession::Handle> session);
[email protected]e13201d82012-12-12 05:00:32304
Ryan Hamilton75f197262017-08-17 14:00:07305 NetErrorDetails* net_error_details() { return net_error_details_; }
306
Paul Jensen8e3c5d32018-02-19 17:06:33307 const QuicSessionKey& session_key() const { return session_key_; }
bnccb7ff3c2015-05-21 20:51:55308
tfarina42834112016-09-22 13:38:20309 const NetLogWithSource& net_log() const { return net_log_; }
[email protected]e13201d82012-12-12 05:00:32310
311 private:
312 QuicStreamFactory* factory_;
Paul Jensen8e3c5d32018-02-19 17:06:33313 QuicSessionKey session_key_;
tfarina42834112016-09-22 13:38:20314 NetLogWithSource net_log_;
Bence Békyd8a21fc32018-06-27 18:29:58315 CompletionOnceCallback callback_;
Zhongyi Shia6b68d112018-09-24 07:49:03316 CompletionOnceCallback failed_on_default_network_callback_;
Ryan Hamilton75f197262017-08-17 14:00:07317 NetErrorDetails* net_error_details_; // Unowned.
rchf0b18c8a2017-05-05 19:31:57318 std::unique_ptr<QuicChromiumClientSession::Handle> session_;
[email protected]e13201d82012-12-12 05:00:32319
Yixin Wang7c5d11a82017-12-21 02:40:00320 // Set in Request(). If true, then OnHostResolutionComplete() is expected to
321 // be called in the future.
322 bool expect_on_host_resolution_;
323 // Callback passed to WaitForHostResolution().
Bence Békyd8a21fc32018-06-27 18:29:58324 CompletionOnceCallback host_resolution_callback_;
Yixin Wang7c5d11a82017-12-21 02:40:00325
[email protected]e13201d82012-12-12 05:00:32326 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest);
327};
328
Yixin Wang7891a39d2017-11-08 20:59:24329// A factory for fetching QuicChromiumClientSessions.
[email protected]f698a012013-05-06 20:18:59330class NET_EXPORT_PRIVATE QuicStreamFactory
[email protected]d7d1e50b2013-11-25 22:08:09331 : public NetworkChangeNotifier::IPAddressObserver,
jri7e636642016-01-14 06:57:08332 public NetworkChangeNotifier::NetworkObserver,
[email protected]d7d1e50b2013-11-25 22:08:09333 public CertDatabase::Observer {
[email protected]e13201d82012-12-12 05:00:32334 public:
bnc359ed2a2016-04-29 20:43:45335 // This class encompasses |destination| and |server_id|.
336 // |destination| is a HostPortPair which is resolved
Ryan Hamilton8d9ee76e2018-05-29 23:52:52337 // and a quic::QuicConnection is made to the resulting IP address.
bnc359ed2a2016-04-29 20:43:45338 // |server_id| identifies the origin of the request,
339 // the crypto handshake advertises |server_id.host()| to the server,
340 // and the certificate is also matched against |server_id.host()|.
Paul Jensen8e3c5d32018-02-19 17:06:33341 class NET_EXPORT_PRIVATE QuicSessionAliasKey {
bnc359ed2a2016-04-29 20:43:45342 public:
Paul Jensen8e3c5d32018-02-19 17:06:33343 QuicSessionAliasKey() = default;
344 QuicSessionAliasKey(const HostPortPair& destination,
345 const QuicSessionKey& session_key);
346 ~QuicSessionAliasKey() = default;
bnc359ed2a2016-04-29 20:43:45347
348 // Needed to be an element of std::set.
Paul Jensen8e3c5d32018-02-19 17:06:33349 bool operator<(const QuicSessionAliasKey& other) const;
350 bool operator==(const QuicSessionAliasKey& other) const;
bnc359ed2a2016-04-29 20:43:45351
352 const HostPortPair& destination() const { return destination_; }
Ryan Hamilton8d9ee76e2018-05-29 23:52:52353 const quic::QuicServerId& server_id() const {
354 return session_key_.server_id();
355 }
Paul Jensen8e3c5d32018-02-19 17:06:33356 const QuicSessionKey& session_key() const { return session_key_; }
bnc359ed2a2016-04-29 20:43:45357
xunjieli69720dd2017-01-30 15:36:29358 // Returns the estimate of dynamically allocated memory in bytes.
359 size_t EstimateMemoryUsage() const;
360
bnc359ed2a2016-04-29 20:43:45361 private:
362 HostPortPair destination_;
Paul Jensen8e3c5d32018-02-19 17:06:33363 QuicSessionKey session_key_;
bnc359ed2a2016-04-29 20:43:45364 };
365
[email protected]e8ff26842013-03-22 21:02:05366 QuicStreamFactory(
jridf673d22016-06-02 22:06:33367 NetLog* net_log,
[email protected]e8ff26842013-03-22 21:02:05368 HostResolver* host_resolver,
nharper642ae4b2016-06-30 00:40:36369 SSLConfigService* ssl_config_service,
[email protected]e8ff26842013-03-22 21:02:05370 ClientSocketFactory* client_socket_factory,
bnc525e175a2016-06-20 12:36:40371 HttpServerProperties* http_server_properties,
[email protected]59c0bbd2014-03-22 04:08:12372 CertVerifier* cert_verifier,
estark6f9b3d82016-01-12 21:37:05373 CTPolicyEnforcer* ct_policy_enforcer,
[email protected]080b77932014-08-04 01:22:46374 TransportSecurityState* transport_security_state,
rtenneti052774e2015-11-24 21:00:12375 CTVerifier* cert_transparency_verifier,
tbansalc8a94ea2015-11-02 23:58:51376 SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
[email protected]e8ff26842013-03-22 21:02:05377 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory,
Victor Vasiliev7752898d2019-11-14 21:30:22378 QuicContext* context,
Nick Harper72ade192019-07-17 03:30:42379 const QuicParams& params);
dchengb03027d2014-10-21 12:00:20380 ~QuicStreamFactory() override;
[email protected]e13201d82012-12-12 05:00:32381
Paul Jensen8e3c5d32018-02-19 17:06:33382 // Returns true if there is an existing session for |session_key| or if the
bnc359ed2a2016-04-29 20:43:45383 // request can be pooled to an existing session to the IP address of
384 // |destination|.
Paul Jensen8e3c5d32018-02-19 17:06:33385 bool CanUseExistingSession(const QuicSessionKey& session_key,
bnc359ed2a2016-04-29 20:43:45386 const HostPortPair& destination);
zhongyi32569c62016-01-08 02:54:30387
Yixin Wang7891a39d2017-11-08 20:59:24388 // Fetches a QuicChromiumClientSession to |host_port_pair| which will be
rchf114d982015-10-21 01:34:56389 // owned by |request|.
[email protected]0cceb922014-07-01 02:00:56390 // If a matching session already exists, this method will return OK. If no
391 // matching session exists, this will return ERR_IO_PENDING and will invoke
392 // OnRequestComplete asynchronously.
Paul Jensen8e3c5d32018-02-19 17:06:33393 int Create(const QuicSessionKey& session_key,
bnc359ed2a2016-04-29 20:43:45394 const HostPortPair& destination,
Ryan Hamilton9ef8c102019-06-28 03:58:52395 quic::ParsedQuicVersion quic_version,
Yixin Wang247ea642017-11-15 01:15:50396 RequestPriority priority,
rtennetia75df622015-06-21 23:59:50397 int cert_verify_flags,
ckrasic3865ee0f2016-02-29 22:04:56398 const GURL& url,
tfarina42834112016-09-22 13:38:20399 const NetLogWithSource& net_log,
[email protected]e13201d82012-12-12 05:00:32400 QuicStreamRequest* request);
401
[email protected]4d283b32013-10-17 12:57:27402 // Called by a session when it is going away and no more streams should be
403 // created on it.
ckrasic4f9d88d2015-07-22 22:23:16404 void OnSessionGoingAway(QuicChromiumClientSession* session);
[email protected]4d283b32013-10-17 12:57:27405
[email protected]e13201d82012-12-12 05:00:32406 // Called by a session after it shuts down.
ckrasic4f9d88d2015-07-22 22:23:16407 void OnSessionClosed(QuicChromiumClientSession* session);
[email protected]e13201d82012-12-12 05:00:32408
rch9ecde09b2017-04-08 00:18:23409 // Called by a session when it blackholes after the handshake is confirmed.
410 void OnBlackholeAfterHandshakeConfirmed(QuicChromiumClientSession* session);
zhongyidd1439f62016-09-02 02:02:26411
[email protected]e13201d82012-12-12 05:00:32412 // Cancels a pending request.
413 void CancelRequest(QuicStreamRequest* request);
414
Lily Chenf11e1292018-11-29 16:42:09415 // Sets priority of a request.
416 void SetRequestPriority(QuicStreamRequest* request, RequestPriority priority);
417
Renjieba55fae2018-09-20 03:05:16418 // Closes all current sessions with specified network, QUIC error codes.
419 // It sends connection close packet when closing connections.
Ryan Hamilton8d9ee76e2018-05-29 23:52:52420 void CloseAllSessions(int error, quic::QuicErrorCode quic_error);
[email protected]56dfb902013-01-03 23:17:55421
danakjad1777e2016-04-16 00:56:42422 std::unique_ptr<base::Value> QuicStreamFactoryInfoToValue() const;
[email protected]c5b061b2013-01-05 00:31:34423
msramek992625ec2016-08-04 18:33:58424 // Delete cached state objects in |crypto_config_|. If |origin_filter| is not
425 // null, only objects on matching origins will be deleted.
426 void ClearCachedStatesInCryptoConfig(
427 const base::Callback<bool(const GURL&)>& origin_filter);
[email protected]f7e21a432014-04-21 22:17:57428
jri7e636642016-01-14 06:57:08429 // Helper method that configures a DatagramClientSocket. Socket is
430 // bound to the default network if the |network| param is
431 // NetworkChangeNotifier::kInvalidNetworkHandle.
432 // Returns net_error code.
433 int ConfigureSocket(DatagramClientSocket* socket,
434 IPEndPoint addr,
Paul Jensen8e3c5d32018-02-19 17:06:33435 NetworkChangeNotifier::NetworkHandle network,
436 const SocketTag& socket_tag);
jri7e636642016-01-14 06:57:08437
jriae8cfdc2016-01-21 19:44:35438 // Finds an alternative to |old_network| from the platform's list of connected
439 // networks. Returns NetworkChangeNotifier::kInvalidNetworkHandle if no
440 // alternative is found.
441 NetworkChangeNotifier::NetworkHandle FindAlternateNetwork(
442 NetworkChangeNotifier::NetworkHandle old_network);
443
Zhongyi Shi673f22ef2017-10-18 00:00:47444 // Creates a datagram socket. |source| is the NetLogSource for the entity
445 // trying to create the socket, if it has one.
446 std::unique_ptr<DatagramClientSocket> CreateSocket(
447 NetLog* net_log,
448 const NetLogSource& source);
449
[email protected]f698a012013-05-06 20:18:59450 // NetworkChangeNotifier::IPAddressObserver methods:
451
Jana Iyengar903dec22017-11-28 00:44:23452 // Until the servers support roaming, close all connections when the local
453 // IP address changes.
dchengb03027d2014-10-21 12:00:20454 void OnIPAddressChanged() override;
[email protected]f698a012013-05-06 20:18:59455
jri7e636642016-01-14 06:57:08456 // NetworkChangeNotifier::NetworkObserver methods:
457 void OnNetworkConnected(
458 NetworkChangeNotifier::NetworkHandle network) override;
459 void OnNetworkDisconnected(
460 NetworkChangeNotifier::NetworkHandle network) override;
461 void OnNetworkSoonToDisconnect(
462 NetworkChangeNotifier::NetworkHandle network) override;
463 void OnNetworkMadeDefault(
464 NetworkChangeNotifier::NetworkHandle network) override;
465
[email protected]d7d1e50b2013-11-25 22:08:09466 // CertDatabase::Observer methods:
467
468 // We close all sessions when certificate database is changed.
mattmfd05a1f2017-02-18 06:18:44469 void OnCertDBChanged() override;
[email protected]d7d1e50b2013-11-25 22:08:09470
Matt Menkeb566c392019-09-11 23:22:43471 bool is_quic_known_to_work_on_current_network() const {
472 return is_quic_known_to_work_on_current_network_;
473 }
[email protected]11c05872013-08-20 02:04:12474
Nick Harper72ade192019-07-17 03:30:42475 bool allow_server_migration() const { return params_.allow_server_migration; }
Zhongyi Shif124a582017-11-02 00:15:04476
Matt Menkeb566c392019-09-11 23:22:43477 void set_is_quic_known_to_work_on_current_network(
478 bool is_quic_known_to_work_on_current_network);
[email protected]11c05872013-08-20 02:04:12479
rtenneti8332ba52015-09-17 19:33:41480 // It returns the amount of time waiting job should be delayed.
Renjie Tangdd708972019-10-03 20:56:21481 base::TimeDelta GetTimeDelayForWaitingJob(const QuicSessionKey& session_key);
rtenneti8332ba52015-09-17 19:33:41482
rch12fef552016-01-15 16:26:31483 QuicChromiumConnectionHelper* helper() { return helper_.get(); }
[email protected]2cfc6bb82013-10-27 03:40:44484
Ryan Hamilton8d9ee76e2018-05-29 23:52:52485 quic::QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); }
rch16c74d1d2016-04-22 06:14:07486
zhongyiaf257542016-12-19 03:36:01487 void set_server_push_delegate(ServerPushDelegate* push_delegate) {
488 push_delegate_ = push_delegate;
489 }
490
Zhongyi Shi8de43832018-08-15 23:40:00491 NetworkChangeNotifier::NetworkHandle default_network() const {
492 return default_network_;
493 }
494
xunjieli69720dd2017-01-30 15:36:29495 // Dumps memory allocation stats. |parent_dump_absolute_name| is the name
496 // used by the parent MemoryAllocatorDump in the memory dump hierarchy.
497 void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd,
498 const std::string& parent_absolute_name) const;
499
[email protected]e13201d82012-12-12 05:00:32500 private:
501 class Job;
rtennetid073dd22016-08-04 01:58:33502 class CertVerifierJob;
Matt Menkefca05b62019-09-20 23:15:56503 class QuicCryptoClientConfigOwner;
504 class CryptoClientConfigHandle;
[email protected]c49ff182013-09-28 08:33:26505 friend class test::QuicStreamFactoryPeer;
[email protected]e13201d82012-12-12 05:00:32506
Paul Jensen8e3c5d32018-02-19 17:06:33507 typedef std::map<QuicSessionKey, QuicChromiumClientSession*> SessionMap;
508 typedef std::map<QuicChromiumClientSession*, QuicSessionAliasKey>
509 SessionIdMap;
510 typedef std::set<QuicSessionAliasKey> AliasSet;
ckrasic4f9d88d2015-07-22 22:23:16511 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap;
512 typedef std::set<QuicChromiumClientSession*> SessionSet;
rchf114d982015-10-21 01:34:56513 typedef std::map<IPEndPoint, SessionSet> IPAliasMap;
jri94ddc3142016-08-26 01:32:43514 typedef std::map<QuicChromiumClientSession*, IPEndPoint> SessionPeerIPMap;
Paul Jensen8e3c5d32018-02-19 17:06:33515 typedef std::map<QuicSessionKey, std::unique_ptr<Job>> JobMap;
Ryan Hamilton8d9ee76e2018-05-29 23:52:52516 typedef std::map<quic::QuicServerId, std::unique_ptr<CertVerifierJob>>
rtennetid073dd22016-08-04 01:58:33517 CertVerifierJobMap;
Matt Menkefca05b62019-09-20 23:15:56518 using QuicCryptoClientConfigMap =
519 std::map<NetworkIsolationKey,
520 std::unique_ptr<QuicCryptoClientConfigOwner>>;
rtenneti14abd312015-02-06 21:56:01521
Paul Jensen8e3c5d32018-02-19 17:06:33522 bool HasMatchingIpSession(const QuicSessionAliasKey& key,
Yixin Wang7c5d11a82017-12-21 02:40:00523 const AddressList& address_list);
[email protected]e13201d82012-12-12 05:00:32524 void OnJobComplete(Job* job, int rv);
rtennetid073dd22016-08-04 01:58:33525 void OnCertVerifyJobComplete(CertVerifierJob* job, int rv);
Paul Jensen8e3c5d32018-02-19 17:06:33526 bool HasActiveSession(const QuicSessionKey& session_key) const;
527 bool HasActiveJob(const QuicSessionKey& session_key) const;
Ryan Hamilton8d9ee76e2018-05-29 23:52:52528 bool HasActiveCertVerifierJob(const quic::QuicServerId& server_id) const;
Paul Jensen8e3c5d32018-02-19 17:06:33529 int CreateSession(const QuicSessionAliasKey& key,
Ryan Hamilton9ef8c102019-06-28 03:58:52530 quic::ParsedQuicVersion quic_version,
rtennetia75df622015-06-21 23:59:50531 int cert_verify_flags,
rch433bf5f2017-02-14 04:10:47532 bool require_confirmation,
[email protected]338e7982013-12-13 11:15:32533 const AddressList& address_list,
xunjieli100937eb52016-09-15 20:09:37534 base::TimeTicks dns_resolution_start_time,
rtennetif4f08852015-02-27 17:50:04535 base::TimeTicks dns_resolution_end_time,
tfarina42834112016-09-22 13:38:20536 const NetLogWithSource& net_log,
Zhongyi Shi55ec9532018-07-24 03:57:39537 QuicChromiumClientSession** session,
538 NetworkChangeNotifier::NetworkHandle* network);
Paul Jensen8e3c5d32018-02-19 17:06:33539 void ActivateSession(const QuicSessionAliasKey& key,
ckrasic4f9d88d2015-07-22 22:23:16540 QuicChromiumClientSession* session);
Charles 'Buck' Krasic71763c9f2018-02-16 02:37:28541 void MarkAllActiveSessionsGoingAway();
[email protected]e13201d82012-12-12 05:00:32542
Matt Menke19475f72019-08-21 18:57:44543 void ConfigureInitialRttEstimate(
544 const quic::QuicServerId& server_id,
545 const NetworkIsolationKey& network_isolation_key,
546 quic::QuicConfig* config);
rchd6163f32017-01-30 23:50:38547
rtenneti2912825c2015-01-06 01:19:46548 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there
549 // is no |http_server_properties_| or if |http_server_properties_| doesn't
550 // have ServerNetworkStats for the given |server_id|.
Avi Drissman13fc8932015-12-20 04:40:46551 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds(
Matt Menke19475f72019-08-21 18:57:44552 const quic::QuicServerId& server_id,
553 const NetworkIsolationKey& network_isolation_key) const;
rtenneti2912825c2015-01-06 01:19:46554
rchd6163f32017-01-30 23:50:38555 // Returns |srtt| from ServerNetworkStats. Returns null if there
556 // is no |http_server_properties_| or if |http_server_properties_| doesn't
557 // have ServerNetworkStats for the given |server_id|.
558 const base::TimeDelta* GetServerNetworkStatsSmoothedRtt(
Matt Menke19475f72019-08-21 18:57:44559 const quic::QuicServerId& server_id,
560 const NetworkIsolationKey& network_isolation_key) const;
rchd6163f32017-01-30 23:50:38561
bnccacc0992015-03-20 20:22:22562 // Helper methods.
Matt Menkeb32ba5122019-09-10 19:17:05563 bool WasQuicRecentlyBroken(const QuicSessionKey& session_key) const;
rtenneti8332ba52015-09-17 19:33:41564
rtennetid073dd22016-08-04 01:58:33565 // Starts an asynchronous job for cert verification if
Nick Harper72ade192019-07-17 03:30:42566 // |params_.race_cert_verification| is enabled and if there are cached certs
567 // for the given |server_id|.
Matt Menkefca05b62019-09-20 23:15:56568 //
569 // Takes a constant reference to a CryptoClientConfigHandle instead of a
570 // NetworkIsolationKey to force the caller to keep the corresponding
571 // QuicCryptoClientConfig alive. There's no guarantee it won't be garbage
572 // collected beyond when this method completes, otherwise.
573 quic::QuicAsyncStatus StartCertVerifyJob(
574 const CryptoClientConfigHandle& crypto_config_handle,
575 const quic::QuicServerId& server_id,
576 int cert_verify_flags,
577 const NetLogWithSource& net_log);
rtennetid073dd22016-08-04 01:58:33578
Zhongyi Shid04bd412019-08-26 23:31:08579 // Helper method to initialize the following migration options and check
580 // pre-requisites:
581 // - |params_.migrate_sessions_on_network_change_v2|
582 // - |params_.migrate_sessions_early_v2|
583 // - |params_.migrate_idle_sessions|
584 // - |params_.retry_on_alternate_network_before_handshake|
585 // If pre-requisites are not met, turn off the corresponding options.
586 void InitializeMigrationOptions();
587
[email protected]257f24f2014-04-01 09:15:37588 // Initializes the cached state associated with |server_id| in
rchf37ccc782016-01-31 05:13:50589 // |crypto_config_| with the information in |server_info|. Populates
590 // |connection_id| with the next server designated connection id,
591 // if any, and otherwise leaves it unchanged.
[email protected]60cf50e2014-04-28 23:23:18592 void InitializeCachedStateInCryptoConfig(
Matt Menkefca05b62019-09-20 23:15:56593 const CryptoClientConfigHandle& crypto_config_handle,
Ryan Hamilton8d9ee76e2018-05-29 23:52:52594 const quic::QuicServerId& server_id,
danakjad1777e2016-04-16 00:56:42595 const std::unique_ptr<QuicServerInfo>& server_info,
Ryan Hamilton8d9ee76e2018-05-29 23:52:52596 quic::QuicConnectionId* connection_id);
[email protected]b694e48c2014-03-18 17:10:13597
ckrasic4f9d88d2015-07-22 22:23:16598 void ProcessGoingAwaySession(QuicChromiumClientSession* session,
Ryan Hamilton8d9ee76e2018-05-29 23:52:52599 const quic::QuicServerId& server_id,
[email protected]eb71ab62014-05-23 07:57:53600 bool was_session_active);
[email protected]4d590c9c2014-05-02 05:14:33601
Matt Menkefca05b62019-09-20 23:15:56602 // Creates a CreateCryptoConfigHandle for the specified NetworkIsolationKey.
603 // If there's already a corresponding entry in |active_crypto_config_map_|,
604 // reuses it. If there's a corresponding entry in |recent_crypto_config_map_|,
605 // promotes it to |active_crypto_config_map_| and then reuses it. Otherwise,
606 // creates a new entry in |active_crypto_config_map_|.
607 std::unique_ptr<CryptoClientConfigHandle> CreateCryptoConfigHandle(
608 const NetworkIsolationKey& network_isolation_key);
609
610 // Salled when the indicated member of |active_crypto_config_map_| has no
611 // outstanding references. The QuicCryptoClientConfigOwner is then moved to
612 // |recent_crypto_config_map_|, an MRU cache.
613 void OnAllCryptoClientRefReleased(
614 QuicCryptoClientConfigMap::iterator& map_iterator);
615
616 std::unique_ptr<QuicCryptoClientConfigHandle> GetCryptoConfigForTesting(
617 const NetworkIsolationKey& network_isolation_key);
618
619 quic::QuicAsyncStatus StartCertVerifyJobForTesting(
620 const quic::QuicServerId& server_id,
621 const NetworkIsolationKey& network_isolation_key,
622 int cert_verify_flags,
623 const NetLogWithSource& net_log);
624
Matt Menkeca5253312019-09-23 18:59:37625 bool CryptoConfigCacheIsEmptyForTesting(
626 const quic::QuicServerId& server_id,
627 const NetworkIsolationKey& network_isolation_key);
628
Matt Menkeb566c392019-09-11 23:22:43629 // Whether QUIC is known to work on current network. This is true when QUIC is
630 // expected to work in general, rather than whether QUIC was broken / recently
631 // broken when used with a particular server. That information is stored in
632 // the broken alternative service map in HttpServerProperties.
633 bool is_quic_known_to_work_on_current_network_;
634
jridf673d22016-06-02 22:06:33635 NetLog* net_log_;
[email protected]e13201d82012-12-12 05:00:32636 HostResolver* host_resolver_;
637 ClientSocketFactory* client_socket_factory_;
bnc525e175a2016-06-20 12:36:40638 HttpServerProperties* http_server_properties_;
zhongyiaf257542016-12-19 03:36:01639 ServerPushDelegate* push_delegate_;
Matt Menkefca05b62019-09-20 23:15:56640 CertVerifier* const cert_verifier_;
641 CTPolicyEnforcer* const ct_policy_enforcer_;
642 TransportSecurityState* const transport_security_state_;
643 CTVerifier* const cert_transparency_verifier_;
[email protected]e8ff26842013-03-22 21:02:05644 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_;
Ryan Hamilton8d9ee76e2018-05-29 23:52:52645 quic::QuicRandom* random_generator_; // Unowned.
Victor Vasiliev7752898d2019-11-14 21:30:22646 const quic::QuicClock* clock_; // Unowned.
Nick Harper72ade192019-07-17 03:30:42647 QuicParams params_;
rchf11cc0f2016-11-15 03:04:32648 QuicClockSkewDetector clock_skew_detector_;
[email protected]e13201d82012-12-12 05:00:32649
tbansalfdf5665b2015-09-21 22:46:40650 // Factory which is used to create socket performance watcher. A new watcher
651 // is created for every QUIC connection.
652 // |socket_performance_watcher_factory_| may be null.
tbansalc8a94ea2015-11-02 23:58:51653 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
tbansalfdf5665b2015-09-21 22:46:40654
[email protected]2cfc6bb82013-10-27 03:40:44655 // The helper used for all connections.
danakjad1777e2016-04-16 00:56:42656 std::unique_ptr<QuicChromiumConnectionHelper> helper_;
[email protected]2cfc6bb82013-10-27 03:40:44657
rch16c74d1d2016-04-22 06:14:07658 // The alarm factory used for all connections.
Ryan Hamilton8d9ee76e2018-05-29 23:52:52659 std::unique_ptr<quic::QuicAlarmFactory> alarm_factory_;
rch16c74d1d2016-04-22 06:14:07660
[email protected]e13201d82012-12-12 05:00:32661 // Contains owning pointers to all sessions that currently exist.
[email protected]4d590c9c2014-05-02 05:14:33662 SessionIdMap all_sessions_;
[email protected]e13201d82012-12-12 05:00:32663 // Contains non-owning pointers to currently active session
664 // (not going away session, once they're implemented).
665 SessionMap active_sessions_;
[email protected]eed749f92013-12-23 18:57:38666 // Map from session to set of aliases that this session is known by.
[email protected]e13201d82012-12-12 05:00:32667 SessionAliasMap session_aliases_;
[email protected]eed749f92013-12-23 18:57:38668 // Map from IP address to sessions which are connected to this address.
669 IPAliasMap ip_aliases_;
jri94ddc3142016-08-26 01:32:43670 // Map from session to its original peer IP address.
671 SessionPeerIPMap session_peer_ip_;
[email protected]e13201d82012-12-12 05:00:32672
[email protected]d8e2abf82014-03-06 10:30:10673 // Origins which have gone away recently.
674 AliasSet gone_away_aliases_;
675
Matt Menkefca05b62019-09-20 23:15:56676 // When a QuicCryptoClientConfig is in use, it has one or more live
677 // CryptoClientConfigHandles, and is stored in |active_crypto_config_map_|.
678 // Once all the handles are deleted, it's moved to
679 // |recent_crypto_config_map_|. If reused before it is evicted from MRUCache,
680 // it will be removed from the cache and return to the active config map.
681 // These two maps should never both have entries with the same
682 // NetworkIsolationKey.
683 QuicCryptoClientConfigMap active_crypto_config_map_;
684 base::MRUCache<NetworkIsolationKey,
685 std::unique_ptr<QuicCryptoClientConfigOwner>>
686 recent_crypto_config_map_;
687
Ryan Hamilton8d9ee76e2018-05-29 23:52:52688 const quic::QuicConfig config_;
[email protected]b064310782013-05-30 21:12:17689
[email protected]e13201d82012-12-12 05:00:32690 JobMap active_jobs_;
[email protected]e13201d82012-12-12 05:00:32691
Ryan Hamilton8d9ee76e2018-05-29 23:52:52692 // Map of quic::QuicServerId to owning CertVerifierJob.
rtennetid073dd22016-08-04 01:58:33693 CertVerifierJobMap active_cert_verifier_jobs_;
694
zhongyidd1439f62016-09-02 02:02:26695 // PING timeout for connections.
Ryan Hamilton8d9ee76e2018-05-29 23:52:52696 quic::QuicTime::Delta ping_timeout_;
697 quic::QuicTime::Delta reduced_ping_timeout_;
zhongyidd1439f62016-09-02 02:02:26698
Zhongyi Shie01f2db2019-02-22 19:53:23699 // Timeout for how long the wire can have no retransmittable packets.
700 quic::QuicTime::Delta retransmittable_on_wire_timeout_;
701
rtenneti1cd3b162015-09-29 02:58:28702 // If more than |yield_after_packets_| packets have been read or more than
703 // |yield_after_duration_| time has passed, then
rcha02807b42016-01-29 21:56:15704 // QuicChromiumPacketReader::StartReading() yields by doing a PostTask().
rtenneti1cd3b162015-09-29 02:58:28705 int yield_after_packets_;
Ryan Hamilton8d9ee76e2018-05-29 23:52:52706 quic::QuicTime::Delta yield_after_duration_;
rtenneti1cd3b162015-09-29 02:58:28707
Zhongyi Shi6db13462018-05-19 01:36:26708 // If |migrate_sessions_early_v2_| is true, tracks the current default
709 // network, and is updated OnNetworkMadeDefault.
710 // Otherwise, always set to NetworkChangeNotifier::kInvalidNetwork.
711 NetworkChangeNotifier::NetworkHandle default_network_;
712
rtennetifc47e0e2014-09-26 02:54:05713 // Local address of socket that was created in CreateSession.
714 IPEndPoint local_address_;
Zhongyi Shia0cef1082017-08-25 01:49:50715 // True if we need to check HttpServerProperties if QUIC was supported last
716 // time.
717 bool need_to_check_persisted_supports_quic_;
Matt Menkefca05b62019-09-20 23:15:56718 bool prefer_aes_gcm_recorded_;
rtennetifc47e0e2014-09-26 02:54:05719
rtenneti041b2992015-02-23 23:03:28720 NetworkConnection network_connection_;
721
ckrasic3865ee0f2016-02-29 22:04:56722 int num_push_streams_created_;
723
Ryan Hamilton8d9ee76e2018-05-29 23:52:52724 quic::QuicClientPushPromiseIndex push_promise_index_;
jric533399b2016-01-29 07:36:01725
Zhongyi Shic16b4102019-02-12 00:37:40726 const base::TickClock* tick_clock_;
727
Zhongyi Shi8fff75b2017-11-19 21:36:36728 base::SequencedTaskRunner* task_runner_;
rtenneti38f5cd52014-10-28 20:28:28729
Ryan Sleevib8449e02018-07-15 04:31:07730 SSLConfigService* const ssl_config_service_;
nharper642ae4b2016-06-30 00:40:36731
Matt Menkefca05b62019-09-20 23:15:56732 // Whether NetworkIsolationKeys should be used for
733 // |active_crypto_config_map_|. If false, there will just be one config with
734 // an empty NetworkIsolationKey. Whether QuicSessionAliasKeys all have an
735 // empty NIK is based on whether socket pools are respecting NIKs, but whether
736 // those NIKs are also used when accessing |active_crypto_config_map_| is also
737 // gated this, which is set based on whether HttpServerProperties is
738 // respecting NIKs, as that data is fed into the crypto config map using the
739 // corresponding NIK.
740 const bool use_network_isolation_key_for_crypto_configs_;
741
Jeremy Romand54000b22019-07-08 18:40:16742 base::WeakPtrFactory<QuicStreamFactory> weak_factory_{this};
[email protected]1e960032013-12-20 19:00:20743
[email protected]e13201d82012-12-12 05:00:32744 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
745};
746
747} // namespace net
748
Ryan Hamiltona3ee93a72018-08-01 22:03:08749#endif // NET_QUIC_QUIC_STREAM_FACTORY_H_