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 #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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 bool prefer_aes, | 562 bool prefer_aes, |
563 int max_number_of_lossy_connections, | 563 int max_number_of_lossy_connections, |
564 float packet_loss_threshold, | 564 float packet_loss_threshold, |
565 int max_disabled_reasons, | 565 int max_disabled_reasons, |
566 int threshold_public_resets_post_handshake, | 566 int threshold_public_resets_post_handshake, |
567 int threshold_timeouts_with_open_streams, | 567 int threshold_timeouts_with_open_streams, |
568 int socket_receive_buffer_size, | 568 int socket_receive_buffer_size, |
569 bool delay_tcp_race, | 569 bool delay_tcp_race, |
570 bool store_server_configs_in_properties, | 570 bool store_server_configs_in_properties, |
571 bool close_sessions_on_ip_change, | 571 bool close_sessions_on_ip_change, |
572 bool migrate_sessions_on_network_change, | |
572 const QuicTagVector& connection_options) | 573 const QuicTagVector& connection_options) |
573 : require_confirmation_(true), | 574 : require_confirmation_(true), |
574 host_resolver_(host_resolver), | 575 host_resolver_(host_resolver), |
575 client_socket_factory_(client_socket_factory), | 576 client_socket_factory_(client_socket_factory), |
576 http_server_properties_(http_server_properties), | 577 http_server_properties_(http_server_properties), |
577 transport_security_state_(transport_security_state), | 578 transport_security_state_(transport_security_state), |
578 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 579 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
579 random_generator_(random_generator), | 580 random_generator_(random_generator), |
580 clock_(clock), | 581 clock_(clock), |
581 max_packet_length_(max_packet_length), | 582 max_packet_length_(max_packet_length), |
(...skipping 24 matching lines...) Expand all Loading... | |
606 threshold_timeouts_with_open_streams), | 607 threshold_timeouts_with_open_streams), |
607 threshold_public_resets_post_handshake_( | 608 threshold_public_resets_post_handshake_( |
608 threshold_public_resets_post_handshake), | 609 threshold_public_resets_post_handshake), |
609 socket_receive_buffer_size_(socket_receive_buffer_size), | 610 socket_receive_buffer_size_(socket_receive_buffer_size), |
610 delay_tcp_race_(delay_tcp_race), | 611 delay_tcp_race_(delay_tcp_race), |
611 yield_after_packets_(kQuicYieldAfterPacketsRead), | 612 yield_after_packets_(kQuicYieldAfterPacketsRead), |
612 yield_after_duration_(QuicTime::Delta::FromMilliseconds( | 613 yield_after_duration_(QuicTime::Delta::FromMilliseconds( |
613 kQuicYieldAfterDurationMilliseconds)), | 614 kQuicYieldAfterDurationMilliseconds)), |
614 store_server_configs_in_properties_(store_server_configs_in_properties), | 615 store_server_configs_in_properties_(store_server_configs_in_properties), |
615 close_sessions_on_ip_change_(close_sessions_on_ip_change), | 616 close_sessions_on_ip_change_(close_sessions_on_ip_change), |
617 migrate_sessions_on_network_change_(migrate_sessions_on_network_change), | |
616 port_seed_(random_generator_->RandUint64()), | 618 port_seed_(random_generator_->RandUint64()), |
617 check_persisted_supports_quic_(true), | 619 check_persisted_supports_quic_(true), |
618 has_initialized_data_(false), | 620 has_initialized_data_(false), |
619 task_runner_(nullptr), | 621 task_runner_(nullptr), |
620 weak_factory_(this) { | 622 weak_factory_(this) { |
621 DCHECK(transport_security_state_); | 623 DCHECK(transport_security_state_); |
622 DCHECK(http_server_properties_); | 624 DCHECK(http_server_properties_); |
623 crypto_config_.set_user_agent_id(user_agent_id); | 625 crypto_config_.set_user_agent_id(user_agent_id); |
624 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 626 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
625 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 627 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
(...skipping 18 matching lines...) Expand all Loading... | |
644 if (!IsEcdsaSupported()) | 646 if (!IsEcdsaSupported()) |
645 crypto_config_.DisableEcdsa(); | 647 crypto_config_.DisableEcdsa(); |
646 // When disk cache is used to store the server configs, HttpCache code calls | 648 // When disk cache is used to store the server configs, HttpCache code calls |
647 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't | 649 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't |
648 // created. | 650 // created. |
649 if (store_server_configs_in_properties_) { | 651 if (store_server_configs_in_properties_) { |
650 quic_server_info_factory_.reset( | 652 quic_server_info_factory_.reset( |
651 new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); | 653 new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); |
652 } | 654 } |
653 | 655 |
656 #if defined(OS_ANDROID) | |
657 // Migration only implemented for Android versions >= L. | |
658 // TODO (jri): Maybe move this to NetworkChangeNotifier, as a | |
659 // IsSupported (or some such) method. | |
660 if (migrate_sessions_on_network_change_ && | |
661 base::android::BuildInfo::GetInstance()->sdk_int() >= | |
662 base::android::SDK_VERSION_LOLLIPOP) { | |
663 NetworkChangeNotifier::AddNetworkObserver(this); | |
664 } else if (close_sessions_on_ip_change_) { | |
665 NetworkChangeNotifier::AddIPAddressObserver(this); | |
666 } | |
667 #else | |
654 if (close_sessions_on_ip_change_) { | 668 if (close_sessions_on_ip_change_) { |
655 NetworkChangeNotifier::AddIPAddressObserver(this); | 669 NetworkChangeNotifier::AddIPAddressObserver(this); |
656 } | 670 } |
671 #endif | |
657 } | 672 } |
658 | 673 |
659 QuicStreamFactory::~QuicStreamFactory() { | 674 QuicStreamFactory::~QuicStreamFactory() { |
660 CloseAllSessions(ERR_ABORTED); | 675 CloseAllSessions(ERR_ABORTED); |
661 while (!all_sessions_.empty()) { | 676 while (!all_sessions_.empty()) { |
662 delete all_sessions_.begin()->first; | 677 delete all_sessions_.begin()->first; |
663 all_sessions_.erase(all_sessions_.begin()); | 678 all_sessions_.erase(all_sessions_.begin()); |
664 } | 679 } |
665 while (!active_jobs_.empty()) { | 680 while (!active_jobs_.empty()) { |
666 const QuicServerId server_id = active_jobs_.begin()->first; | 681 const QuicServerId server_id = active_jobs_.begin()->first; |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1124 list->Append(session->GetInfoAsValue(hosts)); | 1139 list->Append(session->GetInfoAsValue(hosts)); |
1125 } | 1140 } |
1126 } | 1141 } |
1127 return list.Pass(); | 1142 return list.Pass(); |
1128 } | 1143 } |
1129 | 1144 |
1130 void QuicStreamFactory::ClearCachedStatesInCryptoConfig() { | 1145 void QuicStreamFactory::ClearCachedStatesInCryptoConfig() { |
1131 crypto_config_.ClearCachedStates(); | 1146 crypto_config_.ClearCachedStates(); |
1132 } | 1147 } |
1133 | 1148 |
1149 // We still need OnIPAddressChanged, but not for Android >= L. | |
1150 // pauljensen: How do we do this? | |
1134 void QuicStreamFactory::OnIPAddressChanged() { | 1151 void QuicStreamFactory::OnIPAddressChanged() { |
1135 CloseAllSessions(ERR_NETWORK_CHANGED); | 1152 CloseAllSessions(ERR_NETWORK_CHANGED); |
1136 set_require_confirmation(true); | 1153 set_require_confirmation(true); |
1137 } | 1154 } |
1138 | 1155 |
1156 void QuicStreamFactory::OnNetworkConnected( | |
1157 NetworkChangeNotifier::NetworkHandle network) { | |
1158 // Nothing to do. | |
Ryan Hamilton
2015/11/18 22:23:36
I'm not sure that this comment adds any value.
| |
1159 } | |
1160 | |
1161 void QuicStreamFactory::OnNetworkMadeDefault( | |
1162 NetworkChangeNotifier::NetworkHandle network) { | |
1163 // Nothing to do. | |
1164 } | |
1165 | |
1166 void QuicStreamFactory::OnNetworkDisconnected( | |
1167 NetworkChangeNotifier::NetworkHandle network) { | |
1168 MigrateOrCloseSessions(network); | |
1169 } | |
1170 | |
1171 void QuicStreamFactory::OnNetworkSoonToDisconnect( | |
1172 NetworkChangeNotifier::NetworkHandle network) { | |
1173 MigrateOrCloseSessions(network); | |
1174 } | |
1175 | |
1176 void QuicStreamFactory::MigrateOrCloseSessions( | |
1177 NetworkChangeNotifier::NetworkHandle network) { | |
1178 // TODO(jri): Need a "verified" flag on each network that gets set when | |
1179 // any data is received on the network. | |
1180 set_require_confirmation(true); | |
1181 | |
1182 // pauljensen: do we need the following "== network" check? | |
1183 NetworkChangeNotifier::NetworkList network_list; | |
1184 NetworkChangeNotifier::GetConnectedNetworks(&network_list); | |
1185 if (network_list.empty() || | |
1186 (network_list.size() == 1 && network_list[0] == network)) { | |
1187 CloseAllSessions(ERR_NETWORK_CHANGED); | |
1188 return; | |
1189 } | |
1190 | |
1191 // Find a new network that old sockets can be migrated to. | |
1192 // pauljensen: do we need the following "== network" check? | |
1193 NetworkChangeNotifier::NetworkHandle new_network = | |
1194 NetworkChangeNotifier::kInvalidNetworkHandle; | |
1195 for (NetworkChangeNotifier::NetworkHandle n : network_list) { | |
1196 if (n == network) { | |
1197 continue; | |
1198 } | |
1199 new_network = n; | |
1200 } | |
1201 | |
1202 DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, new_network); | |
1203 DCHECK_NE(network, new_network); | |
Ryan Hamilton
2015/11/18 22:23:36
It looks like these DCHECKs are needed because of
Jana
2015/11/21 02:21:22
Good suggestion -- there was definitely redundant
| |
1204 | |
1205 for (auto& it : all_sessions_) { | |
1206 QuicChromiumClientSession* session = it.first; | |
1207 QuicServerId server_id = it.second; | |
1208 | |
1209 if (session->GetNumOpenStreams() == 0) { | |
1210 // If idle session, close session | |
1211 active_sessions_.erase(server_id); | |
1212 // TODO(jri): Add new error for QUIC connection migration. | |
1213 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); | |
Ryan Hamilton
2015/11/18 22:23:36
CloseSessionOnError causes the session to be remov
Jana
2015/11/21 02:21:22
Ah, ok, I see that now. Removed.
| |
1214 // } else if (session->current_network() == new_network) { | |
1215 // @@@ TODO (jri): store network and record in session when | |
1216 // BindToNetwork() is called. | |
1217 // If session is already using |network|, move on. | |
1218 // continue; | |
Ryan Hamilton
2015/11/18 22:23:36
What's up with this code?
Jana
2015/11/21 02:21:22
Cleaned it up some and added a method in session t
| |
1219 continue; | |
1220 } | |
1221 // If session has active streams, | |
1222 // (i) make the session GO_AWAY, | |
1223 // (ii) create a new socket (which should be bound to the new interface), | |
1224 // (iii) migrate the session to using the new socket. | |
1225 OnSessionGoingAway(session); | |
Ryan Hamilton
2015/11/18 22:23:36
I wonder if you want to send a GOAWAY as well?
Jana
2015/11/21 02:21:22
Why? We won't sent any more requests to the server
| |
1226 QuicConnection* connection = session->connection(); | |
1227 scoped_ptr<DatagramClientSocket> socket = | |
1228 CreateDatagramClientSocket(all_sessions_[session], session->net_log()); | |
Ryan Hamilton
2015/11/18 22:23:36
instead of all_sessions_[session] can you call ses
Jana
2015/11/21 02:21:22
Ah! Didn't know that existed. Done.
| |
1229 int rv = ConfigureDatagramClientSocket(socket.get(), | |
1230 connection->peer_address(), network); | |
Ryan Hamilton
2015/11/18 22:23:36
It looks like both places this method is called is
Jana
2015/11/21 02:21:22
I had it together first (some earlier rev) but I n
| |
1231 if (rv != OK) { | |
Ryan Hamilton
2015/11/18 22:23:36
nit: no need to store rv in a variable if it's not
Jana
2015/11/21 02:21:22
Done.
| |
1232 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); | |
1233 continue; | |
1234 } | |
1235 scoped_ptr<QuicPacketReader> new_reader(new QuicPacketReader( | |
1236 socket.get(), clock_.get(), session, yield_after_packets_, | |
1237 yield_after_duration_, session->net_log())); | |
1238 DefaultPacketWriterFactory packet_writer_factory(socket.get()); | |
1239 scoped_ptr<QuicPacketWriter> new_writer( | |
1240 packet_writer_factory.Create(connection)); | |
1241 | |
1242 if (!session->MigrateToSocket(socket.Pass(), new_reader.Pass(), | |
1243 new_writer.Pass())) { | |
1244 // TODO (jri): Log this as a different ERROR. | |
1245 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); | |
1246 } | |
1247 } | |
1248 } | |
1249 | |
1139 void QuicStreamFactory::OnSSLConfigChanged() { | 1250 void QuicStreamFactory::OnSSLConfigChanged() { |
1140 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); | 1251 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); |
1141 } | 1252 } |
1142 | 1253 |
1143 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { | 1254 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { |
1144 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); | 1255 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); |
1145 } | 1256 } |
1146 | 1257 |
1147 void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) { | 1258 void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) { |
1148 // We should flush the sessions if we removed trust from a | 1259 // We should flush the sessions if we removed trust from a |
(...skipping 13 matching lines...) Expand all Loading... | |
1162 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() check. | 1273 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() check. |
1163 if (active_sessions_.empty()) | 1274 if (active_sessions_.empty()) |
1164 return false; | 1275 return false; |
1165 return ContainsKey(active_sessions_, server_id); | 1276 return ContainsKey(active_sessions_, server_id); |
1166 } | 1277 } |
1167 | 1278 |
1168 bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const { | 1279 bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const { |
1169 return ContainsKey(active_jobs_, key); | 1280 return ContainsKey(active_jobs_, key); |
1170 } | 1281 } |
1171 | 1282 |
1172 int QuicStreamFactory::CreateSession(const QuicServerId& server_id, | 1283 scoped_ptr<DatagramClientSocket> QuicStreamFactory::CreateDatagramClientSocket( |
1173 int cert_verify_flags, | 1284 const QuicServerId& server_id, |
1174 scoped_ptr<QuicServerInfo> server_info, | 1285 const BoundNetLog& net_log) { |
1175 const AddressList& address_list, | |
1176 base::TimeTicks dns_resolution_end_time, | |
1177 const BoundNetLog& net_log, | |
1178 QuicChromiumClientSession** session) { | |
1179 bool enable_port_selection = enable_port_selection_; | 1286 bool enable_port_selection = enable_port_selection_; |
1180 if (enable_port_selection && | 1287 if (enable_port_selection && |
1181 ContainsKey(gone_away_aliases_, server_id)) { | 1288 ContainsKey(gone_away_aliases_, server_id)) { |
1182 // Disable port selection when the server is going away. | 1289 // Disable port selection when the server is going away. |
1183 // There is no point in trying to return to the same server, if | 1290 // There is no point in trying to return to the same server, if |
1184 // that server is no longer handling requests. | 1291 // that server is no longer handling requests. |
1185 enable_port_selection = false; | 1292 enable_port_selection = false; |
1186 gone_away_aliases_.erase(server_id); | 1293 gone_away_aliases_.erase(server_id); |
1187 } | 1294 } |
1188 | |
1189 QuicConnectionId connection_id = random_generator_->RandUint64(); | |
1190 IPEndPoint addr = *address_list.begin(); | |
1191 scoped_refptr<PortSuggester> port_suggester = | 1295 scoped_refptr<PortSuggester> port_suggester = |
1192 new PortSuggester(server_id.host_port_pair(), port_seed_); | 1296 new PortSuggester(server_id.host_port_pair(), port_seed_); |
1193 DatagramSocket::BindType bind_type = enable_port_selection ? | 1297 DatagramSocket::BindType bind_type = enable_port_selection ? |
1194 DatagramSocket::RANDOM_BIND : // Use our callback. | 1298 DatagramSocket::RANDOM_BIND : // Use our callback. |
1195 DatagramSocket::DEFAULT_BIND; // Use OS to randomize. | 1299 DatagramSocket::DEFAULT_BIND; // Use OS to randomize. |
1300 | |
1196 scoped_ptr<DatagramClientSocket> socket( | 1301 scoped_ptr<DatagramClientSocket> socket( |
1197 client_socket_factory_->CreateDatagramClientSocket( | 1302 client_socket_factory_->CreateDatagramClientSocket( |
1198 bind_type, | 1303 bind_type, |
1199 base::Bind(&PortSuggester::SuggestPort, port_suggester), | 1304 base::Bind(&PortSuggester::SuggestPort, port_suggester), |
1200 net_log.net_log(), net_log.source())); | 1305 net_log.net_log(), net_log.source())); |
1201 | 1306 |
1307 UMA_HISTOGRAM_COUNTS("Net.QuicEphemeralPortsSuggested", | |
1308 port_suggester->call_count()); | |
1309 if (enable_port_selection) { | |
1310 DCHECK_LE(1u, port_suggester->call_count()); | |
1311 } else { | |
1312 DCHECK_EQ(0u, port_suggester->call_count()); | |
1313 } | |
1314 | |
1315 return socket; | |
1316 } | |
1317 | |
1318 int QuicStreamFactory::ConfigureDatagramClientSocket( | |
1319 DatagramClientSocket* socket, | |
1320 IPEndPoint addr, | |
1321 NetworkChangeNotifier::NetworkHandle network) { | |
1202 if (enable_non_blocking_io_ && | 1322 if (enable_non_blocking_io_ && |
1203 client_socket_factory_ == ClientSocketFactory::GetDefaultFactory()) { | 1323 client_socket_factory_ == ClientSocketFactory::GetDefaultFactory()) { |
1204 #if defined(OS_WIN) | 1324 #if defined(OS_WIN) |
1205 static_cast<UDPClientSocket*>(socket.get())->UseNonBlockingIO(); | 1325 static_cast<UDPClientSocket*>(socket.get())->UseNonBlockingIO(); |
1206 #endif | 1326 #endif |
1207 } | 1327 } |
1208 | 1328 |
1209 int rv = socket->Connect(addr); | 1329 // If caller leaves network unspecified, find current default. |
1330 int rv; | |
1331 if (network == NetworkChangeNotifier::kInvalidNetworkHandle) { | |
1332 rv = socket->BindToDefaultNetwork(); | |
1333 } else { | |
1334 rv = socket->BindToNetwork(network); | |
1335 } | |
1336 if (rv != OK) { | |
1337 return rv; | |
1338 } | |
1210 | 1339 |
1340 rv = socket->Connect(addr); | |
1211 if (rv != OK) { | 1341 if (rv != OK) { |
1212 HistogramCreateSessionFailure(CREATION_ERROR_CONNECTING_SOCKET); | 1342 HistogramCreateSessionFailure(CREATION_ERROR_CONNECTING_SOCKET); |
1213 return rv; | 1343 return rv; |
1214 } | 1344 } |
1215 UMA_HISTOGRAM_COUNTS("Net.QuicEphemeralPortsSuggested", | |
1216 port_suggester->call_count()); | |
1217 if (enable_port_selection) { | |
1218 DCHECK_LE(1u, port_suggester->call_count()); | |
1219 } else { | |
1220 DCHECK_EQ(0u, port_suggester->call_count()); | |
1221 } | |
1222 | 1345 |
1223 rv = socket->SetReceiveBufferSize(socket_receive_buffer_size_); | 1346 rv = socket->SetReceiveBufferSize(socket_receive_buffer_size_); |
1224 if (rv != OK) { | 1347 if (rv != OK) { |
1225 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_RECEIVE_BUFFER); | 1348 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_RECEIVE_BUFFER); |
1226 return rv; | 1349 return rv; |
1227 } | 1350 } |
1351 | |
1228 // Set a buffer large enough to contain the initial CWND's worth of packet | 1352 // Set a buffer large enough to contain the initial CWND's worth of packet |
1229 // to work around the problem with CHLO packets being sent out with the | 1353 // to work around the problem with CHLO packets being sent out with the |
1230 // wrong encryption level, when the send buffer is full. | 1354 // wrong encryption level, when the send buffer is full. |
1231 rv = socket->SetSendBufferSize(kMaxPacketSize * 20); | 1355 rv = socket->SetSendBufferSize(kMaxPacketSize * 20); |
1232 if (rv != OK) { | 1356 if (rv != OK) { |
1233 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); | 1357 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); |
1234 return rv; | 1358 return rv; |
1235 } | 1359 } |
1236 | 1360 |
1237 socket->GetLocalAddress(&local_address_); | 1361 socket->GetLocalAddress(&local_address_); |
1238 if (check_persisted_supports_quic_) { | 1362 if (check_persisted_supports_quic_) { |
1239 check_persisted_supports_quic_ = false; | 1363 check_persisted_supports_quic_ = false; |
1240 IPAddressNumber last_address; | 1364 IPAddressNumber last_address; |
1241 if (http_server_properties_->GetSupportsQuic(&last_address) && | 1365 if (http_server_properties_->GetSupportsQuic(&last_address) && |
1242 last_address == local_address_.address()) { | 1366 last_address == local_address_.address()) { |
1243 require_confirmation_ = false; | 1367 require_confirmation_ = false; |
1244 } | 1368 } |
1245 } | 1369 } |
1246 | 1370 |
1371 return OK; | |
1372 } | |
1373 | |
1374 int QuicStreamFactory::CreateSession(const QuicServerId& server_id, | |
1375 int cert_verify_flags, | |
1376 scoped_ptr<QuicServerInfo> server_info, | |
1377 const AddressList& address_list, | |
1378 base::TimeTicks dns_resolution_end_time, | |
1379 const BoundNetLog& net_log, | |
1380 QuicChromiumClientSession** session) { | |
1381 IPEndPoint addr = *address_list.begin(); | |
1382 | |
1383 scoped_ptr<DatagramClientSocket> socket = | |
1384 CreateDatagramClientSocket(server_id, net_log); | |
1385 | |
1386 int rv = ConfigureDatagramClientSocket( | |
1387 socket.get(), addr, NetworkChangeNotifier::kInvalidNetworkHandle); | |
Ryan Hamilton
2015/11/18 22:23:36
PLease add a comment here about using an "invalid"
Jana
2015/11/21 02:21:22
added a comment here and in the .h declaration of
| |
1388 | |
1389 if (rv != OK) { | |
1390 return rv; | |
1391 } | |
1392 | |
1247 DefaultPacketWriterFactory packet_writer_factory(socket.get()); | 1393 DefaultPacketWriterFactory packet_writer_factory(socket.get()); |
1248 | |
1249 if (!helper_.get()) { | 1394 if (!helper_.get()) { |
1250 helper_.reset( | 1395 helper_.reset( |
1251 new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(), | 1396 new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(), |
1252 clock_.get(), random_generator_)); | 1397 clock_.get(), random_generator_)); |
1253 } | 1398 } |
1254 | 1399 |
1400 QuicConnectionId connection_id = random_generator_->RandUint64(); | |
1255 QuicConnection* connection = new QuicConnection( | 1401 QuicConnection* connection = new QuicConnection( |
1256 connection_id, addr, helper_.get(), packet_writer_factory, | 1402 connection_id, addr, helper_.get(), packet_writer_factory, |
1257 true /* owns_writer */, Perspective::IS_CLIENT, supported_versions_); | 1403 true /* owns_writer */, Perspective::IS_CLIENT, supported_versions_); |
1258 connection->SetMaxPacketLength(max_packet_length_); | 1404 connection->SetMaxPacketLength(max_packet_length_); |
1259 | 1405 |
1260 InitializeCachedStateInCryptoConfig(server_id, server_info); | 1406 InitializeCachedStateInCryptoConfig(server_id, server_info); |
1261 | 1407 |
1262 QuicConfig config = config_; | 1408 QuicConfig config = config_; |
1263 config.SetSocketReceiveBufferToSend(socket_receive_buffer_size_); | 1409 config.SetSocketReceiveBufferToSend(socket_receive_buffer_size_); |
1264 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); | 1410 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1448 // Since the session was active, there's no longer an | 1594 // Since the session was active, there's no longer an |
1449 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1595 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
1450 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1596 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
1451 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1597 // it as recently broken, which means that 0-RTT will be disabled but we'll |
1452 // still race. | 1598 // still race. |
1453 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1599 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
1454 alternative_service); | 1600 alternative_service); |
1455 } | 1601 } |
1456 | 1602 |
1457 } // namespace net | 1603 } // namespace net |
OLD | NEW |