| 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_client_session.h" |
| 23 #include "net/quic/quic_config.h" | 24 #include "net/quic/quic_config.h" |
| 24 #include "net/quic/quic_crypto_stream.h" | 25 #include "net/quic/quic_crypto_stream.h" |
| 25 #include "net/quic/quic_http_stream.h" | 26 #include "net/quic/quic_http_stream.h" |
| 26 #include "net/quic/quic_protocol.h" | 27 #include "net/quic/quic_protocol.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; |
| (...skipping 81 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_recent_disabled_reasons, |
| 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 QuicClientSession::QuicDisabledReason QuicDisabledReason(uint16 port) const; |
| 160 |
| 161 // Returns reason QUIC is disabled as string for net-internals, or |
| 162 // returns empty string if QUIC is not disabled. |
| 163 const char* QuicDisabledReasonString() const; |
| 164 |
| 154 // Called by a session when it becomes idle. | 165 // Called by a session when it becomes idle. |
| 155 void OnIdleSession(QuicClientSession* session); | 166 void OnIdleSession(QuicClientSession* session); |
| 156 | 167 |
| 157 // Called by a session when it is going away and no more streams should be | 168 // Called by a session when it is going away and no more streams should be |
| 158 // created on it. | 169 // created on it. |
| 159 void OnSessionGoingAway(QuicClientSession* session); | 170 void OnSessionGoingAway(QuicClientSession* session); |
| 160 | 171 |
| 161 // Called by a session after it shuts down. | 172 // Called by a session after it shuts down. |
| 162 void OnSessionClosed(QuicClientSession* session); | 173 void OnSessionClosed(QuicClientSession* session); |
| 163 | 174 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 typedef std::set<QuicServerId> AliasSet; | 248 typedef std::set<QuicServerId> AliasSet; |
| 238 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap; | 249 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap; |
| 239 typedef std::set<QuicClientSession*> SessionSet; | 250 typedef std::set<QuicClientSession*> SessionSet; |
| 240 typedef std::map<IpAliasKey, SessionSet> IPAliasMap; | 251 typedef std::map<IpAliasKey, SessionSet> IPAliasMap; |
| 241 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; | 252 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; |
| 242 typedef std::set<Job*> JobSet; | 253 typedef std::set<Job*> JobSet; |
| 243 typedef std::map<QuicServerId, JobSet> JobMap; | 254 typedef std::map<QuicServerId, JobSet> JobMap; |
| 244 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; | 255 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; |
| 245 typedef std::set<QuicStreamRequest*> RequestSet; | 256 typedef std::set<QuicStreamRequest*> RequestSet; |
| 246 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; | 257 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; |
| 258 typedef std::deque<enum QuicClientSession::QuicDisabledReason> |
| 259 DisabledReasonsQueue; |
| 247 | 260 |
| 248 // Creates a job which doesn't wait for server config to be loaded from the | 261 // 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. | 262 // disk cache. This job is started via a PostTask. |
| 250 void CreateAuxilaryJob(const QuicServerId server_id, | 263 void CreateAuxilaryJob(const QuicServerId server_id, |
| 251 int cert_verify_flags, | 264 int cert_verify_flags, |
| 252 bool server_and_origin_have_same_host, | 265 bool server_and_origin_have_same_host, |
| 253 bool is_post, | 266 bool is_post, |
| 254 const BoundNetLog& net_log); | 267 const BoundNetLog& net_log); |
| 255 | 268 |
| 256 // Returns a newly created QuicHttpStream owned by the caller. | 269 // 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 | 297 // Initializes the cached state associated with |server_id| in |
| 285 // |crypto_config_| with the information in |server_info|. | 298 // |crypto_config_| with the information in |server_info|. |
| 286 void InitializeCachedStateInCryptoConfig( | 299 void InitializeCachedStateInCryptoConfig( |
| 287 const QuicServerId& server_id, | 300 const QuicServerId& server_id, |
| 288 const scoped_ptr<QuicServerInfo>& server_info); | 301 const scoped_ptr<QuicServerInfo>& server_info); |
| 289 | 302 |
| 290 void ProcessGoingAwaySession(QuicClientSession* session, | 303 void ProcessGoingAwaySession(QuicClientSession* session, |
| 291 const QuicServerId& server_id, | 304 const QuicServerId& server_id, |
| 292 bool was_session_active); | 305 bool was_session_active); |
| 293 | 306 |
| 307 // Collect stats from recent connections, possibly disabling Quic. |
| 308 void MaybeDisableQuic(QuicClientSession* session); |
| 309 |
| 294 bool require_confirmation_; | 310 bool require_confirmation_; |
| 295 HostResolver* host_resolver_; | 311 HostResolver* host_resolver_; |
| 296 ClientSocketFactory* client_socket_factory_; | 312 ClientSocketFactory* client_socket_factory_; |
| 297 base::WeakPtr<HttpServerProperties> http_server_properties_; | 313 base::WeakPtr<HttpServerProperties> http_server_properties_; |
| 298 TransportSecurityState* transport_security_state_; | 314 TransportSecurityState* transport_security_state_; |
| 299 QuicServerInfoFactory* quic_server_info_factory_; | 315 QuicServerInfoFactory* quic_server_info_factory_; |
| 300 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; | 316 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; |
| 301 QuicRandom* random_generator_; | 317 QuicRandom* random_generator_; |
| 302 scoped_ptr<QuicClock> clock_; | 318 scoped_ptr<QuicClock> clock_; |
| 303 const size_t max_packet_length_; | 319 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. | 378 // 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 | 379 // Specifies the maximum number of connections with high packet loss in a row |
| 364 // after which QUIC will be disabled. | 380 // after which QUIC will be disabled. |
| 365 int max_number_of_lossy_connections_; | 381 int max_number_of_lossy_connections_; |
| 366 // Specifies packet loss rate in fraction after which a connection is closed | 382 // Specifies packet loss rate in fraction after which a connection is closed |
| 367 // and is considered as a lossy connection. | 383 // and is considered as a lossy connection. |
| 368 float packet_loss_threshold_; | 384 float packet_loss_threshold_; |
| 369 // Count number of lossy connections by port. | 385 // Count number of lossy connections by port. |
| 370 std::map<uint16, int> number_of_lossy_connections_; | 386 std::map<uint16, int> number_of_lossy_connections_; |
| 371 | 387 |
| 388 // Keep track of stats for recently closed connections, using a |
| 389 // bounded queue. |
| 390 int max_disabled_reasons_; |
| 391 DisabledReasonsQueue disabled_reasons_; |
| 392 // Events that can trigger disabling QUIC |
| 393 int num_public_resets_post_handshake_; |
| 394 int num_timeouts_with_open_streams_; |
| 395 // Keep track the largest values for UMA histograms, that will help |
| 396 // determine good threshold values. |
| 397 int max_public_resets_post_handshake_; |
| 398 int max_timeouts_with_open_streams_; |
| 399 // Thresholds if greater than zero, determine when to |
| 400 int threshold_timeouts_with_open_streams_; |
| 401 int threshold_public_resets_post_handshake_; |
| 402 |
| 372 // Size of the UDP receive buffer. | 403 // Size of the UDP receive buffer. |
| 373 int socket_receive_buffer_size_; | 404 int socket_receive_buffer_size_; |
| 374 | 405 |
| 375 // Each profile will (probably) have a unique port_seed_ value. This value | 406 // 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 | 407 // is used to help seed a pseudo-random number generator (PortSuggester) so |
| 377 // that we consistently (within this profile) suggest the same ephemeral | 408 // that we consistently (within this profile) suggest the same ephemeral |
| 378 // port when we re-connect to any given server/port. The differences between | 409 // port when we re-connect to any given server/port. The differences between |
| 379 // profiles (probablistically) prevent two profiles from colliding in their | 410 // profiles (probablistically) prevent two profiles from colliding in their |
| 380 // ephemeral port requests. | 411 // ephemeral port requests. |
| 381 uint64 port_seed_; | 412 uint64 port_seed_; |
| 382 | 413 |
| 383 // Local address of socket that was created in CreateSession. | 414 // Local address of socket that was created in CreateSession. |
| 384 IPEndPoint local_address_; | 415 IPEndPoint local_address_; |
| 385 bool check_persisted_supports_quic_; | 416 bool check_persisted_supports_quic_; |
| 386 std::set<HostPortPair> quic_supported_servers_at_startup_; | 417 std::set<HostPortPair> quic_supported_servers_at_startup_; |
| 387 | 418 |
| 388 NetworkConnection network_connection_; | 419 NetworkConnection network_connection_; |
| 389 | 420 |
| 390 base::TaskRunner* task_runner_; | 421 base::TaskRunner* task_runner_; |
| 391 | 422 |
| 392 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 423 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
| 393 | 424 |
| 394 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 425 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
| 395 }; | 426 }; |
| 396 | 427 |
| 397 } // namespace net | 428 } // namespace net |
| 398 | 429 |
| 399 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 430 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| OLD | NEW |