Chromium Code Reviews| 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_net_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_net_change_(migrate_sessions_on_net_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 |
| 654 if (close_sessions_on_ip_change_) { | 656 if (migrate_sessions_on_net_change_) { |
| 657 NetworkChangeNotifier::AddNetworkObserver(this); | |
| 658 } else if (close_sessions_on_ip_change_) { | |
| 655 NetworkChangeNotifier::AddIPAddressObserver(this); | 659 NetworkChangeNotifier::AddIPAddressObserver(this); |
|
Ryan Hamilton
2015/11/17 04:57:28
So if migrate_ is true, then is close_ effectively
Jana
2015/11/18 04:31:41
Yes, since migrate_ and close_ are both experiment
| |
| 656 } | 660 } |
| 657 } | 661 } |
| 658 | 662 |
| 659 QuicStreamFactory::~QuicStreamFactory() { | 663 QuicStreamFactory::~QuicStreamFactory() { |
| 660 CloseAllSessions(ERR_ABORTED); | 664 CloseAllSessions(ERR_ABORTED); |
| 661 while (!all_sessions_.empty()) { | 665 while (!all_sessions_.empty()) { |
| 662 delete all_sessions_.begin()->first; | 666 delete all_sessions_.begin()->first; |
| 663 all_sessions_.erase(all_sessions_.begin()); | 667 all_sessions_.erase(all_sessions_.begin()); |
| 664 } | 668 } |
| 665 while (!active_jobs_.empty()) { | 669 while (!active_jobs_.empty()) { |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1124 list->Append(session->GetInfoAsValue(hosts)); | 1128 list->Append(session->GetInfoAsValue(hosts)); |
| 1125 } | 1129 } |
| 1126 } | 1130 } |
| 1127 return list.Pass(); | 1131 return list.Pass(); |
| 1128 } | 1132 } |
| 1129 | 1133 |
| 1130 void QuicStreamFactory::ClearCachedStatesInCryptoConfig() { | 1134 void QuicStreamFactory::ClearCachedStatesInCryptoConfig() { |
| 1131 crypto_config_.ClearCachedStates(); | 1135 crypto_config_.ClearCachedStates(); |
| 1132 } | 1136 } |
| 1133 | 1137 |
| 1138 // We still need OnIPAddressChanged, but not for Android >= L. | |
| 1139 // pauljensen: How do we do this? | |
| 1134 void QuicStreamFactory::OnIPAddressChanged() { | 1140 void QuicStreamFactory::OnIPAddressChanged() { |
| 1135 CloseAllSessions(ERR_NETWORK_CHANGED); | 1141 CloseAllSessions(ERR_NETWORK_CHANGED); |
| 1136 set_require_confirmation(true); | 1142 set_require_confirmation(true); |
| 1137 } | 1143 } |
| 1138 | 1144 |
| 1145 void QuicStreamFactory::OnNetworkConnected( | |
| 1146 NetworkChangeNotifier::NetworkHandle network) { | |
| 1147 // Nothing to do. | |
| 1148 } | |
| 1149 | |
| 1150 void QuicStreamFactory::OnNetworkMadeDefault( | |
| 1151 NetworkChangeNotifier::NetworkHandle network) { | |
| 1152 // Nothing to do. | |
| 1153 } | |
| 1154 | |
| 1155 void QuicStreamFactory::OnNetworkDisconnected( | |
| 1156 NetworkChangeNotifier::NetworkHandle network) { | |
| 1157 MigrateOrCloseSessions(network); | |
| 1158 } | |
| 1159 | |
| 1160 void QuicStreamFactory::OnNetworkSoonToDisconnect( | |
| 1161 NetworkChangeNotifier::NetworkHandle network) { | |
| 1162 MigrateOrCloseSessions(network); | |
| 1163 } | |
| 1164 | |
| 1165 void QuicStreamFactory::MigrateOrCloseSessions( | |
| 1166 NetworkChangeNotifier::NetworkHandle network) { | |
| 1167 // TODO(jri): Need a "verified" flag on each network that gets set when | |
| 1168 // any data is received on the network. | |
| 1169 set_require_confirmation(true); | |
| 1170 | |
| 1171 // pauljensen: do we need the following "== network" check? | |
| 1172 NetworkChangeNotifier::NetworkList network_list; | |
| 1173 NetworkChangeNotifier::GetConnectedNetworks(&network_list); | |
| 1174 if (network_list.empty() || | |
| 1175 (network_list.size() == 1 && network_list[0] == network)) { | |
| 1176 CloseAllSessions(ERR_NETWORK_CHANGED); | |
| 1177 return; | |
| 1178 } | |
| 1179 | |
| 1180 // Find a new network that old sockets can be migrated to. | |
| 1181 // pauljensen: do we need the following "== network" check? | |
| 1182 NetworkChangeNotifier::NetworkHandle new_network = | |
| 1183 NetworkChangeNotifier::kInvalidNetworkHandle; | |
| 1184 for (NetworkChangeNotifier::NetworkHandle n : network_list) { | |
| 1185 if (n == network) { | |
| 1186 continue; | |
| 1187 } | |
| 1188 new_network = n; | |
| 1189 } | |
| 1190 | |
| 1191 DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, new_network); | |
| 1192 DCHECK_NE(network, new_network); | |
| 1193 | |
| 1194 for (auto& it : all_sessions_) { | |
| 1195 QuicChromiumClientSession* session = it.first; | |
| 1196 QuicServerId server_id = it.second; | |
| 1197 | |
| 1198 if (session->GetNumOpenStreams() == 0) { | |
| 1199 // If idle session, close session | |
| 1200 active_sessions_.erase(server_id); | |
| 1201 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); | |
| 1202 // } else if (session->current_network() == new_network) { | |
| 1203 // @@@ TODO (jri): store network and record in session when | |
| 1204 // BindToNetwork() is called. | |
| 1205 // If session is already using |network|, move on. | |
| 1206 // continue; | |
| 1207 continue; | |
| 1208 } | |
| 1209 // If session has active streams, | |
| 1210 // (i) make the session GO_AWAY, | |
| 1211 // (ii) create a new socket (which should be bound to the new interface), | |
| 1212 // (iii) migrate the session to using the new socket. | |
| 1213 OnSessionGoingAway(session); | |
| 1214 QuicConnection* connection = session->connection(); | |
| 1215 scoped_ptr<DatagramClientSocket> socket = | |
| 1216 CreateDatagramClientSocket(all_sessions_[session], session->net_log()); | |
| 1217 int rv = ConfigureDatagramClientSocket(socket.get(), | |
| 1218 connection->peer_address(), network); | |
| 1219 if (rv != OK) { | |
| 1220 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); | |
| 1221 continue; | |
| 1222 } | |
| 1223 QuicPacketReader* new_reader = new QuicPacketReader( | |
| 1224 socket.get(), clock_.get(), session, yield_after_packets_, | |
| 1225 yield_after_duration_, session->net_log()); | |
| 1226 DefaultPacketWriterFactory packet_writer_factory(socket.get()); | |
| 1227 QuicPacketWriter* new_writer = packet_writer_factory.Create(connection); | |
| 1228 | |
| 1229 if (!session->MigrateToSocket(socket.Pass(), new_reader, new_writer)) { | |
|
Ryan Hamilton
2015/11/17 04:57:28
I think new_reader and new_writer are leaked here
Jana
2015/11/18 04:31:41
Doh! They're scoped_ptrs now, so the leak is fixed
| |
| 1230 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); | |
| 1231 } | |
| 1232 } | |
| 1233 } | |
| 1234 | |
| 1139 void QuicStreamFactory::OnSSLConfigChanged() { | 1235 void QuicStreamFactory::OnSSLConfigChanged() { |
| 1140 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); | 1236 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); |
| 1141 } | 1237 } |
| 1142 | 1238 |
| 1143 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { | 1239 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { |
| 1144 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); | 1240 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); |
| 1145 } | 1241 } |
| 1146 | 1242 |
| 1147 void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) { | 1243 void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) { |
| 1148 // We should flush the sessions if we removed trust from a | 1244 // 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. | 1258 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() check. |
| 1163 if (active_sessions_.empty()) | 1259 if (active_sessions_.empty()) |
| 1164 return false; | 1260 return false; |
| 1165 return ContainsKey(active_sessions_, server_id); | 1261 return ContainsKey(active_sessions_, server_id); |
| 1166 } | 1262 } |
| 1167 | 1263 |
| 1168 bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const { | 1264 bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const { |
| 1169 return ContainsKey(active_jobs_, key); | 1265 return ContainsKey(active_jobs_, key); |
| 1170 } | 1266 } |
| 1171 | 1267 |
| 1172 int QuicStreamFactory::CreateSession(const QuicServerId& server_id, | 1268 scoped_ptr<DatagramClientSocket> QuicStreamFactory::CreateDatagramClientSocket( |
| 1173 int cert_verify_flags, | 1269 const QuicServerId& server_id, |
| 1174 scoped_ptr<QuicServerInfo> server_info, | 1270 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_; | 1271 bool enable_port_selection = enable_port_selection_; |
| 1180 if (enable_port_selection && | 1272 if (enable_port_selection && |
| 1181 ContainsKey(gone_away_aliases_, server_id)) { | 1273 ContainsKey(gone_away_aliases_, server_id)) { |
| 1182 // Disable port selection when the server is going away. | 1274 // Disable port selection when the server is going away. |
| 1183 // There is no point in trying to return to the same server, if | 1275 // There is no point in trying to return to the same server, if |
| 1184 // that server is no longer handling requests. | 1276 // that server is no longer handling requests. |
| 1185 enable_port_selection = false; | 1277 enable_port_selection = false; |
| 1186 gone_away_aliases_.erase(server_id); | 1278 gone_away_aliases_.erase(server_id); |
| 1187 } | 1279 } |
| 1188 | |
| 1189 QuicConnectionId connection_id = random_generator_->RandUint64(); | |
| 1190 IPEndPoint addr = *address_list.begin(); | |
| 1191 scoped_refptr<PortSuggester> port_suggester = | 1280 scoped_refptr<PortSuggester> port_suggester = |
| 1192 new PortSuggester(server_id.host_port_pair(), port_seed_); | 1281 new PortSuggester(server_id.host_port_pair(), port_seed_); |
| 1193 DatagramSocket::BindType bind_type = enable_port_selection ? | 1282 DatagramSocket::BindType bind_type = enable_port_selection ? |
| 1194 DatagramSocket::RANDOM_BIND : // Use our callback. | 1283 DatagramSocket::RANDOM_BIND : // Use our callback. |
| 1195 DatagramSocket::DEFAULT_BIND; // Use OS to randomize. | 1284 DatagramSocket::DEFAULT_BIND; // Use OS to randomize. |
| 1285 | |
| 1196 scoped_ptr<DatagramClientSocket> socket( | 1286 scoped_ptr<DatagramClientSocket> socket( |
| 1197 client_socket_factory_->CreateDatagramClientSocket( | 1287 client_socket_factory_->CreateDatagramClientSocket( |
| 1198 bind_type, | 1288 bind_type, |
| 1199 base::Bind(&PortSuggester::SuggestPort, port_suggester), | 1289 base::Bind(&PortSuggester::SuggestPort, port_suggester), |
| 1200 net_log.net_log(), net_log.source())); | 1290 net_log.net_log(), net_log.source())); |
| 1201 | 1291 |
| 1292 UMA_HISTOGRAM_COUNTS("Net.QuicEphemeralPortsSuggested", | |
| 1293 port_suggester->call_count()); | |
| 1294 if (enable_port_selection) { | |
| 1295 DCHECK_LE(1u, port_suggester->call_count()); | |
| 1296 } else { | |
| 1297 DCHECK_EQ(0u, port_suggester->call_count()); | |
| 1298 } | |
| 1299 | |
| 1300 return socket; | |
| 1301 } | |
| 1302 | |
| 1303 int QuicStreamFactory::ConfigureDatagramClientSocket( | |
| 1304 DatagramClientSocket* socket, | |
| 1305 IPEndPoint addr, | |
| 1306 NetworkChangeNotifier::NetworkHandle network) { | |
| 1202 if (enable_non_blocking_io_ && | 1307 if (enable_non_blocking_io_ && |
| 1203 client_socket_factory_ == ClientSocketFactory::GetDefaultFactory()) { | 1308 client_socket_factory_ == ClientSocketFactory::GetDefaultFactory()) { |
| 1204 #if defined(OS_WIN) | 1309 #if defined(OS_WIN) |
| 1205 static_cast<UDPClientSocket*>(socket.get())->UseNonBlockingIO(); | 1310 static_cast<UDPClientSocket*>(socket.get())->UseNonBlockingIO(); |
| 1206 #endif | 1311 #endif |
| 1207 } | 1312 } |
| 1208 | 1313 |
| 1209 int rv = socket->Connect(addr); | 1314 // If caller leaves network unspecified, find current default. |
| 1315 int rv; | |
| 1316 if (network == NetworkChangeNotifier::kInvalidNetworkHandle) { | |
| 1317 rv = socket->BindToDefaultNetwork(); | |
| 1318 } else { | |
| 1319 rv = socket->BindToNetwork(network); | |
| 1320 } | |
| 1321 if (rv != OK) { | |
| 1322 return rv; | |
| 1323 } | |
| 1210 | 1324 |
| 1325 rv = socket->Connect(addr); | |
| 1211 if (rv != OK) { | 1326 if (rv != OK) { |
| 1212 HistogramCreateSessionFailure(CREATION_ERROR_CONNECTING_SOCKET); | 1327 HistogramCreateSessionFailure(CREATION_ERROR_CONNECTING_SOCKET); |
| 1213 return rv; | 1328 return rv; |
| 1214 } | 1329 } |
| 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 | 1330 |
| 1223 rv = socket->SetReceiveBufferSize(socket_receive_buffer_size_); | 1331 rv = socket->SetReceiveBufferSize(socket_receive_buffer_size_); |
| 1224 if (rv != OK) { | 1332 if (rv != OK) { |
| 1225 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_RECEIVE_BUFFER); | 1333 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_RECEIVE_BUFFER); |
| 1226 return rv; | 1334 return rv; |
| 1227 } | 1335 } |
| 1336 | |
| 1228 // Set a buffer large enough to contain the initial CWND's worth of packet | 1337 // 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 | 1338 // to work around the problem with CHLO packets being sent out with the |
| 1230 // wrong encryption level, when the send buffer is full. | 1339 // wrong encryption level, when the send buffer is full. |
| 1231 rv = socket->SetSendBufferSize(kMaxPacketSize * 20); | 1340 rv = socket->SetSendBufferSize(kMaxPacketSize * 20); |
| 1232 if (rv != OK) { | 1341 if (rv != OK) { |
| 1233 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); | 1342 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); |
| 1234 return rv; | 1343 return rv; |
| 1235 } | 1344 } |
| 1236 | 1345 |
| 1237 socket->GetLocalAddress(&local_address_); | 1346 socket->GetLocalAddress(&local_address_); |
| 1238 if (check_persisted_supports_quic_) { | 1347 if (check_persisted_supports_quic_) { |
| 1239 check_persisted_supports_quic_ = false; | 1348 check_persisted_supports_quic_ = false; |
| 1240 IPAddressNumber last_address; | 1349 IPAddressNumber last_address; |
| 1241 if (http_server_properties_->GetSupportsQuic(&last_address) && | 1350 if (http_server_properties_->GetSupportsQuic(&last_address) && |
| 1242 last_address == local_address_.address()) { | 1351 last_address == local_address_.address()) { |
| 1243 require_confirmation_ = false; | 1352 require_confirmation_ = false; |
| 1244 } | 1353 } |
| 1245 } | 1354 } |
| 1246 | 1355 |
| 1356 return OK; | |
| 1357 } | |
| 1358 | |
| 1359 int QuicStreamFactory::CreateSession(const QuicServerId& server_id, | |
| 1360 int cert_verify_flags, | |
| 1361 scoped_ptr<QuicServerInfo> server_info, | |
| 1362 const AddressList& address_list, | |
| 1363 base::TimeTicks dns_resolution_end_time, | |
| 1364 const BoundNetLog& net_log, | |
| 1365 QuicChromiumClientSession** session) { | |
| 1366 IPEndPoint addr = *address_list.begin(); | |
| 1367 | |
| 1368 scoped_ptr<DatagramClientSocket> socket = | |
| 1369 CreateDatagramClientSocket(server_id, net_log); | |
| 1370 | |
| 1371 int rv = ConfigureDatagramClientSocket( | |
| 1372 socket.get(), addr, NetworkChangeNotifier::kInvalidNetworkHandle); | |
| 1373 | |
| 1374 if (rv != OK) { | |
| 1375 return rv; | |
| 1376 } | |
| 1377 | |
| 1247 DefaultPacketWriterFactory packet_writer_factory(socket.get()); | 1378 DefaultPacketWriterFactory packet_writer_factory(socket.get()); |
| 1248 | |
| 1249 if (!helper_.get()) { | 1379 if (!helper_.get()) { |
| 1250 helper_.reset( | 1380 helper_.reset( |
| 1251 new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(), | 1381 new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(), |
| 1252 clock_.get(), random_generator_)); | 1382 clock_.get(), random_generator_)); |
| 1253 } | 1383 } |
| 1254 | 1384 |
| 1385 QuicConnectionId connection_id = random_generator_->RandUint64(); | |
| 1255 QuicConnection* connection = new QuicConnection( | 1386 QuicConnection* connection = new QuicConnection( |
| 1256 connection_id, addr, helper_.get(), packet_writer_factory, | 1387 connection_id, addr, helper_.get(), packet_writer_factory, |
| 1257 true /* owns_writer */, Perspective::IS_CLIENT, supported_versions_); | 1388 true /* owns_writer */, Perspective::IS_CLIENT, supported_versions_); |
| 1258 connection->SetMaxPacketLength(max_packet_length_); | 1389 connection->SetMaxPacketLength(max_packet_length_); |
| 1259 | 1390 |
| 1260 InitializeCachedStateInCryptoConfig(server_id, server_info); | 1391 InitializeCachedStateInCryptoConfig(server_id, server_info); |
| 1261 | 1392 |
| 1262 QuicConfig config = config_; | 1393 QuicConfig config = config_; |
| 1263 config.SetSocketReceiveBufferToSend(socket_receive_buffer_size_); | 1394 config.SetSocketReceiveBufferToSend(socket_receive_buffer_size_); |
| 1264 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); | 1395 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 | 1579 // Since the session was active, there's no longer an |
| 1449 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1580 // 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 | 1581 // 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 | 1582 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1452 // still race. | 1583 // still race. |
| 1453 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1584 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1454 alternative_service); | 1585 alternative_service); |
| 1455 } | 1586 } |
| 1456 | 1587 |
| 1457 } // namespace net | 1588 } // namespace net |
| OLD | NEW |