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

Side by Side Diff: net/quic/quic_stream_factory.cc

Issue 1216703002: Implement multiple alternative services per origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit. Created 5 years, 5 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
« no previous file with comments | « net/quic/quic_network_transaction_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. 677 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed.
678 if (!task_runner_) 678 if (!task_runner_)
679 task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); 679 task_runner_ = base::ThreadTaskRunnerHandle::Get().get();
680 680
681 QuicServerInfo* quic_server_info = nullptr; 681 QuicServerInfo* quic_server_info = nullptr;
682 if (quic_server_info_factory_) { 682 if (quic_server_info_factory_) {
683 bool load_from_disk_cache = !disable_disk_cache_; 683 bool load_from_disk_cache = !disable_disk_cache_;
684 if (http_server_properties_) { 684 if (http_server_properties_) {
685 const AlternativeServiceMap& alternative_service_map = 685 const AlternativeServiceMap& alternative_service_map =
686 http_server_properties_->alternative_service_map(); 686 http_server_properties_->alternative_service_map();
687 AlternativeServiceMap::const_iterator it = 687 AlternativeServiceMap::const_iterator map_it =
688 alternative_service_map.Peek(server_id.host_port_pair()); 688 alternative_service_map.Peek(server_id.host_port_pair());
689 if (it == alternative_service_map.end() || 689 if (map_it != alternative_service_map.end()) {
690 it->second.alternative_service.protocol != QUIC) { 690 const AlternativeServiceInfoVector& alternative_service_info_vector =
691 map_it->second;
692 AlternativeServiceInfoVector::const_iterator it;
693 for (it = alternative_service_info_vector.begin();
694 it != alternative_service_info_vector.end(); ++it) {
695 if (it->alternative_service.protocol == QUIC)
696 break;
697 }
691 // If there is no entry for QUIC, consider that as a new server and 698 // If there is no entry for QUIC, consider that as a new server and
692 // don't wait for Cache thread to load the data for that server. 699 // don't wait for Cache thread to load the data for that server.
693 load_from_disk_cache = false; 700 if (it == alternative_service_info_vector.end())
701 load_from_disk_cache = false;
694 } 702 }
695 } 703 }
696 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) { 704 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) {
697 quic_server_info = quic_server_info_factory_->GetForServer(server_id); 705 quic_server_info = quic_server_info_factory_->GetForServer(server_id);
698 } 706 }
699 } 707 }
700 708
701 bool server_and_origin_have_same_host = host_port_pair.host() == origin_host; 709 bool server_and_origin_have_same_host = host_port_pair.host() == origin_host;
702 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, 710 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair,
703 server_and_origin_have_same_host, is_https, 711 server_and_origin_have_same_host, is_https,
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 if (!server_info) 1213 if (!server_info)
1206 return; 1214 return;
1207 1215
1208 QuicCryptoClientConfig::CachedState* cached = 1216 QuicCryptoClientConfig::CachedState* cached =
1209 crypto_config_.LookupOrCreate(server_id); 1217 crypto_config_.LookupOrCreate(server_id);
1210 if (!cached->IsEmpty()) 1218 if (!cached->IsEmpty())
1211 return; 1219 return;
1212 1220
1213 if (http_server_properties_) { 1221 if (http_server_properties_) {
1214 if (quic_supported_servers_at_startup_.empty()) { 1222 if (quic_supported_servers_at_startup_.empty()) {
1215 for (const std::pair<const HostPortPair, AlternativeServiceInfo>& 1223 for (const std::pair<const HostPortPair, AlternativeServiceInfoVector>&
1216 key_value : http_server_properties_->alternative_service_map()) { 1224 key_value : http_server_properties_->alternative_service_map()) {
1217 if (key_value.second.alternative_service.protocol == QUIC) { 1225 for (const AlternativeServiceInfo& alternative_service_info :
1218 quic_supported_servers_at_startup_.insert(key_value.first); 1226 key_value.second) {
1227 if (alternative_service_info.alternative_service.protocol == QUIC) {
1228 quic_supported_servers_at_startup_.insert(key_value.first);
1229 break;
1230 }
1219 } 1231 }
1220 } 1232 }
1221 } 1233 }
1222 1234
1223 // TODO(rtenneti): Delete the following histogram after collecting stats. 1235 // TODO(rtenneti): Delete the following histogram after collecting stats.
1224 // If the AlternativeServiceMap contained an entry for this host, check if 1236 // If the AlternativeServiceMap contained an entry for this host, check if
1225 // the disk cache contained an entry for it. 1237 // the disk cache contained an entry for it.
1226 if (ContainsKey(quic_supported_servers_at_startup_, 1238 if (ContainsKey(quic_supported_servers_at_startup_,
1227 server_id.host_port_pair())) { 1239 server_id.host_port_pair())) {
1228 UMA_HISTOGRAM_BOOLEAN( 1240 UMA_HISTOGRAM_BOOLEAN(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 // Since the session was active, there's no longer an 1292 // Since the session was active, there's no longer an
1281 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1293 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1282 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1294 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1283 // it as recently broken, which means that 0-RTT will be disabled but we'll 1295 // it as recently broken, which means that 0-RTT will be disabled but we'll
1284 // still race. 1296 // still race.
1285 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1297 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1286 alternative_service); 1298 alternative_service);
1287 } 1299 }
1288 1300
1289 } // namespace net 1301 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_network_transaction_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698