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 ConfigureDatagramClientSocket( | |
Ryan Hamilton
2015/12/29 05:29:36
nit: I think you can omit "DatagramClient" from th
Jana
2016/01/06 23:01:17
Done.
| |
219 DatagramClientSocket* socket, | |
220 IPEndPoint addr, | |
221 NetworkChangeNotifier::NetworkHandle network); | |
222 | |
223 // Helper method that initiates migration of active sessions | |
224 // currently bound to |network| to an alternate network, if one | |
225 // exists. Idle sessions bound to |network| are closed. If there is | |
226 // no alternate network to migrate active sessions onto, active | |
227 // sessions are closed if |force_close| is true, and continue using | |
228 // |network| otherwise. Sessions not bound to |network| are left unchanged. | |
229 void MaybeMigrateOrCloseSessions(NetworkChangeNotifier::NetworkHandle network, | |
230 bool force_close); | |
231 | |
212 // NetworkChangeNotifier::IPAddressObserver methods: | 232 // NetworkChangeNotifier::IPAddressObserver methods: |
213 | 233 |
214 // Until the servers support roaming, close all connections when the local | 234 // Until the servers support roaming, close all connections when the local |
215 // IP address changes. | 235 // IP address changes. |
216 void OnIPAddressChanged() override; | 236 void OnIPAddressChanged() override; |
217 | 237 |
238 // NetworkChangeNotifier::NetworkObserver methods: | |
239 void OnNetworkConnected( | |
240 NetworkChangeNotifier::NetworkHandle network) override; | |
241 void OnNetworkDisconnected( | |
242 NetworkChangeNotifier::NetworkHandle network) override; | |
243 void OnNetworkSoonToDisconnect( | |
244 NetworkChangeNotifier::NetworkHandle network) override; | |
245 void OnNetworkMadeDefault( | |
246 NetworkChangeNotifier::NetworkHandle network) override; | |
247 | |
218 // SSLConfigService::Observer methods: | 248 // SSLConfigService::Observer methods: |
219 | 249 |
220 // We perform the same flushing as described above when SSL settings change. | 250 // We perform the same flushing as described above when SSL settings change. |
221 void OnSSLConfigChanged() override; | 251 void OnSSLConfigChanged() override; |
222 | 252 |
223 // CertDatabase::Observer methods: | 253 // CertDatabase::Observer methods: |
224 | 254 |
225 // We close all sessions when certificate database is changed. | 255 // We close all sessions when certificate database is changed. |
226 void OnCertAdded(const X509Certificate* cert) override; | 256 void OnCertAdded(const X509Certificate* cert) override; |
227 void OnCACertChanged(const X509Certificate* cert) override; | 257 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(). | 475 // QuicPacketReader::StartReading() yields by doing a PostTask(). |
446 int yield_after_packets_; | 476 int yield_after_packets_; |
447 QuicTime::Delta yield_after_duration_; | 477 QuicTime::Delta yield_after_duration_; |
448 | 478 |
449 // Set if server configs are to be stored in HttpServerProperties. | 479 // Set if server configs are to be stored in HttpServerProperties. |
450 bool store_server_configs_in_properties_; | 480 bool store_server_configs_in_properties_; |
451 | 481 |
452 // Set if all sessions should be closed when any local IP address changes. | 482 // Set if all sessions should be closed when any local IP address changes. |
453 const bool close_sessions_on_ip_change_; | 483 const bool close_sessions_on_ip_change_; |
454 | 484 |
485 // Set if migration should be attempted on active sessions when primary | |
486 // interface changes. | |
487 const bool migrate_sessions_on_network_change_; | |
488 | |
455 // Each profile will (probably) have a unique port_seed_ value. This value | 489 // 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 | 490 // is used to help seed a pseudo-random number generator (PortSuggester) so |
457 // that we consistently (within this profile) suggest the same ephemeral | 491 // that we consistently (within this profile) suggest the same ephemeral |
458 // port when we re-connect to any given server/port. The differences between | 492 // port when we re-connect to any given server/port. The differences between |
459 // profiles (probablistically) prevent two profiles from colliding in their | 493 // profiles (probablistically) prevent two profiles from colliding in their |
460 // ephemeral port requests. | 494 // ephemeral port requests. |
461 uint64_t port_seed_; | 495 uint64_t port_seed_; |
462 | 496 |
463 // Local address of socket that was created in CreateSession. | 497 // Local address of socket that was created in CreateSession. |
464 IPEndPoint local_address_; | 498 IPEndPoint local_address_; |
465 bool check_persisted_supports_quic_; | 499 bool check_persisted_supports_quic_; |
466 bool has_initialized_data_; | 500 bool has_initialized_data_; |
467 std::set<HostPortPair> quic_supported_servers_at_startup_; | 501 std::set<HostPortPair> quic_supported_servers_at_startup_; |
468 | 502 |
469 NetworkConnection network_connection_; | 503 NetworkConnection network_connection_; |
470 | 504 |
471 base::TaskRunner* task_runner_; | 505 base::TaskRunner* task_runner_; |
472 | 506 |
473 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 507 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
474 | 508 |
475 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 509 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
476 }; | 510 }; |
477 | 511 |
478 } // namespace net | 512 } // namespace net |
479 | 513 |
480 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 514 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |