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

Side by Side 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 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 #include "net/quic/quic_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 } 1105 }
1106 } 1106 }
1107 return list.Pass(); 1107 return list.Pass();
1108 } 1108 }
1109 1109
1110 void QuicStreamFactory::ClearCachedStatesInCryptoConfig() { 1110 void QuicStreamFactory::ClearCachedStatesInCryptoConfig() {
1111 crypto_config_.ClearCachedStates(); 1111 crypto_config_.ClearCachedStates();
1112 } 1112 }
1113 1113
1114 void QuicStreamFactory::OnIPAddressChanged() { 1114 void QuicStreamFactory::OnIPAddressChanged() {
1115 CloseAllSessions(ERR_NETWORK_CHANGED); 1115 // CloseAllIdleSessions(ERR_NETWORK_CHANGED);
1116 for (QuicStreamFactory::SessionIdMap::iterator it = all_sessions_.begin();
1117 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.
1118 QuicChromiumClientSession* session = it->first;
1119 QuicServerId server_id = it->second;
1120 if (session->GetNumOpenStreams() == 0) {
1121 // If idle session, close session
1122 active_sessions_.erase(server_id);
1123 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.
1124 } else {
1125 // 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.
1126 // bound to the new interface), (ii) add a new PacketReader to the
1127 // session that reads from the new socket, (iii) replace the
1128 // connection's PacketWriter with a new PacketWriter that uses the
1129 // new socket, and (iv) make the session go away.
1130 scoped_ptr<DatagramClientSocket> socket(
1131 client_socket_factory_->CreateDatagramClientSocket(
1132 DatagramSocket::DEFAULT_BIND, RandIntCallback(),
1133 // Fix net_log.source()
1134 session->net_log().net_log(), session->net_log().source()));
1135 if (!session->AddPacketReader(new QuicPacketReader(socket.get(), session,
1136 session->net_log()))) {
1137 CloseAllSessions(ERR_NETWORK_CHANGED);
1138 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
1139 continue;
1140 }
1141 session->StartReading();
1142
1143 DefaultPacketWriterFactory packet_writer_factory(socket.get());
1144 QuicConnection* connection = session->connection();
1145 connection->SetQuicPacketWriter(packet_writer_factory.Create(connection),
1146 /*owns_writer=*/true);
1147
1148 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.
1149 OnSessionGoingAway(session);
1150 }
1151 }
1116 set_require_confirmation(true); 1152 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.
1117 } 1153 }
1118 1154
1119 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { 1155 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) {
1120 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); 1156 CloseAllSessions(ERR_CERT_DATABASE_CHANGED);
1121 } 1157 }
1122 1158
1123 void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) { 1159 void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) {
1124 // We should flush the sessions if we removed trust from a 1160 // We should flush the sessions if we removed trust from a
1125 // cert, because a previously trusted server may have become 1161 // cert, because a previously trusted server may have become
1126 // untrusted. 1162 // untrusted.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 net_log.net_log(), net_log.source())); 1209 net_log.net_log(), net_log.source()));
1174 1210
1175 if (enable_non_blocking_io_ && 1211 if (enable_non_blocking_io_ &&
1176 client_socket_factory_ == ClientSocketFactory::GetDefaultFactory()) { 1212 client_socket_factory_ == ClientSocketFactory::GetDefaultFactory()) {
1177 #if defined(OS_WIN) 1213 #if defined(OS_WIN)
1178 static_cast<UDPClientSocket*>(socket.get())->UseNonBlockingIO(); 1214 static_cast<UDPClientSocket*>(socket.get())->UseNonBlockingIO();
1179 #endif 1215 #endif
1180 } 1216 }
1181 1217
1182 int rv = socket->Connect(addr); 1218 int rv = socket->Connect(addr);
1183
1184 if (rv != OK) { 1219 if (rv != OK) {
1185 HistogramCreateSessionFailure(CREATION_ERROR_CONNECTING_SOCKET); 1220 HistogramCreateSessionFailure(CREATION_ERROR_CONNECTING_SOCKET);
1186 return rv; 1221 return rv;
1187 } 1222 }
1188 UMA_HISTOGRAM_COUNTS("Net.QuicEphemeralPortsSuggested", 1223 UMA_HISTOGRAM_COUNTS("Net.QuicEphemeralPortsSuggested",
1189 port_suggester->call_count()); 1224 port_suggester->call_count());
1190 if (enable_port_selection) { 1225 if (enable_port_selection) {
1191 DCHECK_LE(1u, port_suggester->call_count()); 1226 DCHECK_LE(1u, port_suggester->call_count());
1192 } else { 1227 } else {
1193 DCHECK_EQ(0u, port_suggester->call_count()); 1228 DCHECK_EQ(0u, port_suggester->call_count());
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 // Since the session was active, there's no longer an 1438 // Since the session was active, there's no longer an
1404 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1439 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1405 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1440 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1406 // it as recently broken, which means that 0-RTT will be disabled but we'll 1441 // it as recently broken, which means that 0-RTT will be disabled but we'll
1407 // still race. 1442 // still race.
1408 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1443 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1409 alternative_service); 1444 alternative_service);
1410 } 1445 }
1411 1446
1412 } // namespace net 1447 } // namespace net
OLDNEW
« 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