| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 CompletionCallback callback_; | 104 CompletionCallback callback_; |
| 105 scoped_ptr<QuicHttpStream> stream_; | 105 scoped_ptr<QuicHttpStream> stream_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); | 107 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 // A factory for creating new QuicHttpStreams on top of a pool of | 110 // A factory for creating new QuicHttpStreams on top of a pool of |
| 111 // QuicChromiumClientSessions. | 111 // QuicChromiumClientSessions. |
| 112 class NET_EXPORT_PRIVATE QuicStreamFactory | 112 class NET_EXPORT_PRIVATE QuicStreamFactory |
| 113 : public NetworkChangeNotifier::IPAddressObserver, | 113 : public NetworkChangeNotifier::IPAddressObserver, |
| 114 public NetworkChangeNotifier::NetworkObserver, |
| 114 public SSLConfigService::Observer, | 115 public SSLConfigService::Observer, |
| 115 public CertDatabase::Observer { | 116 public CertDatabase::Observer { |
| 116 public: | 117 public: |
| 117 QuicStreamFactory( | 118 QuicStreamFactory( |
| 118 HostResolver* host_resolver, | 119 HostResolver* host_resolver, |
| 119 ClientSocketFactory* client_socket_factory, | 120 ClientSocketFactory* client_socket_factory, |
| 120 base::WeakPtr<HttpServerProperties> http_server_properties, | 121 base::WeakPtr<HttpServerProperties> http_server_properties, |
| 121 CertVerifier* cert_verifier, | 122 CertVerifier* cert_verifier, |
| 122 CertPolicyEnforcer* cert_policy_enforcer, | 123 CertPolicyEnforcer* cert_policy_enforcer, |
| 123 ChannelIDService* channel_id_service, | 124 ChannelIDService* channel_id_service, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 141 int max_number_of_lossy_connections, | 142 int max_number_of_lossy_connections, |
| 142 float packet_loss_threshold, | 143 float packet_loss_threshold, |
| 143 int max_recent_disabled_reasons, | 144 int max_recent_disabled_reasons, |
| 144 int threshold_timeouts_with_streams_open, | 145 int threshold_timeouts_with_streams_open, |
| 145 int threshold_public_resets_post_handshake, | 146 int threshold_public_resets_post_handshake, |
| 146 int socket_receive_buffer_size, | 147 int socket_receive_buffer_size, |
| 147 bool delay_tcp_race, | 148 bool delay_tcp_race, |
| 148 bool store_server_configs_in_properties, | 149 bool store_server_configs_in_properties, |
| 149 bool close_sessions_on_ip_change, | 150 bool close_sessions_on_ip_change, |
| 150 int idle_connection_timeout_seconds, | 151 int idle_connection_timeout_seconds, |
| 152 bool migrate_sessions_on_network_change, |
| 151 const QuicTagVector& connection_options); | 153 const QuicTagVector& connection_options); |
| 152 ~QuicStreamFactory() override; | 154 ~QuicStreamFactory() override; |
| 153 | 155 |
| 154 // Creates a new QuicHttpStream to |host_port_pair| which will be | 156 // Creates a new QuicHttpStream to |host_port_pair| which will be |
| 155 // owned by |request|. | 157 // owned by |request|. |
| 156 // If a matching session already exists, this method will return OK. If no | 158 // If a matching session already exists, this method will return OK. If no |
| 157 // matching session exists, this will return ERR_IO_PENDING and will invoke | 159 // matching session exists, this will return ERR_IO_PENDING and will invoke |
| 158 // OnRequestComplete asynchronously. | 160 // OnRequestComplete asynchronously. |
| 159 int Create(const HostPortPair& host_port_pair, | 161 int Create(const HostPortPair& host_port_pair, |
| 160 PrivacyMode privacy_mode, | 162 PrivacyMode privacy_mode, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 196 |
| 195 // Called by a session after it shuts down. | 197 // Called by a session after it shuts down. |
| 196 void OnSessionClosed(QuicChromiumClientSession* session); | 198 void OnSessionClosed(QuicChromiumClientSession* session); |
| 197 | 199 |
| 198 // Called by a session whose connection has timed out. | 200 // Called by a session whose connection has timed out. |
| 199 void OnSessionConnectTimeout(QuicChromiumClientSession* session); | 201 void OnSessionConnectTimeout(QuicChromiumClientSession* session); |
| 200 | 202 |
| 201 // Cancels a pending request. | 203 // Cancels a pending request. |
| 202 void CancelRequest(QuicStreamRequest* request); | 204 void CancelRequest(QuicStreamRequest* request); |
| 203 | 205 |
| 204 // Closes all current sessions. | 206 // Closes all current sessions with specified network and QUIC error codes. |
| 205 void CloseAllSessions(int error); | 207 void CloseAllSessions(int error, QuicErrorCode quic_error); |
| 206 | 208 |
| 207 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const; | 209 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const; |
| 208 | 210 |
| 209 // Delete all cached state objects in |crypto_config_|. | 211 // Delete all cached state objects in |crypto_config_|. |
| 210 void ClearCachedStatesInCryptoConfig(); | 212 void ClearCachedStatesInCryptoConfig(); |
| 211 | 213 |
| 214 // Helper method that configures a DatagramClientSocket. Socket is |
| 215 // bound to the default network if the |network| param is |
| 216 // NetworkChangeNotifier::kInvalidNetworkHandle. |
| 217 // Returns net_error code. |
| 218 int ConfigureSocket(DatagramClientSocket* socket, |
| 219 IPEndPoint addr, |
| 220 NetworkChangeNotifier::NetworkHandle network); |
| 221 |
| 222 // Helper method that initiates migration of active sessions |
| 223 // currently bound to |network| to an alternate network, if one |
| 224 // exists. Idle sessions bound to |network| are closed. If there is |
| 225 // no alternate network to migrate active sessions onto, active |
| 226 // sessions are closed if |force_close| is true, and continue using |
| 227 // |network| otherwise. Sessions not bound to |network| are left unchanged. |
| 228 void MaybeMigrateOrCloseSessions(NetworkChangeNotifier::NetworkHandle network, |
| 229 bool force_close); |
| 230 |
| 212 // NetworkChangeNotifier::IPAddressObserver methods: | 231 // NetworkChangeNotifier::IPAddressObserver methods: |
| 213 | 232 |
| 214 // Until the servers support roaming, close all connections when the local | 233 // Until the servers support roaming, close all connections when the local |
| 215 // IP address changes. | 234 // IP address changes. |
| 216 void OnIPAddressChanged() override; | 235 void OnIPAddressChanged() override; |
| 217 | 236 |
| 237 // NetworkChangeNotifier::NetworkObserver methods: |
| 238 void OnNetworkConnected( |
| 239 NetworkChangeNotifier::NetworkHandle network) override; |
| 240 void OnNetworkDisconnected( |
| 241 NetworkChangeNotifier::NetworkHandle network) override; |
| 242 void OnNetworkSoonToDisconnect( |
| 243 NetworkChangeNotifier::NetworkHandle network) override; |
| 244 void OnNetworkMadeDefault( |
| 245 NetworkChangeNotifier::NetworkHandle network) override; |
| 246 |
| 218 // SSLConfigService::Observer methods: | 247 // SSLConfigService::Observer methods: |
| 219 | 248 |
| 220 // We perform the same flushing as described above when SSL settings change. | 249 // We perform the same flushing as described above when SSL settings change. |
| 221 void OnSSLConfigChanged() override; | 250 void OnSSLConfigChanged() override; |
| 222 | 251 |
| 223 // CertDatabase::Observer methods: | 252 // CertDatabase::Observer methods: |
| 224 | 253 |
| 225 // We close all sessions when certificate database is changed. | 254 // We close all sessions when certificate database is changed. |
| 226 void OnCertAdded(const X509Certificate* cert) override; | 255 void OnCertAdded(const X509Certificate* cert) override; |
| 227 void OnCACertChanged(const X509Certificate* cert) override; | 256 void OnCACertChanged(const X509Certificate* cert) override; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 // QuicPacketReader::StartReading() yields by doing a PostTask(). | 474 // QuicPacketReader::StartReading() yields by doing a PostTask(). |
| 446 int yield_after_packets_; | 475 int yield_after_packets_; |
| 447 QuicTime::Delta yield_after_duration_; | 476 QuicTime::Delta yield_after_duration_; |
| 448 | 477 |
| 449 // Set if server configs are to be stored in HttpServerProperties. | 478 // Set if server configs are to be stored in HttpServerProperties. |
| 450 bool store_server_configs_in_properties_; | 479 bool store_server_configs_in_properties_; |
| 451 | 480 |
| 452 // Set if all sessions should be closed when any local IP address changes. | 481 // Set if all sessions should be closed when any local IP address changes. |
| 453 const bool close_sessions_on_ip_change_; | 482 const bool close_sessions_on_ip_change_; |
| 454 | 483 |
| 484 // Set if migration should be attempted on active sessions when primary |
| 485 // interface changes. |
| 486 const bool migrate_sessions_on_network_change_; |
| 487 |
| 455 // Each profile will (probably) have a unique port_seed_ value. This value | 488 // Each profile will (probably) have a unique port_seed_ value. This value |
| 456 // is used to help seed a pseudo-random number generator (PortSuggester) so | 489 // is used to help seed a pseudo-random number generator (PortSuggester) so |
| 457 // that we consistently (within this profile) suggest the same ephemeral | 490 // that we consistently (within this profile) suggest the same ephemeral |
| 458 // port when we re-connect to any given server/port. The differences between | 491 // port when we re-connect to any given server/port. The differences between |
| 459 // profiles (probablistically) prevent two profiles from colliding in their | 492 // profiles (probablistically) prevent two profiles from colliding in their |
| 460 // ephemeral port requests. | 493 // ephemeral port requests. |
| 461 uint64_t port_seed_; | 494 uint64_t port_seed_; |
| 462 | 495 |
| 463 // Local address of socket that was created in CreateSession. | 496 // Local address of socket that was created in CreateSession. |
| 464 IPEndPoint local_address_; | 497 IPEndPoint local_address_; |
| 465 bool check_persisted_supports_quic_; | 498 bool check_persisted_supports_quic_; |
| 466 bool has_initialized_data_; | 499 bool has_initialized_data_; |
| 467 std::set<HostPortPair> quic_supported_servers_at_startup_; | 500 std::set<HostPortPair> quic_supported_servers_at_startup_; |
| 468 | 501 |
| 469 NetworkConnection network_connection_; | 502 NetworkConnection network_connection_; |
| 470 | 503 |
| 471 base::TaskRunner* task_runner_; | 504 base::TaskRunner* task_runner_; |
| 472 | 505 |
| 473 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 506 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
| 474 | 507 |
| 475 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 508 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
| 476 }; | 509 }; |
| 477 | 510 |
| 478 } // namespace net | 511 } // namespace net |
| 479 | 512 |
| 480 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 513 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| OLD | NEW |