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/cpu.h" | 10 #include "base/cpu.h" |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. | 668 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. |
669 if (!task_runner_) | 669 if (!task_runner_) |
670 task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); | 670 task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); |
671 | 671 |
672 QuicServerInfo* quic_server_info = nullptr; | 672 QuicServerInfo* quic_server_info = nullptr; |
673 if (quic_server_info_factory_) { | 673 if (quic_server_info_factory_) { |
674 bool load_from_disk_cache = !disable_disk_cache_; | 674 bool load_from_disk_cache = !disable_disk_cache_; |
675 if (http_server_properties_) { | 675 if (http_server_properties_) { |
676 const AlternativeServiceMap& alternative_service_map = | 676 const AlternativeServiceMap& alternative_service_map = |
677 http_server_properties_->alternative_service_map(); | 677 http_server_properties_->alternative_service_map(); |
678 AlternativeServiceMap::const_iterator it = | 678 AlternativeServiceMap::const_iterator map_it = |
679 alternative_service_map.Peek(server_id.host_port_pair()); | 679 alternative_service_map.Peek(server_id.host_port_pair()); |
680 if (it == alternative_service_map.end() || | 680 if (map_it != alternative_service_map.end()) { |
681 it->second.alternative_service.protocol != QUIC) { | 681 const AlternativeServiceInfoVector& alternative_service_info_vector = |
| 682 map_it->second; |
| 683 AlternativeServiceInfoVector::const_iterator it; |
| 684 for (it = alternative_service_info_vector.begin(); |
| 685 it != alternative_service_info_vector.end(); ++it) { |
| 686 if (it->alternative_service.protocol == QUIC) |
| 687 break; |
| 688 } |
682 // If there is no entry for QUIC, consider that as a new server and | 689 // If there is no entry for QUIC, consider that as a new server and |
683 // don't wait for Cache thread to load the data for that server. | 690 // don't wait for Cache thread to load the data for that server. |
684 load_from_disk_cache = false; | 691 if (it == alternative_service_info_vector.end()) |
| 692 load_from_disk_cache = false; |
685 } | 693 } |
686 } | 694 } |
687 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) { | 695 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) { |
688 quic_server_info = quic_server_info_factory_->GetForServer(server_id); | 696 quic_server_info = quic_server_info_factory_->GetForServer(server_id); |
689 } | 697 } |
690 } | 698 } |
691 | 699 |
692 bool server_and_origin_have_same_host = host_port_pair.host() == origin_host; | 700 bool server_and_origin_have_same_host = host_port_pair.host() == origin_host; |
693 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, | 701 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, |
694 server_and_origin_have_same_host, is_https, | 702 server_and_origin_have_same_host, is_https, |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 if (!server_info) | 1204 if (!server_info) |
1197 return; | 1205 return; |
1198 | 1206 |
1199 QuicCryptoClientConfig::CachedState* cached = | 1207 QuicCryptoClientConfig::CachedState* cached = |
1200 crypto_config_.LookupOrCreate(server_id); | 1208 crypto_config_.LookupOrCreate(server_id); |
1201 if (!cached->IsEmpty()) | 1209 if (!cached->IsEmpty()) |
1202 return; | 1210 return; |
1203 | 1211 |
1204 if (http_server_properties_) { | 1212 if (http_server_properties_) { |
1205 if (quic_supported_servers_at_startup_.empty()) { | 1213 if (quic_supported_servers_at_startup_.empty()) { |
1206 for (const std::pair<const HostPortPair, AlternativeServiceInfo>& | 1214 for (const std::pair<const HostPortPair, AlternativeServiceInfoVector>& |
1207 key_value : http_server_properties_->alternative_service_map()) { | 1215 key_value : http_server_properties_->alternative_service_map()) { |
1208 if (key_value.second.alternative_service.protocol == QUIC) { | 1216 for (const AlternativeServiceInfo& alternative_service_info : |
1209 quic_supported_servers_at_startup_.insert(key_value.first); | 1217 key_value.second) { |
| 1218 if (alternative_service_info.alternative_service.protocol == QUIC) { |
| 1219 quic_supported_servers_at_startup_.insert(key_value.first); |
| 1220 break; |
| 1221 } |
1210 } | 1222 } |
1211 } | 1223 } |
1212 } | 1224 } |
1213 | 1225 |
1214 // TODO(rtenneti): Delete the following histogram after collecting stats. | 1226 // TODO(rtenneti): Delete the following histogram after collecting stats. |
1215 // If the AlternativeServiceMap contained an entry for this host, check if | 1227 // If the AlternativeServiceMap contained an entry for this host, check if |
1216 // the disk cache contained an entry for it. | 1228 // the disk cache contained an entry for it. |
1217 if (ContainsKey(quic_supported_servers_at_startup_, | 1229 if (ContainsKey(quic_supported_servers_at_startup_, |
1218 server_id.host_port_pair())) { | 1230 server_id.host_port_pair())) { |
1219 UMA_HISTOGRAM_BOOLEAN( | 1231 UMA_HISTOGRAM_BOOLEAN( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 // Since the session was active, there's no longer an | 1283 // Since the session was active, there's no longer an |
1272 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1284 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
1273 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1285 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
1274 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1286 // it as recently broken, which means that 0-RTT will be disabled but we'll |
1275 // still race. | 1287 // still race. |
1276 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1288 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
1277 alternative_service); | 1289 alternative_service); |
1278 } | 1290 } |
1279 | 1291 |
1280 } // namespace net | 1292 } // namespace net |
OLD | NEW |