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

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

Issue 1018943002: Update HttpServerProperties::*AlternateProtocol* interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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 <set> 7 #include <set>
8 8
9 #include "base/cpu.h" 9 #include "base/cpu.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // don't wait for Cache thread to load the data for that server. 639 // don't wait for Cache thread to load the data for that server.
640 load_from_disk_cache = false; 640 load_from_disk_cache = false;
641 } 641 }
642 } 642 }
643 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) { 643 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) {
644 quic_server_info = quic_server_info_factory_->GetForServer(server_id); 644 quic_server_info = quic_server_info_factory_->GetForServer(server_id);
645 } 645 }
646 } 646 }
647 647
648 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, is_https, 648 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, is_https,
649 WasAlternateProtocolRecentlyBroken(server_id), 649 WasAlternativeServiceRecentlyBroken(server_id),
650 privacy_mode, method == "POST" /* is_post */, 650 privacy_mode, method == "POST" /* is_post */,
651 quic_server_info, net_log)); 651 quic_server_info, net_log));
652 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, 652 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete,
653 base::Unretained(this), job.get())); 653 base::Unretained(this), job.get()));
654 if (rv == ERR_IO_PENDING) { 654 if (rv == ERR_IO_PENDING) {
655 active_requests_[request] = server_id; 655 active_requests_[request] = server_id;
656 job_requests_map_[server_id].insert(request); 656 job_requests_map_[server_id].insert(request);
657 active_jobs_[server_id].insert(job.release()); 657 active_jobs_[server_id].insert(job.release());
658 return rv; 658 return rv;
659 } 659 }
660 if (rv == OK) { 660 if (rv == OK) {
661 DCHECK(HasActiveSession(server_id)); 661 DCHECK(HasActiveSession(server_id));
662 request->set_stream(CreateIfSessionExists(server_id, net_log)); 662 request->set_stream(CreateIfSessionExists(server_id, net_log));
663 } 663 }
664 return rv; 664 return rv;
665 } 665 }
666 666
667 void QuicStreamFactory::CreateAuxilaryJob(const QuicServerId server_id, 667 void QuicStreamFactory::CreateAuxilaryJob(const QuicServerId server_id,
668 bool is_post, 668 bool is_post,
669 const BoundNetLog& net_log) { 669 const BoundNetLog& net_log) {
670 Job* aux_job = new Job(this, host_resolver_, server_id.host_port_pair(), 670 Job* aux_job = new Job(this, host_resolver_, server_id.host_port_pair(),
671 server_id.is_https(), 671 server_id.is_https(),
672 WasAlternateProtocolRecentlyBroken(server_id), 672 WasAlternativeServiceRecentlyBroken(server_id),
673 server_id.privacy_mode(), is_post, nullptr, net_log); 673 server_id.privacy_mode(), is_post, nullptr, net_log);
674 active_jobs_[server_id].insert(aux_job); 674 active_jobs_[server_id].insert(aux_job);
675 task_runner_->PostTask(FROM_HERE, 675 task_runner_->PostTask(FROM_HERE,
676 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob, 676 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob,
677 aux_job->GetWeakPtr())); 677 aux_job->GetWeakPtr()));
678 } 678 }
679 679
680 bool QuicStreamFactory::OnResolution( 680 bool QuicStreamFactory::OnResolution(
681 const QuicServerId& server_id, 681 const QuicServerId& server_id,
682 const AddressList& address_list) { 682 const AddressList& address_list) {
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 if (!http_server_properties_) 1056 if (!http_server_properties_)
1057 return 0; 1057 return 0;
1058 const ServerNetworkStats* stats = 1058 const ServerNetworkStats* stats =
1059 http_server_properties_->GetServerNetworkStats( 1059 http_server_properties_->GetServerNetworkStats(
1060 server_id.host_port_pair()); 1060 server_id.host_port_pair());
1061 if (stats == nullptr) 1061 if (stats == nullptr)
1062 return 0; 1062 return 0;
1063 return stats->srtt.InMicroseconds(); 1063 return stats->srtt.InMicroseconds();
1064 } 1064 }
1065 1065
1066 bool QuicStreamFactory::WasAlternateProtocolRecentlyBroken( 1066 bool QuicStreamFactory::WasAlternativeServiceRecentlyBroken(
1067 const QuicServerId& server_id) const { 1067 const QuicServerId& server_id) const {
1068 return http_server_properties_ && 1068 if (!http_server_properties_)
1069 http_server_properties_->WasAlternateProtocolRecentlyBroken( 1069 return false;
1070 server_id.host_port_pair()); 1070 const AlternativeService alternative_service(
1071 QUIC, server_id.host_port_pair().host(),
1072 server_id.host_port_pair().port());
Ryan Hamilton 2015/03/18 22:55:43 You could also add a 2-arg constructor which takes
Bence 2015/03/19 12:45:39 Excellent idea. Done.
1073 return http_server_properties_->WasAlternativeServiceRecentlyBroken(
1074 alternative_service);
1071 } 1075 }
1072 1076
1073 bool QuicStreamFactory::CryptoConfigCacheIsEmpty( 1077 bool QuicStreamFactory::CryptoConfigCacheIsEmpty(
1074 const QuicServerId& server_id) { 1078 const QuicServerId& server_id) {
1075 QuicCryptoClientConfig::CachedState* cached = 1079 QuicCryptoClientConfig::CachedState* cached =
1076 crypto_config_.LookupOrCreate(server_id); 1080 crypto_config_.LookupOrCreate(server_id);
1077 return cached->IsEmpty(); 1081 return cached->IsEmpty();
1078 } 1082 }
1079 1083
1080 void QuicStreamFactory::InitializeCachedStateInCryptoConfig( 1084 void QuicStreamFactory::InitializeCachedStateInCryptoConfig(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1162 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1159 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1163 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1160 // it as recently broken, which means that 0-RTT will be disabled but we'll 1164 // it as recently broken, which means that 0-RTT will be disabled but we'll
1161 // still race. 1165 // still race.
1162 const HostPortPair& server = server_id.host_port_pair(); 1166 const HostPortPair& server = server_id.host_port_pair();
1163 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1167 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1164 AlternativeService(QUIC, server.host(), server.port())); 1168 AlternativeService(QUIC, server.host(), server.port()));
1165 } 1169 }
1166 1170
1167 } // namespace net 1171 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698