| 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/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <openssl/aead.h> | 7 #include <openssl/aead.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 const std::string& user_agent_id, | 711 const std::string& user_agent_id, |
| 712 const QuicVersionVector& supported_versions, | 712 const QuicVersionVector& supported_versions, |
| 713 bool enable_port_selection, | 713 bool enable_port_selection, |
| 714 bool always_require_handshake_confirmation, | 714 bool always_require_handshake_confirmation, |
| 715 bool disable_connection_pooling, | 715 bool disable_connection_pooling, |
| 716 float load_server_info_timeout_srtt_multiplier, | 716 float load_server_info_timeout_srtt_multiplier, |
| 717 bool enable_connection_racing, | 717 bool enable_connection_racing, |
| 718 bool enable_non_blocking_io, | 718 bool enable_non_blocking_io, |
| 719 bool disable_disk_cache, | 719 bool disable_disk_cache, |
| 720 bool prefer_aes, | 720 bool prefer_aes, |
| 721 int max_number_of_lossy_connections, | |
| 722 float packet_loss_threshold, | |
| 723 int max_disabled_reasons, | |
| 724 int threshold_public_resets_post_handshake, | |
| 725 int threshold_timeouts_with_open_streams, | |
| 726 int socket_receive_buffer_size, | 721 int socket_receive_buffer_size, |
| 727 bool delay_tcp_race, | 722 bool delay_tcp_race, |
| 728 int max_server_configs_stored_in_properties, | 723 int max_server_configs_stored_in_properties, |
| 729 bool close_sessions_on_ip_change, | 724 bool close_sessions_on_ip_change, |
| 730 bool disable_quic_on_timeout_with_open_streams, | 725 bool disable_quic_on_timeout_with_open_streams, |
| 731 int idle_connection_timeout_seconds, | 726 int idle_connection_timeout_seconds, |
| 732 int reduced_ping_timeout_seconds, | 727 int reduced_ping_timeout_seconds, |
| 733 int packet_reader_yield_after_duration_milliseconds, | 728 int packet_reader_yield_after_duration_milliseconds, |
| 734 bool migrate_sessions_on_network_change, | 729 bool migrate_sessions_on_network_change, |
| 735 bool migrate_sessions_early, | 730 bool migrate_sessions_early, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 762 enable_port_selection_(enable_port_selection), | 757 enable_port_selection_(enable_port_selection), |
| 763 always_require_handshake_confirmation_( | 758 always_require_handshake_confirmation_( |
| 764 always_require_handshake_confirmation), | 759 always_require_handshake_confirmation), |
| 765 disable_connection_pooling_(disable_connection_pooling), | 760 disable_connection_pooling_(disable_connection_pooling), |
| 766 load_server_info_timeout_srtt_multiplier_( | 761 load_server_info_timeout_srtt_multiplier_( |
| 767 load_server_info_timeout_srtt_multiplier), | 762 load_server_info_timeout_srtt_multiplier), |
| 768 enable_connection_racing_(enable_connection_racing), | 763 enable_connection_racing_(enable_connection_racing), |
| 769 enable_non_blocking_io_(enable_non_blocking_io), | 764 enable_non_blocking_io_(enable_non_blocking_io), |
| 770 disable_disk_cache_(disable_disk_cache), | 765 disable_disk_cache_(disable_disk_cache), |
| 771 prefer_aes_(prefer_aes), | 766 prefer_aes_(prefer_aes), |
| 772 max_number_of_lossy_connections_(max_number_of_lossy_connections), | 767 disable_quic_on_timeout_with_open_streams_( |
| 773 packet_loss_threshold_(packet_loss_threshold), | 768 disable_quic_on_timeout_with_open_streams), |
| 774 max_disabled_reasons_(max_disabled_reasons), | |
| 775 num_public_resets_post_handshake_(0), | |
| 776 num_timeouts_with_open_streams_(0), | |
| 777 max_public_resets_post_handshake_(0), | |
| 778 max_timeouts_with_open_streams_(0), | |
| 779 threshold_timeouts_with_open_streams_( | |
| 780 threshold_timeouts_with_open_streams), | |
| 781 threshold_public_resets_post_handshake_( | |
| 782 threshold_public_resets_post_handshake), | |
| 783 socket_receive_buffer_size_(socket_receive_buffer_size), | 769 socket_receive_buffer_size_(socket_receive_buffer_size), |
| 784 delay_tcp_race_(delay_tcp_race), | 770 delay_tcp_race_(delay_tcp_race), |
| 785 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), | 771 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), |
| 786 reduced_ping_timeout_( | 772 reduced_ping_timeout_( |
| 787 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), | 773 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), |
| 788 yield_after_packets_(kQuicYieldAfterPacketsRead), | 774 yield_after_packets_(kQuicYieldAfterPacketsRead), |
| 789 yield_after_duration_(QuicTime::Delta::FromMilliseconds( | 775 yield_after_duration_(QuicTime::Delta::FromMilliseconds( |
| 790 packet_reader_yield_after_duration_milliseconds)), | 776 packet_reader_yield_after_duration_milliseconds)), |
| 791 close_sessions_on_ip_change_(close_sessions_on_ip_change), | 777 close_sessions_on_ip_change_(close_sessions_on_ip_change), |
| 792 migrate_sessions_on_network_change_( | 778 migrate_sessions_on_network_change_( |
| 793 migrate_sessions_on_network_change && | 779 migrate_sessions_on_network_change && |
| 794 NetworkChangeNotifier::AreNetworkHandlesSupported()), | 780 NetworkChangeNotifier::AreNetworkHandlesSupported()), |
| 795 migrate_sessions_early_(migrate_sessions_early && | 781 migrate_sessions_early_(migrate_sessions_early && |
| 796 migrate_sessions_on_network_change_), | 782 migrate_sessions_on_network_change_), |
| 797 allow_server_migration_(allow_server_migration), | 783 allow_server_migration_(allow_server_migration), |
| 798 force_hol_blocking_(force_hol_blocking), | 784 force_hol_blocking_(force_hol_blocking), |
| 799 race_cert_verification_(race_cert_verification), | 785 race_cert_verification_(race_cert_verification), |
| 800 quic_do_not_fragment_(quic_do_not_fragment), | 786 quic_do_not_fragment_(quic_do_not_fragment), |
| 801 port_seed_(random_generator_->RandUint64()), | 787 port_seed_(random_generator_->RandUint64()), |
| 802 check_persisted_supports_quic_(true), | 788 check_persisted_supports_quic_(true), |
| 803 has_initialized_data_(false), | 789 has_initialized_data_(false), |
| 804 num_push_streams_created_(0), | 790 num_push_streams_created_(0), |
| 805 status_(OPEN), | 791 status_(OPEN), |
| 806 task_runner_(nullptr), | 792 task_runner_(nullptr), |
| 807 ssl_config_service_(ssl_config_service), | 793 ssl_config_service_(ssl_config_service), |
| 808 weak_factory_(this) { | 794 weak_factory_(this) { |
| 809 if (ssl_config_service_.get()) | 795 if (ssl_config_service_.get()) |
| 810 ssl_config_service_->AddObserver(this); | 796 ssl_config_service_->AddObserver(this); |
| 811 if (disable_quic_on_timeout_with_open_streams) | |
| 812 threshold_timeouts_with_open_streams_ = 1; | |
| 813 DCHECK(transport_security_state_); | 797 DCHECK(transport_security_state_); |
| 814 DCHECK(http_server_properties_); | 798 DCHECK(http_server_properties_); |
| 815 crypto_config_.set_user_agent_id(user_agent_id); | 799 crypto_config_.set_user_agent_id(user_agent_id); |
| 816 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 800 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
| 817 crypto_config_.AddCanonicalSuffix(".ggpht.com"); | 801 crypto_config_.AddCanonicalSuffix(".ggpht.com"); |
| 818 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 802 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
| 819 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); | 803 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); |
| 820 // TODO(rtenneti): http://crbug.com/487355. Temporary fix for b/20760730 until | 804 // TODO(rtenneti): http://crbug.com/487355. Temporary fix for b/20760730 until |
| 821 // channel_id_service is supported in cronet. | 805 // channel_id_service is supported in cronet. |
| 822 if (channel_id_service) { | 806 if (channel_id_service) { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { | 1122 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { |
| 1139 active_cert_verifier_jobs_.erase(job->server_id()); | 1123 active_cert_verifier_jobs_.erase(job->server_id()); |
| 1140 } | 1124 } |
| 1141 | 1125 |
| 1142 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( | 1126 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( |
| 1143 QuicChromiumClientSession* session) { | 1127 QuicChromiumClientSession* session) { |
| 1144 return std::unique_ptr<QuicHttpStream>( | 1128 return std::unique_ptr<QuicHttpStream>( |
| 1145 new QuicHttpStream(session->GetWeakPtr())); | 1129 new QuicHttpStream(session->GetWeakPtr())); |
| 1146 } | 1130 } |
| 1147 | 1131 |
| 1148 QuicChromiumClientSession::QuicDisabledReason | 1132 bool QuicStreamFactory::IsQuicDisabled() const { |
| 1149 QuicStreamFactory::QuicDisabledReason(uint16_t port) const { | |
| 1150 if (max_number_of_lossy_connections_ > 0 && | |
| 1151 number_of_lossy_connections_.find(port) != | |
| 1152 number_of_lossy_connections_.end() && | |
| 1153 number_of_lossy_connections_.at(port) >= | |
| 1154 max_number_of_lossy_connections_) { | |
| 1155 return QuicChromiumClientSession::QUIC_DISABLED_BAD_PACKET_LOSS_RATE; | |
| 1156 } | |
| 1157 if (threshold_public_resets_post_handshake_ > 0 && | |
| 1158 num_public_resets_post_handshake_ >= | |
| 1159 threshold_public_resets_post_handshake_) { | |
| 1160 return QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE; | |
| 1161 } | |
| 1162 if (threshold_timeouts_with_open_streams_ > 0 && | |
| 1163 num_timeouts_with_open_streams_ >= | |
| 1164 threshold_timeouts_with_open_streams_) { | |
| 1165 return QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS; | |
| 1166 } | |
| 1167 return QuicChromiumClientSession::QUIC_DISABLED_NOT; | |
| 1168 } | |
| 1169 | |
| 1170 const char* QuicStreamFactory::QuicDisabledReasonString() const { | |
| 1171 // TODO(ckrasic) - better solution for port/lossy connections? | |
| 1172 const uint16_t port = 443; | |
| 1173 switch (QuicDisabledReason(port)) { | |
| 1174 case QuicChromiumClientSession::QUIC_DISABLED_BAD_PACKET_LOSS_RATE: | |
| 1175 return "Bad packet loss rate."; | |
| 1176 case QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE: | |
| 1177 return "Public resets after successful handshakes."; | |
| 1178 case QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS: | |
| 1179 return "Connection timeouts with streams open."; | |
| 1180 default: | |
| 1181 return ""; | |
| 1182 } | |
| 1183 } | |
| 1184 | |
| 1185 bool QuicStreamFactory::IsQuicDisabled(uint16_t port) const { | |
| 1186 return status_ != OPEN; | 1133 return status_ != OPEN; |
| 1187 } | 1134 } |
| 1188 | 1135 |
| 1189 bool QuicStreamFactory::OnHandshakeConfirmed(QuicChromiumClientSession* session, | 1136 bool QuicStreamFactory::OnHandshakeConfirmed( |
| 1190 float packet_loss_rate) { | 1137 QuicChromiumClientSession* session) { |
| 1191 DCHECK(session); | 1138 if (!IsQuicDisabled()) |
| 1192 uint16_t port = session->server_id().port(); | |
| 1193 if (packet_loss_rate < packet_loss_threshold_) { | |
| 1194 number_of_lossy_connections_[port] = 0; | |
| 1195 return false; | 1139 return false; |
| 1196 } | |
| 1197 | 1140 |
| 1198 // We mark it as recently broken, which means that 0-RTT will be disabled | 1141 session->CloseSessionOnErrorAndNotifyFactoryLater( |
| 1199 // but we'll still race. | 1142 ERR_ABORTED, QUIC_TIMEOUTS_WITH_OPEN_STREAMS); |
| 1200 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | |
| 1201 AlternativeService(QUIC, session->server_id().host(), port)); | |
| 1202 | 1143 |
| 1203 bool was_quic_disabled = IsQuicDisabled(port); | 1144 return true; |
| 1204 ++number_of_lossy_connections_[port]; | |
| 1205 | |
| 1206 // Collect data for port 443 for packet loss events. | |
| 1207 if (port == 443 && max_number_of_lossy_connections_ > 0) { | |
| 1208 UMA_HISTOGRAM_SPARSE_SLOWLY( | |
| 1209 base::StringPrintf("Net.QuicStreamFactory.BadPacketLossEvents%d", | |
| 1210 max_number_of_lossy_connections_), | |
| 1211 std::min(number_of_lossy_connections_[port], | |
| 1212 max_number_of_lossy_connections_)); | |
| 1213 } | |
| 1214 | |
| 1215 MaybeDisableQuic(port); | |
| 1216 | |
| 1217 bool is_quic_disabled = IsQuicDisabled(port); | |
| 1218 if (is_quic_disabled) { | |
| 1219 // Close QUIC connection if Quic is disabled for this port. | |
| 1220 session->CloseSessionOnErrorAndNotifyFactoryLater( | |
| 1221 ERR_ABORTED, QUIC_BAD_PACKET_LOSS_RATE); | |
| 1222 | |
| 1223 // If this bad packet loss rate disabled the QUIC, then record it. | |
| 1224 if (!was_quic_disabled) | |
| 1225 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicStreamFactory.QuicIsDisabled", port); | |
| 1226 } | |
| 1227 return is_quic_disabled; | |
| 1228 } | 1145 } |
| 1229 | 1146 |
| 1230 void QuicStreamFactory::OnTcpJobCompleted(bool succeeded) { | 1147 void QuicStreamFactory::OnTcpJobCompleted(bool succeeded) { |
| 1231 if (status_ != CLOSED) | 1148 if (status_ != CLOSED) |
| 1232 return; | 1149 return; |
| 1233 | 1150 |
| 1234 // If QUIC connections are failing while TCP connections are working, | 1151 // If QUIC connections are failing while TCP connections are working, |
| 1235 // then stop using QUIC. On the other hand if both QUIC and TCP are | 1152 // then stop using QUIC. On the other hand if both QUIC and TCP are |
| 1236 // failing, then attempt to use QUIC again. | 1153 // failing, then attempt to use QUIC again. |
| 1237 if (succeeded) { | 1154 if (succeeded) { |
| 1238 status_ = DISABLED; | 1155 status_ = DISABLED; |
| 1239 return; | 1156 return; |
| 1240 } | 1157 } |
| 1241 | 1158 |
| 1242 status_ = OPEN; | 1159 status_ = OPEN; |
| 1243 num_timeouts_with_open_streams_ = 0; | |
| 1244 } | 1160 } |
| 1245 | 1161 |
| 1246 void QuicStreamFactory::OnIdleSession(QuicChromiumClientSession* session) {} | 1162 void QuicStreamFactory::OnIdleSession(QuicChromiumClientSession* session) {} |
| 1247 | 1163 |
| 1248 void QuicStreamFactory::OnSessionGoingAway(QuicChromiumClientSession* session) { | 1164 void QuicStreamFactory::OnSessionGoingAway(QuicChromiumClientSession* session) { |
| 1249 const AliasSet& aliases = session_aliases_[session]; | 1165 const AliasSet& aliases = session_aliases_[session]; |
| 1250 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); | 1166 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); |
| 1251 ++it) { | 1167 ++it) { |
| 1252 const QuicServerId& server_id = it->server_id(); | 1168 const QuicServerId& server_id = it->server_id(); |
| 1253 DCHECK(active_sessions_.count(server_id)); | 1169 DCHECK(active_sessions_.count(server_id)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1265 DCHECK(base::ContainsKey(session_peer_ip_, session)); | 1181 DCHECK(base::ContainsKey(session_peer_ip_, session)); |
| 1266 const IPEndPoint peer_address = session_peer_ip_[session]; | 1182 const IPEndPoint peer_address = session_peer_ip_[session]; |
| 1267 ip_aliases_[peer_address].erase(session); | 1183 ip_aliases_[peer_address].erase(session); |
| 1268 if (ip_aliases_[peer_address].empty()) | 1184 if (ip_aliases_[peer_address].empty()) |
| 1269 ip_aliases_.erase(peer_address); | 1185 ip_aliases_.erase(peer_address); |
| 1270 session_peer_ip_.erase(session); | 1186 session_peer_ip_.erase(session); |
| 1271 } | 1187 } |
| 1272 session_aliases_.erase(session); | 1188 session_aliases_.erase(session); |
| 1273 } | 1189 } |
| 1274 | 1190 |
| 1275 void QuicStreamFactory::MaybeDisableQuic(QuicChromiumClientSession* session) { | |
| 1276 DCHECK(session); | |
| 1277 uint16_t port = session->server_id().port(); | |
| 1278 if (IsQuicDisabled(port)) | |
| 1279 return; | |
| 1280 | |
| 1281 // Expire the oldest disabled_reason if appropriate. This enforces that we | |
| 1282 // only consider the max_disabled_reasons_ most recent sessions. | |
| 1283 QuicChromiumClientSession::QuicDisabledReason disabled_reason; | |
| 1284 if (static_cast<int>(disabled_reasons_.size()) == max_disabled_reasons_) { | |
| 1285 disabled_reason = disabled_reasons_.front(); | |
| 1286 disabled_reasons_.pop_front(); | |
| 1287 if (disabled_reason == | |
| 1288 QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE) { | |
| 1289 --num_public_resets_post_handshake_; | |
| 1290 } else if (disabled_reason == QuicChromiumClientSession:: | |
| 1291 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS) { | |
| 1292 --num_timeouts_with_open_streams_; | |
| 1293 } | |
| 1294 } | |
| 1295 disabled_reason = session->disabled_reason(); | |
| 1296 disabled_reasons_.push_back(disabled_reason); | |
| 1297 if (disabled_reason == | |
| 1298 QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE) { | |
| 1299 ++num_public_resets_post_handshake_; | |
| 1300 } else if (disabled_reason == QuicChromiumClientSession:: | |
| 1301 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS) { | |
| 1302 ++num_timeouts_with_open_streams_; | |
| 1303 } | |
| 1304 if (num_timeouts_with_open_streams_ > max_timeouts_with_open_streams_) { | |
| 1305 max_timeouts_with_open_streams_ = num_timeouts_with_open_streams_; | |
| 1306 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.QuicStreamFactory.TimeoutsWithOpenStreams", | |
| 1307 num_timeouts_with_open_streams_, 1, 20, 10); | |
| 1308 } | |
| 1309 | |
| 1310 if (num_public_resets_post_handshake_ > max_public_resets_post_handshake_) { | |
| 1311 max_public_resets_post_handshake_ = num_public_resets_post_handshake_; | |
| 1312 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 1313 "Net.QuicStreamFactory.PublicResetsPostHandshake", | |
| 1314 num_public_resets_post_handshake_, 1, 20, 10); | |
| 1315 } | |
| 1316 | |
| 1317 MaybeDisableQuic(port); | |
| 1318 if (IsQuicDisabled(port)) { | |
| 1319 if (disabled_reason == | |
| 1320 QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE) { | |
| 1321 session->CloseSessionOnErrorAndNotifyFactoryLater( | |
| 1322 ERR_ABORTED, QUIC_PUBLIC_RESETS_POST_HANDSHAKE); | |
| 1323 } else if (disabled_reason == QuicChromiumClientSession:: | |
| 1324 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS) { | |
| 1325 session->CloseSessionOnErrorAndNotifyFactoryLater( | |
| 1326 ERR_ABORTED, QUIC_TIMEOUTS_WITH_OPEN_STREAMS); | |
| 1327 } | |
| 1328 UMA_HISTOGRAM_ENUMERATION("Net.QuicStreamFactory.DisabledReasons", | |
| 1329 disabled_reason, | |
| 1330 QuicChromiumClientSession::QUIC_DISABLED_MAX); | |
| 1331 } | |
| 1332 } | |
| 1333 | |
| 1334 void QuicStreamFactory::MaybeDisableQuic(uint16_t port) { | |
| 1335 if (status_ == DISABLED) | |
| 1336 return; | |
| 1337 | |
| 1338 QuicChromiumClientSession::QuicDisabledReason disabled_reason = | |
| 1339 QuicDisabledReason(port); | |
| 1340 if (disabled_reason == QuicChromiumClientSession::QUIC_DISABLED_NOT) { | |
| 1341 DCHECK_EQ(OPEN, status_); | |
| 1342 return; | |
| 1343 } | |
| 1344 | |
| 1345 if (disabled_reason == | |
| 1346 QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS) { | |
| 1347 // When QUIC there are too many timeouts with open stream, the factory | |
| 1348 // should be closed. When TCP jobs complete, they will move the factory | |
| 1349 // to either fully disabled or back to open. | |
| 1350 status_ = CLOSED; | |
| 1351 DCHECK(IsQuicDisabled(port)); | |
| 1352 DCHECK_NE(QuicChromiumClientSession::QuicDisabledReason(port), | |
| 1353 QuicChromiumClientSession::QUIC_DISABLED_NOT); | |
| 1354 return; | |
| 1355 } | |
| 1356 | |
| 1357 status_ = DISABLED; | |
| 1358 DCHECK(IsQuicDisabled(port)); | |
| 1359 DCHECK_NE(QuicChromiumClientSession::QuicDisabledReason(port), | |
| 1360 QuicChromiumClientSession::QUIC_DISABLED_NOT); | |
| 1361 } | |
| 1362 | |
| 1363 void QuicStreamFactory::OnSessionClosed(QuicChromiumClientSession* session) { | 1191 void QuicStreamFactory::OnSessionClosed(QuicChromiumClientSession* session) { |
| 1364 DCHECK_EQ(0u, session->GetNumActiveStreams()); | 1192 DCHECK_EQ(0u, session->GetNumActiveStreams()); |
| 1365 MaybeDisableQuic(session); | |
| 1366 OnSessionGoingAway(session); | 1193 OnSessionGoingAway(session); |
| 1367 delete session; | 1194 delete session; |
| 1368 all_sessions_.erase(session); | 1195 all_sessions_.erase(session); |
| 1369 } | 1196 } |
| 1370 | 1197 |
| 1371 void QuicStreamFactory::OnTimeoutWithOpenStreams() { | 1198 void QuicStreamFactory::OnTimeoutWithOpenStreams() { |
| 1372 // Reduce PING timeout when connection times out with open stream. | 1199 // Reduce PING timeout when connection times out with open stream. |
| 1373 if (ping_timeout_ > reduced_ping_timeout_) { | 1200 if (ping_timeout_ > reduced_ping_timeout_) { |
| 1374 ping_timeout_ = reduced_ping_timeout_; | 1201 ping_timeout_ = reduced_ping_timeout_; |
| 1375 } | 1202 } |
| 1203 if (disable_quic_on_timeout_with_open_streams_) |
| 1204 status_ = CLOSED; |
| 1376 } | 1205 } |
| 1377 | 1206 |
| 1378 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { | 1207 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { |
| 1379 RequestMap::iterator request_it = active_requests_.find(request); | 1208 RequestMap::iterator request_it = active_requests_.find(request); |
| 1380 DCHECK(request_it != active_requests_.end()); | 1209 DCHECK(request_it != active_requests_.end()); |
| 1381 const QuicServerId& server_id = request_it->second; | 1210 const QuicServerId& server_id = request_it->second; |
| 1382 job_requests_map_[server_id].erase(request); | 1211 job_requests_map_[server_id].erase(request); |
| 1383 active_requests_.erase(request_it); | 1212 active_requests_.erase(request_it); |
| 1384 } | 1213 } |
| 1385 | 1214 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 return std::move(list); | 1249 return std::move(list); |
| 1421 } | 1250 } |
| 1422 | 1251 |
| 1423 void QuicStreamFactory::ClearCachedStatesInCryptoConfig( | 1252 void QuicStreamFactory::ClearCachedStatesInCryptoConfig( |
| 1424 const base::Callback<bool(const GURL&)>& origin_filter) { | 1253 const base::Callback<bool(const GURL&)>& origin_filter) { |
| 1425 ServerIdOriginFilter filter(origin_filter); | 1254 ServerIdOriginFilter filter(origin_filter); |
| 1426 crypto_config_.ClearCachedStates(filter); | 1255 crypto_config_.ClearCachedStates(filter); |
| 1427 } | 1256 } |
| 1428 | 1257 |
| 1429 void QuicStreamFactory::OnIPAddressChanged() { | 1258 void QuicStreamFactory::OnIPAddressChanged() { |
| 1430 num_timeouts_with_open_streams_ = 0; | |
| 1431 status_ = OPEN; | 1259 status_ = OPEN; |
| 1432 CloseAllSessions(ERR_NETWORK_CHANGED, QUIC_IP_ADDRESS_CHANGED); | 1260 CloseAllSessions(ERR_NETWORK_CHANGED, QUIC_IP_ADDRESS_CHANGED); |
| 1433 set_require_confirmation(true); | 1261 set_require_confirmation(true); |
| 1434 } | 1262 } |
| 1435 | 1263 |
| 1436 void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) { | 1264 void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) { |
| 1437 num_timeouts_with_open_streams_ = 0; | |
| 1438 status_ = OPEN; | 1265 status_ = OPEN; |
| 1439 ScopedConnectionMigrationEventLog scoped_event_log(net_log_, | 1266 ScopedConnectionMigrationEventLog scoped_event_log(net_log_, |
| 1440 "OnNetworkConnected"); | 1267 "OnNetworkConnected"); |
| 1441 for (auto session : all_sessions_) { | 1268 for (auto session : all_sessions_) { |
| 1442 session.first->OnNetworkConnected(network, scoped_event_log.net_log()); | 1269 session.first->OnNetworkConnected(network, scoped_event_log.net_log()); |
| 1443 } | 1270 } |
| 1444 } | 1271 } |
| 1445 | 1272 |
| 1446 void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) { | 1273 void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) { |
| 1447 ScopedConnectionMigrationEventLog scoped_event_log(net_log_, | 1274 ScopedConnectionMigrationEventLog scoped_event_log(net_log_, |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2039 // Since the session was active, there's no longer an | 1866 // Since the session was active, there's no longer an |
| 2040 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1867 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 2041 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1868 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 2042 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1869 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 2043 // still race. | 1870 // still race. |
| 2044 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1871 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 2045 alternative_service); | 1872 alternative_service); |
| 2046 } | 1873 } |
| 2047 | 1874 |
| 2048 } // namespace net | 1875 } // namespace net |
| OLD | NEW |