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

Unified Diff: net/quic/quic_stream_factory.cc

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: Fixed StartReading method Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/quic_stream_factory.cc
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index d3bf9de857fb7449ab46be24987c93778e4938a2..10f67dab241d17887134665b3542a445a3ac3362 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -1112,7 +1112,43 @@ void QuicStreamFactory::ClearCachedStatesInCryptoConfig() {
}
void QuicStreamFactory::OnIPAddressChanged() {
- CloseAllSessions(ERR_NETWORK_CHANGED);
+ // CloseAllIdleSessions(ERR_NETWORK_CHANGED);
+ for (QuicStreamFactory::SessionIdMap::iterator it = all_sessions_.begin();
+ it != all_sessions_.end(); ++it) {
Ryan Hamilton 2015/09/08 04:09:38 Can you do a C++11 range loop here?
Jana 2015/11/17 01:50:09 Done.
+ QuicChromiumClientSession* session = it->first;
+ QuicServerId server_id = it->second;
+ if (session->GetNumOpenStreams() == 0) {
+ // If idle session, close session
+ active_sessions_.erase(server_id);
+ session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR);
Ryan Hamilton 2015/09/08 04:09:38 not sure about INTERNAL_ERROR nit: add a continue
Jana 2015/11/17 01:50:09 Done.
+ } else {
+ // If session is active, (i) create a new socket (which should be
Ryan Hamilton 2015/09/08 04:09:38 nit: s/is active/has active streams/
Jana 2015/11/17 01:50:09 Done.
+ // bound to the new interface), (ii) add a new PacketReader to the
+ // session that reads from the new socket, (iii) replace the
+ // connection's PacketWriter with a new PacketWriter that uses the
+ // new socket, and (iv) make the session go away.
+ scoped_ptr<DatagramClientSocket> socket(
+ client_socket_factory_->CreateDatagramClientSocket(
+ DatagramSocket::DEFAULT_BIND, RandIntCallback(),
+ // Fix net_log.source()
+ session->net_log().net_log(), session->net_log().source()));
+ if (!session->AddPacketReader(new QuicPacketReader(socket.get(), session,
+ session->net_log()))) {
+ CloseAllSessions(ERR_NETWORK_CHANGED);
+ set_require_confirmation(true);
Ryan Hamilton 2015/09/08 04:09:38 Is this required?
Jana 2015/11/17 01:50:08 We've not verified this new network, and while it
+ continue;
+ }
+ session->StartReading();
+
+ DefaultPacketWriterFactory packet_writer_factory(socket.get());
+ QuicConnection* connection = session->connection();
+ connection->SetQuicPacketWriter(packet_writer_factory.Create(connection),
+ /*owns_writer=*/true);
+
+ session->AddSocket(socket.Pass());
Ryan Hamilton 2015/09/08 04:09:38 Yeah, probably a single method which takes Socket,
Jana 2015/11/17 01:50:09 Done. PTAL.
+ OnSessionGoingAway(session);
+ }
+ }
set_require_confirmation(true);
Ryan Hamilton 2015/09/08 04:09:38 Might as well do this before the for loop since it
Jana 2015/11/17 01:50:09 Done.
}
@@ -1180,7 +1216,6 @@ int QuicStreamFactory::CreateSession(const QuicServerId& server_id,
}
int rv = socket->Connect(addr);
-
if (rv != OK) {
HistogramCreateSessionFailure(CREATION_ERROR_CONNECTING_SOCKET);
return rv;
« net/quic/quic_chromium_client_session.cc ('K') | « net/quic/quic_chromium_client_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698