Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_QUIC_QUIC_STREAM_FACTORY_H_ | 5 #ifndef NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| 6 #define NET_QUIC_QUIC_STREAM_FACTORY_H_ | 6 #define NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "net/base/address_list.h" | 15 #include "net/base/address_list.h" |
| 16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
| 18 #include "net/base/network_change_notifier.h" | 18 #include "net/base/network_change_notifier.h" |
| 19 #include "net/cert/cert_database.h" | 19 #include "net/cert/cert_database.h" |
| 20 #include "net/log/net_log.h" | 20 #include "net/log/net_log.h" |
| 21 #include "net/proxy/proxy_server.h" | 21 #include "net/proxy/proxy_server.h" |
| 22 #include "net/quic/network_connection.h" | 22 #include "net/quic/network_connection.h" |
| 23 #include "net/quic/quic_config.h" | 23 #include "net/quic/quic_config.h" |
| 24 #include "net/quic/quic_crypto_stream.h" | 24 #include "net/quic/quic_crypto_stream.h" |
| 25 #include "net/quic/quic_http_stream.h" | 25 #include "net/quic/quic_http_stream.h" |
| 26 #include "net/quic/quic_protocol.h" | 26 #include "net/quic/quic_protocol.h" |
| 27 #include "net/quic/quic_types.h" | |
| 27 | 28 |
| 28 namespace net { | 29 namespace net { |
| 29 | 30 |
| 30 class CertVerifier; | 31 class CertVerifier; |
| 31 class ChannelIDService; | 32 class ChannelIDService; |
| 32 class ClientSocketFactory; | 33 class ClientSocketFactory; |
| 33 class HostResolver; | 34 class HostResolver; |
| 34 class HttpServerProperties; | 35 class HttpServerProperties; |
| 35 class QuicClock; | 36 class QuicClock; |
| 36 class QuicClientSession; | 37 class QuicClientSession; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 bool enable_port_selection, | 115 bool enable_port_selection, |
| 115 bool always_require_handshake_confirmation, | 116 bool always_require_handshake_confirmation, |
| 116 bool disable_connection_pooling, | 117 bool disable_connection_pooling, |
| 117 float load_server_info_timeout_srtt_multiplier, | 118 float load_server_info_timeout_srtt_multiplier, |
| 118 bool enable_connection_racing, | 119 bool enable_connection_racing, |
| 119 bool enable_non_blocking_io, | 120 bool enable_non_blocking_io, |
| 120 bool disable_disk_cache, | 121 bool disable_disk_cache, |
| 121 bool prefer_aes, | 122 bool prefer_aes, |
| 122 int max_number_of_lossy_connections, | 123 int max_number_of_lossy_connections, |
| 123 float packet_loss_threshold, | 124 float packet_loss_threshold, |
| 125 int max_epitaphs, | |
| 126 int threshold_timeouts_with_streams_open, | |
| 127 int threshold_public_resets_post_handshake, | |
| 124 int socket_receive_buffer_size, | 128 int socket_receive_buffer_size, |
| 125 const QuicTagVector& connection_options); | 129 const QuicTagVector& connection_options); |
| 126 ~QuicStreamFactory() override; | 130 ~QuicStreamFactory() override; |
| 127 | 131 |
| 128 // Creates a new QuicHttpStream to |host_port_pair| which will be | 132 // Creates a new QuicHttpStream to |host_port_pair| which will be |
| 129 // owned by |request|. |is_https| specifies if the protocol is https or not. | 133 // owned by |request|. |is_https| specifies if the protocol is https or not. |
| 130 // If a matching session already exists, this method will return OK. If no | 134 // If a matching session already exists, this method will return OK. If no |
| 131 // matching session exists, this will return ERR_IO_PENDING and will invoke | 135 // matching session exists, this will return ERR_IO_PENDING and will invoke |
| 132 // OnRequestComplete asynchronously. | 136 // OnRequestComplete asynchronously. |
| 133 int Create(const HostPortPair& host_port_pair, | 137 int Create(const HostPortPair& host_port_pair, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 144 // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_| | 148 // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_| |
| 145 // is greater than or equal to |max_number_of_lossy_connections_| then it | 149 // is greater than or equal to |max_number_of_lossy_connections_| then it |
| 146 // disables QUIC. If QUIC is disabled then it closes the connection. | 150 // disables QUIC. If QUIC is disabled then it closes the connection. |
| 147 // | 151 // |
| 148 // Returns true if QUIC is disabled for the port of the session. | 152 // Returns true if QUIC is disabled for the port of the session. |
| 149 bool OnHandshakeConfirmed(QuicClientSession* session, float packet_loss_rate); | 153 bool OnHandshakeConfirmed(QuicClientSession* session, float packet_loss_rate); |
| 150 | 154 |
| 151 // Returns true if QUIC is disabled for this port. | 155 // Returns true if QUIC is disabled for this port. |
| 152 bool IsQuicDisabled(uint16 port); | 156 bool IsQuicDisabled(uint16 port); |
| 153 | 157 |
| 158 // Returns reason QUIC is disabled for this port, or QUIC_DISABLED_NOT if not. | |
| 159 QuicDisabledReason QuicDisabledReason(uint16 port); | |
| 160 | |
| 161 // Returns reason QUIC is disabled as string for net-internals. | |
| 162 std::string QuicDisabledReasonString() const; | |
|
Ryan Hamilton
2015/07/06 18:25:41
nit: const std::string& ? (Or if that doesn't work
Buck
2015/07/06 21:39:32
going with const char*
fyi, it is used in HttpNet
| |
| 163 | |
| 154 // Called by a session when it becomes idle. | 164 // Called by a session when it becomes idle. |
| 155 void OnIdleSession(QuicClientSession* session); | 165 void OnIdleSession(QuicClientSession* session); |
| 156 | 166 |
| 157 // Called by a session when it is going away and no more streams should be | 167 // Called by a session when it is going away and no more streams should be |
| 158 // created on it. | 168 // created on it. |
| 159 void OnSessionGoingAway(QuicClientSession* session); | 169 void OnSessionGoingAway(QuicClientSession* session); |
| 160 | 170 |
| 161 // Called by a session after it shuts down. | 171 // Called by a session after it shuts down. |
| 162 void OnSessionClosed(QuicClientSession* session); | 172 void OnSessionClosed(QuicClientSession* session); |
| 163 | 173 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 typedef std::set<QuicServerId> AliasSet; | 247 typedef std::set<QuicServerId> AliasSet; |
| 238 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap; | 248 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap; |
| 239 typedef std::set<QuicClientSession*> SessionSet; | 249 typedef std::set<QuicClientSession*> SessionSet; |
| 240 typedef std::map<IpAliasKey, SessionSet> IPAliasMap; | 250 typedef std::map<IpAliasKey, SessionSet> IPAliasMap; |
| 241 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; | 251 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; |
| 242 typedef std::set<Job*> JobSet; | 252 typedef std::set<Job*> JobSet; |
| 243 typedef std::map<QuicServerId, JobSet> JobMap; | 253 typedef std::map<QuicServerId, JobSet> JobMap; |
| 244 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; | 254 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; |
| 245 typedef std::set<QuicStreamRequest*> RequestSet; | 255 typedef std::set<QuicStreamRequest*> RequestSet; |
| 246 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; | 256 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; |
| 257 typedef std::deque<enum QuicDisabledReason> DisabledReasonsQueue; | |
| 247 | 258 |
| 248 // Creates a job which doesn't wait for server config to be loaded from the | 259 // Creates a job which doesn't wait for server config to be loaded from the |
| 249 // disk cache. This job is started via a PostTask. | 260 // disk cache. This job is started via a PostTask. |
| 250 void CreateAuxilaryJob(const QuicServerId server_id, | 261 void CreateAuxilaryJob(const QuicServerId server_id, |
| 251 int cert_verify_flags, | 262 int cert_verify_flags, |
| 252 bool server_and_origin_have_same_host, | 263 bool server_and_origin_have_same_host, |
| 253 bool is_post, | 264 bool is_post, |
| 254 const BoundNetLog& net_log); | 265 const BoundNetLog& net_log); |
| 255 | 266 |
| 256 // Returns a newly created QuicHttpStream owned by the caller. | 267 // Returns a newly created QuicHttpStream owned by the caller. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 284 // Initializes the cached state associated with |server_id| in | 295 // Initializes the cached state associated with |server_id| in |
| 285 // |crypto_config_| with the information in |server_info|. | 296 // |crypto_config_| with the information in |server_info|. |
| 286 void InitializeCachedStateInCryptoConfig( | 297 void InitializeCachedStateInCryptoConfig( |
| 287 const QuicServerId& server_id, | 298 const QuicServerId& server_id, |
| 288 const scoped_ptr<QuicServerInfo>& server_info); | 299 const scoped_ptr<QuicServerInfo>& server_info); |
| 289 | 300 |
| 290 void ProcessGoingAwaySession(QuicClientSession* session, | 301 void ProcessGoingAwaySession(QuicClientSession* session, |
| 291 const QuicServerId& server_id, | 302 const QuicServerId& server_id, |
| 292 bool was_session_active); | 303 bool was_session_active); |
| 293 | 304 |
| 305 // Collect stats from epitaphs, possibly disabling Quic. | |
| 306 void MaybeDisableQuic(QuicClientSession* session); | |
| 307 | |
| 294 bool require_confirmation_; | 308 bool require_confirmation_; |
| 295 HostResolver* host_resolver_; | 309 HostResolver* host_resolver_; |
| 296 ClientSocketFactory* client_socket_factory_; | 310 ClientSocketFactory* client_socket_factory_; |
| 297 base::WeakPtr<HttpServerProperties> http_server_properties_; | 311 base::WeakPtr<HttpServerProperties> http_server_properties_; |
| 298 TransportSecurityState* transport_security_state_; | 312 TransportSecurityState* transport_security_state_; |
| 299 QuicServerInfoFactory* quic_server_info_factory_; | 313 QuicServerInfoFactory* quic_server_info_factory_; |
| 300 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; | 314 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; |
| 301 QuicRandom* random_generator_; | 315 QuicRandom* random_generator_; |
| 302 scoped_ptr<QuicClock> clock_; | 316 scoped_ptr<QuicClock> clock_; |
| 303 const size_t max_packet_length_; | 317 const size_t max_packet_length_; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 // Set if we want to disable QUIC when there is high packet loss rate. | 376 // Set if we want to disable QUIC when there is high packet loss rate. |
| 363 // Specifies the maximum number of connections with high packet loss in a row | 377 // Specifies the maximum number of connections with high packet loss in a row |
| 364 // after which QUIC will be disabled. | 378 // after which QUIC will be disabled. |
| 365 int max_number_of_lossy_connections_; | 379 int max_number_of_lossy_connections_; |
| 366 // Specifies packet loss rate in fraction after which a connection is closed | 380 // Specifies packet loss rate in fraction after which a connection is closed |
| 367 // and is considered as a lossy connection. | 381 // and is considered as a lossy connection. |
| 368 float packet_loss_threshold_; | 382 float packet_loss_threshold_; |
| 369 // Count number of lossy connections by port. | 383 // Count number of lossy connections by port. |
| 370 std::map<uint16, int> number_of_lossy_connections_; | 384 std::map<uint16, int> number_of_lossy_connections_; |
| 371 | 385 |
| 386 // Keep track of stats for recently closed connections, using a | |
| 387 // bounded queue. | |
| 388 int max_disabled_reasons_; | |
| 389 DisabledReasonsQueue disabled_reasons_; | |
| 390 // Events that can trigger disabling QUIC | |
| 391 int num_public_resets_post_handshake_; | |
| 392 int num_timeouts_with_open_streams_; | |
| 393 // Keep track the largest values for UMA histograms, that will help | |
| 394 // determine good threshold values. | |
| 395 int max_public_resets_post_handshake_; | |
| 396 int max_timeouts_with_open_streams_; | |
| 397 // Thresholds if greater than zero, determine when to | |
| 398 int threshold_timeouts_with_open_streams_; | |
| 399 int threshold_public_resets_post_handshake_; | |
| 400 | |
| 372 // Size of the UDP receive buffer. | 401 // Size of the UDP receive buffer. |
| 373 int socket_receive_buffer_size_; | 402 int socket_receive_buffer_size_; |
| 374 | 403 |
| 375 // Each profile will (probably) have a unique port_seed_ value. This value | 404 // Each profile will (probably) have a unique port_seed_ value. This value |
| 376 // is used to help seed a pseudo-random number generator (PortSuggester) so | 405 // is used to help seed a pseudo-random number generator (PortSuggester) so |
| 377 // that we consistently (within this profile) suggest the same ephemeral | 406 // that we consistently (within this profile) suggest the same ephemeral |
| 378 // port when we re-connect to any given server/port. The differences between | 407 // port when we re-connect to any given server/port. The differences between |
| 379 // profiles (probablistically) prevent two profiles from colliding in their | 408 // profiles (probablistically) prevent two profiles from colliding in their |
| 380 // ephemeral port requests. | 409 // ephemeral port requests. |
| 381 uint64 port_seed_; | 410 uint64 port_seed_; |
| 382 | 411 |
| 383 // Local address of socket that was created in CreateSession. | 412 // Local address of socket that was created in CreateSession. |
| 384 IPEndPoint local_address_; | 413 IPEndPoint local_address_; |
| 385 bool check_persisted_supports_quic_; | 414 bool check_persisted_supports_quic_; |
| 386 std::set<HostPortPair> quic_supported_servers_at_startup_; | 415 std::set<HostPortPair> quic_supported_servers_at_startup_; |
| 387 | 416 |
| 388 NetworkConnection network_connection_; | 417 NetworkConnection network_connection_; |
| 389 | 418 |
| 390 base::TaskRunner* task_runner_; | 419 base::TaskRunner* task_runner_; |
| 391 | 420 |
| 392 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 421 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
| 393 | 422 |
| 394 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 423 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
| 395 }; | 424 }; |
| 396 | 425 |
| 397 } // namespace net | 426 } // namespace net |
| 398 | 427 |
| 399 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 428 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| OLD | NEW |