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