Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: net/quic/quic_stream_factory.h

Issue 1327923002: Migrates QUIC sessions to a new network when old network is (about to be) disconnected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@home
Patch Set: Addressed comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 CompletionCallback callback_; 99 CompletionCallback callback_;
100 scoped_ptr<QuicHttpStream> stream_; 100 scoped_ptr<QuicHttpStream> stream_;
101 101
102 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest); 102 DISALLOW_COPY_AND_ASSIGN(QuicStreamRequest);
103 }; 103 };
104 104
105 // A factory for creating new QuicHttpStreams on top of a pool of 105 // A factory for creating new QuicHttpStreams on top of a pool of
106 // QuicChromiumClientSessions. 106 // QuicChromiumClientSessions.
107 class NET_EXPORT_PRIVATE QuicStreamFactory 107 class NET_EXPORT_PRIVATE QuicStreamFactory
108 : public NetworkChangeNotifier::IPAddressObserver, 108 : public NetworkChangeNotifier::IPAddressObserver,
109 public NetworkChangeNotifier::NetworkObserver,
109 public SSLConfigService::Observer, 110 public SSLConfigService::Observer,
110 public CertDatabase::Observer { 111 public CertDatabase::Observer {
111 public: 112 public:
112 QuicStreamFactory( 113 QuicStreamFactory(
113 HostResolver* host_resolver, 114 HostResolver* host_resolver,
114 ClientSocketFactory* client_socket_factory, 115 ClientSocketFactory* client_socket_factory,
115 base::WeakPtr<HttpServerProperties> http_server_properties, 116 base::WeakPtr<HttpServerProperties> http_server_properties,
116 CertVerifier* cert_verifier, 117 CertVerifier* cert_verifier,
117 CertPolicyEnforcer* cert_policy_enforcer, 118 CertPolicyEnforcer* cert_policy_enforcer,
118 ChannelIDService* channel_id_service, 119 ChannelIDService* channel_id_service,
(...skipping 15 matching lines...) Expand all
134 bool prefer_aes, 135 bool prefer_aes,
135 int max_number_of_lossy_connections, 136 int max_number_of_lossy_connections,
136 float packet_loss_threshold, 137 float packet_loss_threshold,
137 int max_recent_disabled_reasons, 138 int max_recent_disabled_reasons,
138 int threshold_timeouts_with_streams_open, 139 int threshold_timeouts_with_streams_open,
139 int threshold_public_resets_post_handshake, 140 int threshold_public_resets_post_handshake,
140 int socket_receive_buffer_size, 141 int socket_receive_buffer_size,
141 bool delay_tcp_race, 142 bool delay_tcp_race,
142 bool store_server_configs_in_properties, 143 bool store_server_configs_in_properties,
143 bool close_sessions_on_ip_change, 144 bool close_sessions_on_ip_change,
145 bool migrate_sessions_on_net_change,
144 const QuicTagVector& connection_options); 146 const QuicTagVector& connection_options);
145 ~QuicStreamFactory() override; 147 ~QuicStreamFactory() override;
146 148
147 // Creates a new QuicHttpStream to |host_port_pair| which will be 149 // Creates a new QuicHttpStream to |host_port_pair| which will be
148 // owned by |request|. |is_https| specifies if the protocol is https or not. 150 // owned by |request|. |is_https| specifies if the protocol is https or not.
149 // If a matching session already exists, this method will return OK. If no 151 // If a matching session already exists, this method will return OK. If no
150 // matching session exists, this will return ERR_IO_PENDING and will invoke 152 // matching session exists, this will return ERR_IO_PENDING and will invoke
151 // OnRequestComplete asynchronously. 153 // OnRequestComplete asynchronously.
152 int Create(const HostPortPair& host_port_pair, 154 int Create(const HostPortPair& host_port_pair,
153 bool is_https, 155 bool is_https,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 void CancelRequest(QuicStreamRequest* request); 198 void CancelRequest(QuicStreamRequest* request);
197 199
198 // Closes all current sessions. 200 // Closes all current sessions.
199 void CloseAllSessions(int error); 201 void CloseAllSessions(int error);
200 202
201 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const; 203 scoped_ptr<base::Value> QuicStreamFactoryInfoToValue() const;
202 204
203 // Delete all cached state objects in |crypto_config_|. 205 // Delete all cached state objects in |crypto_config_|.
204 void ClearCachedStatesInCryptoConfig(); 206 void ClearCachedStatesInCryptoConfig();
205 207
208 // Helper method that creates and returns a DatagramClientSocket.
209 scoped_ptr<DatagramClientSocket>
210 CreateDatagramClientSocket(const QuicServerId& server_id,
211 const BoundNetLog& net_log);
212
213 // Helper method that configures a DatagramClientSocket.
214 // Returns net_error code.
215 int ConfigureDatagramClientSocket(DatagramClientSocket* socket,
216 IPEndPoint addr,
217 NetworkChangeNotifier::NetworkHandle
218 network);
219
220 // Helper method that initiates migration of active sessions away from
221 // |network| if possible, and if not, closes them. Migration is only
222 // attempted on active sessions; idle sessions are closed.
223 void MigrateOrCloseSessions(NetworkChangeNotifier::NetworkHandle);
224
206 // NetworkChangeNotifier::IPAddressObserver methods: 225 // NetworkChangeNotifier::IPAddressObserver methods:
207 226
208 // Until the servers support roaming, close all connections when the local 227 // Until the servers support roaming, close all connections when the local
209 // IP address changes. 228 // IP address changes.
210 void OnIPAddressChanged() override; 229 void OnIPAddressChanged() override;
211 230
231 // NetworkChangeNotifier::NetworkObserver methods:
232 void OnNetworkConnected(NetworkChangeNotifier::NetworkHandle network)
233 override;
234 void OnNetworkDisconnected(NetworkChangeNotifier::NetworkHandle network)
235 override;
236 void OnNetworkSoonToDisconnect(NetworkChangeNotifier::NetworkHandle network)
237 override;
238 void OnNetworkMadeDefault(NetworkChangeNotifier::NetworkHandle network)
239 override;
240
212 // SSLConfigService::Observer methods: 241 // SSLConfigService::Observer methods:
213 242
214 // We perform the same flushing as described above when SSL settings change. 243 // We perform the same flushing as described above when SSL settings change.
215 void OnSSLConfigChanged() override; 244 void OnSSLConfigChanged() override;
216 245
217 // CertDatabase::Observer methods: 246 // CertDatabase::Observer methods:
218 247
219 // We close all sessions when certificate database is changed. 248 // We close all sessions when certificate database is changed.
220 void OnCertAdded(const X509Certificate* cert) override; 249 void OnCertAdded(const X509Certificate* cert) override;
221 void OnCACertChanged(const X509Certificate* cert) override; 250 void OnCACertChanged(const X509Certificate* cert) override;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 int yield_after_packets_; 483 int yield_after_packets_;
455 QuicTime::Delta yield_after_duration_; 484 QuicTime::Delta yield_after_duration_;
456 485
457 // Set if server configs are to be stored in HttpServerProperties. 486 // Set if server configs are to be stored in HttpServerProperties.
458 bool store_server_configs_in_properties_; 487 bool store_server_configs_in_properties_;
459 488
460 // Set if sessions should be closed when the IP address of the primary 489 // Set if sessions should be closed when the IP address of the primary
461 // interface changes. 490 // interface changes.
462 const bool close_sessions_on_ip_change_; 491 const bool close_sessions_on_ip_change_;
463 492
493 // Set if migration should be attempted on active sessions when primary
494 // interface changes.
495 const bool migrate_sessions_on_net_change_;
496
464 // Each profile will (probably) have a unique port_seed_ value. This value 497 // Each profile will (probably) have a unique port_seed_ value. This value
465 // is used to help seed a pseudo-random number generator (PortSuggester) so 498 // is used to help seed a pseudo-random number generator (PortSuggester) so
466 // that we consistently (within this profile) suggest the same ephemeral 499 // that we consistently (within this profile) suggest the same ephemeral
467 // port when we re-connect to any given server/port. The differences between 500 // port when we re-connect to any given server/port. The differences between
468 // profiles (probablistically) prevent two profiles from colliding in their 501 // profiles (probablistically) prevent two profiles from colliding in their
469 // ephemeral port requests. 502 // ephemeral port requests.
470 uint64 port_seed_; 503 uint64 port_seed_;
471 504
472 // Local address of socket that was created in CreateSession. 505 // Local address of socket that was created in CreateSession.
473 IPEndPoint local_address_; 506 IPEndPoint local_address_;
474 bool check_persisted_supports_quic_; 507 bool check_persisted_supports_quic_;
475 bool has_initialized_data_; 508 bool has_initialized_data_;
476 std::set<HostPortPair> quic_supported_servers_at_startup_; 509 std::set<HostPortPair> quic_supported_servers_at_startup_;
477 510
478 NetworkConnection network_connection_; 511 NetworkConnection network_connection_;
479 512
480 base::TaskRunner* task_runner_; 513 base::TaskRunner* task_runner_;
481 514
482 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; 515 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
483 516
484 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); 517 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
485 }; 518 };
486 519
487 } // namespace net 520 } // namespace net
488 521
489 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ 522 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698