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> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 CompletionCallback callback_; | 96 CompletionCallback callback_; |
97 scoped_ptr<QuicHttpStream> stream_; | 97 scoped_ptr<QuicHttpStream> stream_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); | 99 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); |
100 }; | 100 }; |
101 | 101 |
102 // A factory for creating new QuicHttpStreams on top of a pool of | 102 // A factory for creating new QuicHttpStreams on top of a pool of |
103 // QuicChromiumClientSessions. | 103 // QuicChromiumClientSessions. |
104 class NET_EXPORT_PRIVATE QuicStreamFactory | 104 class NET_EXPORT_PRIVATE QuicStreamFactory |
105 : public NetworkChangeNotifier::IPAddressObserver, | 105 : public NetworkChangeNotifier::IPAddressObserver, |
| 106 public NetworkChangeNotifier::NetworkObserver, |
106 public SSLConfigService::Observer, | 107 public SSLConfigService::Observer, |
107 public CertDatabase::Observer { | 108 public CertDatabase::Observer { |
108 public: | 109 public: |
109 QuicStreamFactory( | 110 QuicStreamFactory( |
110 HostResolver* host_resolver, | 111 HostResolver* host_resolver, |
111 ClientSocketFactory* client_socket_factory, | 112 ClientSocketFactory* client_socket_factory, |
112 base::WeakPtr<HttpServerProperties> http_server_properties, | 113 base::WeakPtr<HttpServerProperties> http_server_properties, |
113 CertVerifier* cert_verifier, | 114 CertVerifier* cert_verifier, |
114 CertPolicyEnforcer* cert_policy_enforcer, | 115 CertPolicyEnforcer* cert_policy_enforcer, |
115 ChannelIDService* channel_id_service, | 116 ChannelIDService* channel_id_service, |
(...skipping 15 matching lines...) Expand all Loading... |
131 bool prefer_aes, | 132 bool prefer_aes, |
132 int max_number_of_lossy_connections, | 133 int max_number_of_lossy_connections, |
133 float packet_loss_threshold, | 134 float packet_loss_threshold, |
134 int max_recent_disabled_reasons, | 135 int max_recent_disabled_reasons, |
135 int threshold_timeouts_with_streams_open, | 136 int threshold_timeouts_with_streams_open, |
136 int threshold_public_resets_post_handshake, | 137 int threshold_public_resets_post_handshake, |
137 int socket_receive_buffer_size, | 138 int socket_receive_buffer_size, |
138 bool delay_tcp_race, | 139 bool delay_tcp_race, |
139 bool store_server_configs_in_properties, | 140 bool store_server_configs_in_properties, |
140 bool close_sessions_on_ip_change, | 141 bool close_sessions_on_ip_change, |
| 142 bool migrate_sessions_on_network_change, |
141 const QuicTagVector& connection_options); | 143 const QuicTagVector& connection_options); |
142 ~QuicStreamFactory() override; | 144 ~QuicStreamFactory() override; |
143 | 145 |
144 // Creates a new QuicHttpStream to |host_port_pair| which will be | 146 // Creates a new QuicHttpStream to |host_port_pair| which will be |
145 // owned by |request|. | 147 // owned by |request|. |
146 // If a matching session already exists, this method will return OK. If no | 148 // If a matching session already exists, this method will return OK. If no |
147 // matching session exists, this will return ERR_IO_PENDING and will invoke | 149 // matching session exists, this will return ERR_IO_PENDING and will invoke |
148 // OnRequestComplete asynchronously. | 150 // OnRequestComplete asynchronously. |
149 int Create(const HostPortPair& host_port_pair, | 151 int Create(const HostPortPair& host_port_pair, |
150 PrivacyMode privacy_mode, | 152 PrivacyMode privacy_mode, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 void CancelRequest(QuicStreamRequest* request); | 194 void CancelRequest(QuicStreamRequest* request); |
193 | 195 |
194 // Closes all current sessions. | 196 // Closes all current sessions. |
195 void CloseAllSessions(int error); | 197 void CloseAllSessions(int error); |
196 | 198 |
197 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const; | 199 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const; |
198 | 200 |
199 // Delete all cached state objects in |crypto_config_|. | 201 // Delete all cached state objects in |crypto_config_|. |
200 void ClearCachedStatesInCryptoConfig(); | 202 void ClearCachedStatesInCryptoConfig(); |
201 | 203 |
| 204 // Helper method that creates and returns a DatagramClientSocket. |
| 205 scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
| 206 const QuicServerId& server_id, |
| 207 const BoundNetLog& net_log); |
| 208 |
| 209 // Helper method that configures a DatagramClientSocket. |
| 210 // Returns net_error code. |
| 211 int ConfigureDatagramClientSocket( |
| 212 DatagramClientSocket* socket, |
| 213 IPEndPoint addr, |
| 214 NetworkChangeNotifier::NetworkHandle network); |
| 215 |
| 216 // Helper method that initiates migration of active sessions away from |
| 217 // |network| if possible, and if not, closes them. Migration is only |
| 218 // attempted on active sessions; idle sessions are closed. |
| 219 void MigrateOrCloseSessions(NetworkChangeNotifier::NetworkHandle); |
| 220 |
202 // NetworkChangeNotifier::IPAddressObserver methods: | 221 // NetworkChangeNotifier::IPAddressObserver methods: |
203 | 222 |
204 // Until the servers support roaming, close all connections when the local | 223 // Until the servers support roaming, close all connections when the local |
205 // IP address changes. | 224 // IP address changes. |
206 void OnIPAddressChanged() override; | 225 void OnIPAddressChanged() override; |
207 | 226 |
| 227 // NetworkChangeNotifier::NetworkObserver methods: |
| 228 void OnNetworkConnected( |
| 229 NetworkChangeNotifier::NetworkHandle network) override; |
| 230 void OnNetworkDisconnected( |
| 231 NetworkChangeNotifier::NetworkHandle network) override; |
| 232 void OnNetworkSoonToDisconnect( |
| 233 NetworkChangeNotifier::NetworkHandle network) override; |
| 234 void OnNetworkMadeDefault( |
| 235 NetworkChangeNotifier::NetworkHandle network) override; |
| 236 |
208 // SSLConfigService::Observer methods: | 237 // SSLConfigService::Observer methods: |
209 | 238 |
210 // We perform the same flushing as described above when SSL settings change. | 239 // We perform the same flushing as described above when SSL settings change. |
211 void OnSSLConfigChanged() override; | 240 void OnSSLConfigChanged() override; |
212 | 241 |
213 // CertDatabase::Observer methods: | 242 // CertDatabase::Observer methods: |
214 | 243 |
215 // We close all sessions when certificate database is changed. | 244 // We close all sessions when certificate database is changed. |
216 void OnCertAdded(const X509Certificate* cert) override; | 245 void OnCertAdded(const X509Certificate* cert) override; |
217 void OnCACertChanged(const X509Certificate* cert) override; | 246 void OnCACertChanged(const X509Certificate* cert) override; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 // QuicPacketReader::StartReading() yields by doing a PostTask(). | 463 // QuicPacketReader::StartReading() yields by doing a PostTask(). |
435 int yield_after_packets_; | 464 int yield_after_packets_; |
436 QuicTime::Delta yield_after_duration_; | 465 QuicTime::Delta yield_after_duration_; |
437 | 466 |
438 // Set if server configs are to be stored in HttpServerProperties. | 467 // Set if server configs are to be stored in HttpServerProperties. |
439 bool store_server_configs_in_properties_; | 468 bool store_server_configs_in_properties_; |
440 | 469 |
441 // Set if all sessions should be closed when any local IP address changes. | 470 // Set if all sessions should be closed when any local IP address changes. |
442 const bool close_sessions_on_ip_change_; | 471 const bool close_sessions_on_ip_change_; |
443 | 472 |
| 473 // Set if migration should be attempted on active sessions when primary |
| 474 // interface changes. |
| 475 const bool migrate_sessions_on_network_change_; |
| 476 |
444 // Each profile will (probably) have a unique port_seed_ value. This value | 477 // Each profile will (probably) have a unique port_seed_ value. This value |
445 // is used to help seed a pseudo-random number generator (PortSuggester) so | 478 // is used to help seed a pseudo-random number generator (PortSuggester) so |
446 // that we consistently (within this profile) suggest the same ephemeral | 479 // that we consistently (within this profile) suggest the same ephemeral |
447 // port when we re-connect to any given server/port. The differences between | 480 // port when we re-connect to any given server/port. The differences between |
448 // profiles (probablistically) prevent two profiles from colliding in their | 481 // profiles (probablistically) prevent two profiles from colliding in their |
449 // ephemeral port requests. | 482 // ephemeral port requests. |
450 uint64 port_seed_; | 483 uint64 port_seed_; |
451 | 484 |
452 // Local address of socket that was created in CreateSession. | 485 // Local address of socket that was created in CreateSession. |
453 IPEndPoint local_address_; | 486 IPEndPoint local_address_; |
454 bool check_persisted_supports_quic_; | 487 bool check_persisted_supports_quic_; |
455 bool has_initialized_data_; | 488 bool has_initialized_data_; |
456 std::set<HostPortPair> quic_supported_servers_at_startup_; | 489 std::set<HostPortPair> quic_supported_servers_at_startup_; |
457 | 490 |
458 NetworkConnection network_connection_; | 491 NetworkConnection network_connection_; |
459 | 492 |
460 base::TaskRunner* task_runner_; | 493 base::TaskRunner* task_runner_; |
461 | 494 |
462 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 495 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
463 | 496 |
464 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 497 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
465 }; | 498 }; |
466 | 499 |
467 } // namespace net | 500 } // namespace net |
468 | 501 |
469 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 502 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |