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 |
| 239 // Called when device connects to |network|. For example device associates |
| 240 // with a WiFi access point. This does not imply the network has Internet |
| 241 // access as it may well be behind a captive portal. |
| 242 void OnNetworkConnected( |
| 243 NetworkChangeNotifier::NetworkHandle network) override; |
| 244 // Called when device disconnects from |network|. |
| 245 void OnNetworkDisconnected( |
| 246 NetworkChangeNotifier::NetworkHandle network) override; |
| 247 // Called when device determines the connection to |network| is no longer |
| 248 // preferred, for example when a device transitions from cellular to WiFi |
| 249 // it might deem the cellular connection no longer preferred. The device |
| 250 // will disconnect from |network| in a period of time (30s on Android), |
| 251 // allowing network communications via |network| to wrap up. |
| 252 void OnNetworkSoonToDisconnect( |
| 253 NetworkChangeNotifier::NetworkHandle network) override; |
| 254 // Called when |network| is made the default network for communication. |
| 255 void OnNetworkMadeDefault( |
| 256 NetworkChangeNotifier::NetworkHandle network) override; |
| 257 |
218 // SSLConfigService::Observer methods: | 258 // SSLConfigService::Observer methods: |
219 | 259 |
220 // We perform the same flushing as described above when SSL settings change. | 260 // We perform the same flushing as described above when SSL settings change. |
221 void OnSSLConfigChanged() override; | 261 void OnSSLConfigChanged() override; |
222 | 262 |
223 // CertDatabase::Observer methods: | 263 // CertDatabase::Observer methods: |
224 | 264 |
225 // We close all sessions when certificate database is changed. | 265 // We close all sessions when certificate database is changed. |
226 void OnCertAdded(const X509Certificate* cert) override; | 266 void OnCertAdded(const X509Certificate* cert) override; |
227 void OnCACertChanged(const X509Certificate* cert) override; | 267 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(). | 485 // QuicPacketReader::StartReading() yields by doing a PostTask(). |
446 int yield_after_packets_; | 486 int yield_after_packets_; |
447 QuicTime::Delta yield_after_duration_; | 487 QuicTime::Delta yield_after_duration_; |
448 | 488 |
449 // Set if server configs are to be stored in HttpServerProperties. | 489 // Set if server configs are to be stored in HttpServerProperties. |
450 bool store_server_configs_in_properties_; | 490 bool store_server_configs_in_properties_; |
451 | 491 |
452 // Set if all sessions should be closed when any local IP address changes. | 492 // Set if all sessions should be closed when any local IP address changes. |
453 const bool close_sessions_on_ip_change_; | 493 const bool close_sessions_on_ip_change_; |
454 | 494 |
| 495 // Set if migration should be attempted on active sessions when primary |
| 496 // interface changes. |
| 497 const bool migrate_sessions_on_network_change_; |
| 498 |
455 // Each profile will (probably) have a unique port_seed_ value. This value | 499 // 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 | 500 // is used to help seed a pseudo-random number generator (PortSuggester) so |
457 // that we consistently (within this profile) suggest the same ephemeral | 501 // that we consistently (within this profile) suggest the same ephemeral |
458 // port when we re-connect to any given server/port. The differences between | 502 // port when we re-connect to any given server/port. The differences between |
459 // profiles (probablistically) prevent two profiles from colliding in their | 503 // profiles (probablistically) prevent two profiles from colliding in their |
460 // ephemeral port requests. | 504 // ephemeral port requests. |
461 uint64_t port_seed_; | 505 uint64_t port_seed_; |
462 | 506 |
463 // Local address of socket that was created in CreateSession. | 507 // Local address of socket that was created in CreateSession. |
464 IPEndPoint local_address_; | 508 IPEndPoint local_address_; |
465 bool check_persisted_supports_quic_; | 509 bool check_persisted_supports_quic_; |
466 bool has_initialized_data_; | 510 bool has_initialized_data_; |
467 std::set<HostPortPair> quic_supported_servers_at_startup_; | 511 std::set<HostPortPair> quic_supported_servers_at_startup_; |
468 | 512 |
469 NetworkConnection network_connection_; | 513 NetworkConnection network_connection_; |
470 | 514 |
471 base::TaskRunner* task_runner_; | 515 base::TaskRunner* task_runner_; |
472 | 516 |
473 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 517 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
474 | 518 |
475 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 519 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
476 }; | 520 }; |
477 | 521 |
478 } // namespace net | 522 } // namespace net |
479 | 523 |
480 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 524 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |