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

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

Issue 1393713003: Remove insecure QUIC support from Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 2 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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 QuicPacketWriter* DefaultPacketWriterFactory::Create( 116 QuicPacketWriter* DefaultPacketWriterFactory::Create(
117 QuicConnection* connection) const { 117 QuicConnection* connection) const {
118 scoped_ptr<QuicDefaultPacketWriter> writer( 118 scoped_ptr<QuicDefaultPacketWriter> writer(
119 new QuicDefaultPacketWriter(socket_)); 119 new QuicDefaultPacketWriter(socket_));
120 writer->SetConnection(connection); 120 writer->SetConnection(connection);
121 return writer.release(); 121 return writer.release();
122 } 122 }
123 123
124 } // namespace 124 } // namespace
125 125
126 QuicStreamFactory::IpAliasKey::IpAliasKey() {}
127
128 QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint,
129 bool is_https)
130 : ip_endpoint(ip_endpoint),
131 is_https(is_https) {}
132
133 QuicStreamFactory::IpAliasKey::~IpAliasKey() {}
134
135 bool QuicStreamFactory::IpAliasKey::operator<(
136 const QuicStreamFactory::IpAliasKey& other) const {
137 if (!(ip_endpoint == other.ip_endpoint)) {
138 return ip_endpoint < other.ip_endpoint;
139 }
140 return is_https < other.is_https;
141 }
142
143 bool QuicStreamFactory::IpAliasKey::operator==(
144 const QuicStreamFactory::IpAliasKey& other) const {
145 return is_https == other.is_https &&
146 ip_endpoint == other.ip_endpoint;
147 };
148
149 // Responsible for creating a new QUIC session to the specified server, and 126 // Responsible for creating a new QUIC session to the specified server, and
150 // for notifying any associated requests when complete. 127 // for notifying any associated requests when complete.
151 class QuicStreamFactory::Job { 128 class QuicStreamFactory::Job {
152 public: 129 public:
153 Job(QuicStreamFactory* factory, 130 Job(QuicStreamFactory* factory,
154 HostResolver* host_resolver, 131 HostResolver* host_resolver,
155 const HostPortPair& host_port_pair, 132 const HostPortPair& host_port_pair,
156 bool server_and_origin_have_same_host, 133 bool server_and_origin_have_same_host,
157 bool is_https,
158 bool was_alternative_service_recently_broken, 134 bool was_alternative_service_recently_broken,
159 PrivacyMode privacy_mode, 135 PrivacyMode privacy_mode,
160 int cert_verify_flags, 136 int cert_verify_flags,
161 bool is_post, 137 bool is_post,
162 QuicServerInfo* server_info, 138 QuicServerInfo* server_info,
163 const BoundNetLog& net_log); 139 const BoundNetLog& net_log);
164 140
165 // Creates a new job to handle the resumption of for connecting an 141 // Creates a new job to handle the resumption of for connecting an
166 // existing session. 142 // existing session.
167 Job(QuicStreamFactory* factory, 143 Job(QuicStreamFactory* factory,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 base::TimeTicks dns_resolution_start_time_; 200 base::TimeTicks dns_resolution_start_time_;
225 base::TimeTicks dns_resolution_end_time_; 201 base::TimeTicks dns_resolution_end_time_;
226 base::WeakPtrFactory<Job> weak_factory_; 202 base::WeakPtrFactory<Job> weak_factory_;
227 DISALLOW_COPY_AND_ASSIGN(Job); 203 DISALLOW_COPY_AND_ASSIGN(Job);
228 }; 204 };
229 205
230 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, 206 QuicStreamFactory::Job::Job(QuicStreamFactory* factory,
231 HostResolver* host_resolver, 207 HostResolver* host_resolver,
232 const HostPortPair& host_port_pair, 208 const HostPortPair& host_port_pair,
233 bool server_and_origin_have_same_host, 209 bool server_and_origin_have_same_host,
234 bool is_https,
235 bool was_alternative_service_recently_broken, 210 bool was_alternative_service_recently_broken,
236 PrivacyMode privacy_mode, 211 PrivacyMode privacy_mode,
237 int cert_verify_flags, 212 int cert_verify_flags,
238 bool is_post, 213 bool is_post,
239 QuicServerInfo* server_info, 214 QuicServerInfo* server_info,
240 const BoundNetLog& net_log) 215 const BoundNetLog& net_log)
241 : io_state_(STATE_RESOLVE_HOST), 216 : io_state_(STATE_RESOLVE_HOST),
242 factory_(factory), 217 factory_(factory),
243 host_resolver_(host_resolver), 218 host_resolver_(host_resolver),
244 server_id_(host_port_pair, is_https, privacy_mode), 219 server_id_(host_port_pair, /*is_https=*/true, privacy_mode),
245 cert_verify_flags_(cert_verify_flags), 220 cert_verify_flags_(cert_verify_flags),
246 server_and_origin_have_same_host_(server_and_origin_have_same_host), 221 server_and_origin_have_same_host_(server_and_origin_have_same_host),
247 is_post_(is_post), 222 is_post_(is_post),
248 was_alternative_service_recently_broken_( 223 was_alternative_service_recently_broken_(
249 was_alternative_service_recently_broken), 224 was_alternative_service_recently_broken),
250 server_info_(server_info), 225 server_info_(server_info),
251 started_another_job_(false), 226 started_another_job_(false),
252 net_log_(net_log), 227 net_log_(net_log),
253 session_(nullptr), 228 session_(nullptr),
254 weak_factory_(this) { 229 weak_factory_(this) {}
255 }
256 230
257 QuicStreamFactory::Job::Job(QuicStreamFactory* factory, 231 QuicStreamFactory::Job::Job(QuicStreamFactory* factory,
258 HostResolver* host_resolver, 232 HostResolver* host_resolver,
259 QuicChromiumClientSession* session, 233 QuicChromiumClientSession* session,
260 QuicServerId server_id) 234 QuicServerId server_id)
261 : io_state_(STATE_RESUME_CONNECT), 235 : io_state_(STATE_RESUME_CONNECT),
262 factory_(factory), 236 factory_(factory),
263 host_resolver_(host_resolver), // unused 237 host_resolver_(host_resolver), // unused
264 server_id_(server_id), 238 server_id_(server_id),
265 cert_verify_flags_(0), // unused 239 cert_verify_flags_(0), // unused
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 482
509 QuicStreamRequest::QuicStreamRequest(QuicStreamFactory* factory) 483 QuicStreamRequest::QuicStreamRequest(QuicStreamFactory* factory)
510 : factory_(factory) {} 484 : factory_(factory) {}
511 485
512 QuicStreamRequest::~QuicStreamRequest() { 486 QuicStreamRequest::~QuicStreamRequest() {
513 if (factory_ && !callback_.is_null()) 487 if (factory_ && !callback_.is_null())
514 factory_->CancelRequest(this); 488 factory_->CancelRequest(this);
515 } 489 }
516 490
517 int QuicStreamRequest::Request(const HostPortPair& host_port_pair, 491 int QuicStreamRequest::Request(const HostPortPair& host_port_pair,
518 bool is_https,
519 PrivacyMode privacy_mode, 492 PrivacyMode privacy_mode,
520 int cert_verify_flags, 493 int cert_verify_flags,
521 base::StringPiece origin_host, 494 base::StringPiece origin_host,
522 base::StringPiece method, 495 base::StringPiece method,
523 const BoundNetLog& net_log, 496 const BoundNetLog& net_log,
524 const CompletionCallback& callback) { 497 const CompletionCallback& callback) {
525 DCHECK(!stream_); 498 DCHECK(!stream_);
526 DCHECK(callback_.is_null()); 499 DCHECK(callback_.is_null());
527 DCHECK(factory_); 500 DCHECK(factory_);
528 origin_host_ = origin_host.as_string(); 501 origin_host_ = origin_host.as_string();
529 privacy_mode_ = privacy_mode; 502 privacy_mode_ = privacy_mode;
530 int rv = 503 int rv = factory_->Create(host_port_pair, privacy_mode, cert_verify_flags,
531 factory_->Create(host_port_pair, is_https, privacy_mode, 504 origin_host, method, net_log, this);
532 cert_verify_flags, origin_host, method, net_log, this);
533 if (rv == ERR_IO_PENDING) { 505 if (rv == ERR_IO_PENDING) {
534 host_port_pair_ = host_port_pair; 506 host_port_pair_ = host_port_pair;
535 is_https_ = is_https;
536 net_log_ = net_log; 507 net_log_ = net_log;
537 callback_ = callback; 508 callback_ = callback;
538 } else { 509 } else {
539 factory_ = nullptr; 510 factory_ = nullptr;
540 } 511 }
541 if (rv == OK) 512 if (rv == OK)
542 DCHECK(stream_); 513 DCHECK(stream_);
543 return rv; 514 return rv;
544 } 515 }
545 516
546 void QuicStreamRequest::set_stream(scoped_ptr<QuicHttpStream> stream) { 517 void QuicStreamRequest::set_stream(scoped_ptr<QuicHttpStream> stream) {
547 DCHECK(stream); 518 DCHECK(stream);
548 stream_ = stream.Pass(); 519 stream_ = stream.Pass();
549 } 520 }
550 521
551 void QuicStreamRequest::OnRequestComplete(int rv) { 522 void QuicStreamRequest::OnRequestComplete(int rv) {
552 factory_ = nullptr; 523 factory_ = nullptr;
553 callback_.Run(rv); 524 callback_.Run(rv);
554 } 525 }
555 526
556 base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const { 527 base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const {
557 if (!factory_) 528 if (!factory_)
558 return base::TimeDelta(); 529 return base::TimeDelta();
559 return factory_->GetTimeDelayForWaitingJob( 530 return factory_->GetTimeDelayForWaitingJob(
560 QuicServerId(host_port_pair_, is_https_, privacy_mode_)); 531 QuicServerId(host_port_pair_, /*is_https=*/true, privacy_mode_));
561 } 532 }
562 533
563 scoped_ptr<QuicHttpStream> QuicStreamRequest::ReleaseStream() { 534 scoped_ptr<QuicHttpStream> QuicStreamRequest::ReleaseStream() {
564 DCHECK(stream_); 535 DCHECK(stream_);
565 return stream_.Pass(); 536 return stream_.Pass();
566 } 537 }
567 538
568 QuicStreamFactory::QuicStreamFactory( 539 QuicStreamFactory::QuicStreamFactory(
569 HostResolver* host_resolver, 540 HostResolver* host_resolver,
570 ClientSocketFactory* client_socket_factory, 541 ClientSocketFactory* client_socket_factory,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 int64 srtt = 1.5 * GetServerNetworkStatsSmoothedRttInMicroseconds(server_id); 667 int64 srtt = 1.5 * GetServerNetworkStatsSmoothedRttInMicroseconds(server_id);
697 // Picked 300ms based on mean time from 668 // Picked 300ms based on mean time from
698 // Net.QuicSession.HostResolution.HandshakeConfirmedTime histogram. 669 // Net.QuicSession.HostResolution.HandshakeConfirmedTime histogram.
699 const int kDefaultRTT = 300 * kNumMicrosPerMilli; 670 const int kDefaultRTT = 300 * kNumMicrosPerMilli;
700 if (!srtt) 671 if (!srtt)
701 srtt = kDefaultRTT; 672 srtt = kDefaultRTT;
702 return base::TimeDelta::FromMicroseconds(srtt); 673 return base::TimeDelta::FromMicroseconds(srtt);
703 } 674 }
704 675
705 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, 676 int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
706 bool is_https,
707 PrivacyMode privacy_mode, 677 PrivacyMode privacy_mode,
708 int cert_verify_flags, 678 int cert_verify_flags,
709 base::StringPiece origin_host, 679 base::StringPiece origin_host,
710 base::StringPiece method, 680 base::StringPiece method,
711 const BoundNetLog& net_log, 681 const BoundNetLog& net_log,
712 QuicStreamRequest* request) { 682 QuicStreamRequest* request) {
713 QuicServerId server_id(host_port_pair, is_https, privacy_mode); 683 QuicServerId server_id(host_port_pair, /*is_https=*/true, privacy_mode);
714 SessionMap::iterator it = active_sessions_.find(server_id); 684 SessionMap::iterator it = active_sessions_.find(server_id);
715 if (it != active_sessions_.end()) { 685 if (it != active_sessions_.end()) {
716 QuicChromiumClientSession* session = it->second; 686 QuicChromiumClientSession* session = it->second;
717 if (!session->CanPool(origin_host.as_string(), privacy_mode)) 687 if (!session->CanPool(origin_host.as_string(), privacy_mode))
718 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN; 688 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN;
719 request->set_stream(CreateFromSession(session)); 689 request->set_stream(CreateFromSession(session));
720 return OK; 690 return OK;
721 } 691 }
722 692
723 if (HasActiveJob(server_id)) { 693 if (HasActiveJob(server_id)) {
(...skipping 19 matching lines...) Expand all
743 // don't wait for Cache thread to load the data for that server. 713 // don't wait for Cache thread to load the data for that server.
744 load_from_disk_cache = false; 714 load_from_disk_cache = false;
745 } 715 }
746 } 716 }
747 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) { 717 if (load_from_disk_cache && CryptoConfigCacheIsEmpty(server_id)) {
748 quic_server_info = quic_server_info_factory_->GetForServer(server_id); 718 quic_server_info = quic_server_info_factory_->GetForServer(server_id);
749 } 719 }
750 } 720 }
751 721
752 bool server_and_origin_have_same_host = host_port_pair.host() == origin_host; 722 bool server_and_origin_have_same_host = host_port_pair.host() == origin_host;
753 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, 723 scoped_ptr<Job> job(new Job(
754 server_and_origin_have_same_host, is_https, 724 this, host_resolver_, host_port_pair, server_and_origin_have_same_host,
755 WasQuicRecentlyBroken(server_id), privacy_mode, 725 WasQuicRecentlyBroken(server_id), privacy_mode, cert_verify_flags,
756 cert_verify_flags, method == "POST" /* is_post */, 726 method == "POST" /* is_post */, quic_server_info, net_log));
757 quic_server_info, net_log));
758 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, 727 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete,
759 base::Unretained(this), job.get())); 728 base::Unretained(this), job.get()));
760 if (rv == ERR_IO_PENDING) { 729 if (rv == ERR_IO_PENDING) {
761 active_requests_[request] = server_id; 730 active_requests_[request] = server_id;
762 job_requests_map_[server_id].insert(request); 731 job_requests_map_[server_id].insert(request);
763 active_jobs_[server_id].insert(job.release()); 732 active_jobs_[server_id].insert(job.release());
764 return rv; 733 return rv;
765 } 734 }
766 if (rv == OK) { 735 if (rv == OK) {
767 it = active_sessions_.find(server_id); 736 it = active_sessions_.find(server_id);
768 DCHECK(it != active_sessions_.end()); 737 DCHECK(it != active_sessions_.end());
769 QuicChromiumClientSession* session = it->second; 738 QuicChromiumClientSession* session = it->second;
770 if (!session->CanPool(origin_host.as_string(), privacy_mode)) 739 if (!session->CanPool(origin_host.as_string(), privacy_mode))
771 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN; 740 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN;
772 request->set_stream(CreateFromSession(session)); 741 request->set_stream(CreateFromSession(session));
773 } 742 }
774 return rv; 743 return rv;
775 } 744 }
776 745
777 void QuicStreamFactory::CreateAuxilaryJob(const QuicServerId server_id, 746 void QuicStreamFactory::CreateAuxilaryJob(const QuicServerId server_id,
778 int cert_verify_flags, 747 int cert_verify_flags,
779 bool server_and_origin_have_same_host, 748 bool server_and_origin_have_same_host,
780 bool is_post, 749 bool is_post,
781 const BoundNetLog& net_log) { 750 const BoundNetLog& net_log) {
782 Job* aux_job = 751 Job* aux_job = new Job(
783 new Job(this, host_resolver_, server_id.host_port_pair(), 752 this, host_resolver_, server_id.host_port_pair(),
784 server_and_origin_have_same_host, server_id.is_https(), 753 server_and_origin_have_same_host, WasQuicRecentlyBroken(server_id),
785 WasQuicRecentlyBroken(server_id), server_id.privacy_mode(), 754 server_id.privacy_mode(), cert_verify_flags, is_post, nullptr, net_log);
786 cert_verify_flags, is_post, nullptr, net_log);
787 active_jobs_[server_id].insert(aux_job); 755 active_jobs_[server_id].insert(aux_job);
788 task_runner_->PostTask(FROM_HERE, 756 task_runner_->PostTask(FROM_HERE,
789 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob, 757 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob,
790 aux_job->GetWeakPtr())); 758 aux_job->GetWeakPtr()));
791 } 759 }
792 760
793 bool QuicStreamFactory::OnResolution( 761 bool QuicStreamFactory::OnResolution(
794 const QuicServerId& server_id, 762 const QuicServerId& server_id,
795 const AddressList& address_list) { 763 const AddressList& address_list) {
796 DCHECK(!HasActiveSession(server_id)); 764 DCHECK(!HasActiveSession(server_id));
797 if (disable_connection_pooling_) { 765 if (disable_connection_pooling_) {
798 return false; 766 return false;
799 } 767 }
800 for (const IPEndPoint& address : address_list) { 768 for (const IPEndPoint& address : address_list) {
801 const IpAliasKey ip_alias_key(address, server_id.is_https()); 769 if (!ContainsKey(ip_aliases_, address))
802 if (!ContainsKey(ip_aliases_, ip_alias_key))
803 continue; 770 continue;
804 771
805 const SessionSet& sessions = ip_aliases_[ip_alias_key]; 772 const SessionSet& sessions = ip_aliases_[address];
806 for (QuicChromiumClientSession* session : sessions) { 773 for (QuicChromiumClientSession* session : sessions) {
807 if (!session->CanPool(server_id.host(), server_id.privacy_mode())) 774 if (!session->CanPool(server_id.host(), server_id.privacy_mode()))
808 continue; 775 continue;
809 active_sessions_[server_id] = session; 776 active_sessions_[server_id] = session;
810 session_aliases_[session].insert(server_id); 777 session_aliases_[session].insert(server_id);
811 return true; 778 return true;
812 } 779 }
813 } 780 }
814 return false; 781 return false;
815 } 782 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 // port suggestions. 943 // port suggestions.
977 if (session->goaway_received()) { 944 if (session->goaway_received()) {
978 gone_away_aliases_.insert(*it); 945 gone_away_aliases_.insert(*it);
979 } 946 }
980 947
981 active_sessions_.erase(*it); 948 active_sessions_.erase(*it);
982 ProcessGoingAwaySession(session, *it, true); 949 ProcessGoingAwaySession(session, *it, true);
983 } 950 }
984 ProcessGoingAwaySession(session, all_sessions_[session], false); 951 ProcessGoingAwaySession(session, all_sessions_[session], false);
985 if (!aliases.empty()) { 952 if (!aliases.empty()) {
986 const IpAliasKey ip_alias_key(session->connection()->peer_address(), 953 const IPEndPoint peer_address = session->connection()->peer_address();
987 aliases.begin()->is_https()); 954 ip_aliases_[peer_address].erase(session);
988 ip_aliases_[ip_alias_key].erase(session); 955 if (ip_aliases_[peer_address].empty()) {
989 if (ip_aliases_[ip_alias_key].empty()) { 956 ip_aliases_.erase(peer_address);
990 ip_aliases_.erase(ip_alias_key);
991 } 957 }
992 } 958 }
993 session_aliases_.erase(session); 959 session_aliases_.erase(session);
994 } 960 }
995 961
996 void QuicStreamFactory::MaybeDisableQuic(QuicChromiumClientSession* session) { 962 void QuicStreamFactory::MaybeDisableQuic(QuicChromiumClientSession* session) {
997 DCHECK(session); 963 DCHECK(session);
998 uint16 port = session->server_id().port(); 964 uint16 port = session->server_id().port();
999 if (IsQuicDisabled(port)) 965 if (IsQuicDisabled(port))
1000 return; 966 return;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 ++it) { 1032 ++it) {
1067 DCHECK(active_sessions_.count(*it)); 1033 DCHECK(active_sessions_.count(*it));
1068 DCHECK_EQ(session, active_sessions_[*it]); 1034 DCHECK_EQ(session, active_sessions_[*it]);
1069 active_sessions_.erase(*it); 1035 active_sessions_.erase(*it);
1070 } 1036 }
1071 1037
1072 if (aliases.empty()) { 1038 if (aliases.empty()) {
1073 return; 1039 return;
1074 } 1040 }
1075 1041
1076 const IpAliasKey ip_alias_key(session->connection()->peer_address(), 1042 const IPEndPoint peer_address = session->connection()->peer_address();
1077 aliases.begin()->is_https()); 1043 ip_aliases_[peer_address].erase(session);
1078 ip_aliases_[ip_alias_key].erase(session); 1044 if (ip_aliases_[peer_address].empty()) {
1079 if (ip_aliases_[ip_alias_key].empty()) { 1045 ip_aliases_.erase(peer_address);
1080 ip_aliases_.erase(ip_alias_key);
1081 } 1046 }
1082 QuicServerId server_id = *aliases.begin(); 1047 QuicServerId server_id = *aliases.begin();
1083 session_aliases_.erase(session); 1048 session_aliases_.erase(session);
1084 Job* job = new Job(this, host_resolver_, session, server_id); 1049 Job* job = new Job(this, host_resolver_, session, server_id);
1085 active_jobs_[server_id].insert(job); 1050 active_jobs_[server_id].insert(job);
1086 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, 1051 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete,
1087 base::Unretained(this), job)); 1052 base::Unretained(this), job));
1088 DCHECK_EQ(ERR_IO_PENDING, rv); 1053 DCHECK_EQ(ERR_IO_PENDING, rv);
1089 } 1054 }
1090 1055
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 DefaultPacketWriterFactory packet_writer_factory(socket.get()); 1215 DefaultPacketWriterFactory packet_writer_factory(socket.get());
1251 1216
1252 if (!helper_.get()) { 1217 if (!helper_.get()) {
1253 helper_.reset( 1218 helper_.reset(
1254 new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(), 1219 new QuicConnectionHelper(base::ThreadTaskRunnerHandle::Get().get(),
1255 clock_.get(), random_generator_)); 1220 clock_.get(), random_generator_));
1256 } 1221 }
1257 1222
1258 QuicConnection* connection = new QuicConnection( 1223 QuicConnection* connection = new QuicConnection(
1259 connection_id, addr, helper_.get(), packet_writer_factory, 1224 connection_id, addr, helper_.get(), packet_writer_factory,
1260 true /* owns_writer */, Perspective::IS_CLIENT, server_id.is_https(), 1225 true /* owns_writer */, Perspective::IS_CLIENT, /*is_https=*/true,
1261 supported_versions_); 1226 supported_versions_);
1262 connection->SetMaxPacketLength(max_packet_length_); 1227 connection->SetMaxPacketLength(max_packet_length_);
1263 1228
1264 InitializeCachedStateInCryptoConfig(server_id, server_info); 1229 InitializeCachedStateInCryptoConfig(server_id, server_info);
1265 1230
1266 QuicConfig config = config_; 1231 QuicConfig config = config_;
1267 config.SetSocketReceiveBufferToSend(socket_receive_buffer_size_); 1232 config.SetSocketReceiveBufferToSend(socket_receive_buffer_size_);
1268 config.set_max_undecryptable_packets(kMaxUndecryptablePackets); 1233 config.set_max_undecryptable_packets(kMaxUndecryptablePackets);
1269 config.SetInitialSessionFlowControlWindowToSend( 1234 config.SetInitialSessionFlowControlWindowToSend(
1270 kQuicSessionMaxRecvWindowSize); 1235 kQuicSessionMaxRecvWindowSize);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 } 1278 }
1314 return OK; 1279 return OK;
1315 } 1280 }
1316 1281
1317 void QuicStreamFactory::ActivateSession(const QuicServerId& server_id, 1282 void QuicStreamFactory::ActivateSession(const QuicServerId& server_id,
1318 QuicChromiumClientSession* session) { 1283 QuicChromiumClientSession* session) {
1319 DCHECK(!HasActiveSession(server_id)); 1284 DCHECK(!HasActiveSession(server_id));
1320 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); 1285 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size());
1321 active_sessions_[server_id] = session; 1286 active_sessions_[server_id] = session;
1322 session_aliases_[session].insert(server_id); 1287 session_aliases_[session].insert(server_id);
1323 const IpAliasKey ip_alias_key(session->connection()->peer_address(), 1288 const IPEndPoint peer_address = session->connection()->peer_address();
1324 server_id.is_https()); 1289 DCHECK(!ContainsKey(ip_aliases_[peer_address], session));
1325 DCHECK(!ContainsKey(ip_aliases_[ip_alias_key], session)); 1290 ip_aliases_[peer_address].insert(session);
1326 ip_aliases_[ip_alias_key].insert(session);
1327 } 1291 }
1328 1292
1329 int64 QuicStreamFactory::GetServerNetworkStatsSmoothedRttInMicroseconds( 1293 int64 QuicStreamFactory::GetServerNetworkStatsSmoothedRttInMicroseconds(
1330 const QuicServerId& server_id) const { 1294 const QuicServerId& server_id) const {
1331 if (!http_server_properties_) 1295 if (!http_server_properties_)
1332 return 0; 1296 return 0;
1333 const ServerNetworkStats* stats = 1297 const ServerNetworkStats* stats =
1334 http_server_properties_->GetServerNetworkStats( 1298 http_server_properties_->GetServerNetworkStats(
1335 server_id.host_port_pair()); 1299 server_id.host_port_pair());
1336 if (stats == nullptr) 1300 if (stats == nullptr)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 // If the AlternativeServiceMap contained an entry for this host, check if 1338 // If the AlternativeServiceMap contained an entry for this host, check if
1375 // the disk cache contained an entry for it. 1339 // the disk cache contained an entry for it.
1376 if (ContainsKey(quic_supported_servers_at_startup_, 1340 if (ContainsKey(quic_supported_servers_at_startup_,
1377 server_id.host_port_pair())) { 1341 server_id.host_port_pair())) {
1378 UMA_HISTOGRAM_BOOLEAN( 1342 UMA_HISTOGRAM_BOOLEAN(
1379 "Net.QuicServerInfo.ExpectConfigMissingFromDiskCache", 1343 "Net.QuicServerInfo.ExpectConfigMissingFromDiskCache",
1380 server_info->state().server_config.empty()); 1344 server_info->state().server_config.empty());
1381 } 1345 }
1382 } 1346 }
1383 1347
1384 if (!cached->Initialize(server_info->state().server_config, 1348 cached->Initialize(server_info->state().server_config,
1385 server_info->state().source_address_token, 1349 server_info->state().source_address_token,
1386 server_info->state().certs, 1350 server_info->state().certs,
1387 server_info->state().server_config_sig, 1351 server_info->state().server_config_sig, clock_->WallNow());
1388 clock_->WallNow()))
1389 return;
1390
1391 if (!server_id.is_https()) {
1392 // Don't check the certificates for insecure QUIC.
1393 cached->SetProofValid();
1394 }
1395 } 1352 }
1396 1353
1397 void QuicStreamFactory::InitializeQuicSupportedServersAtStartup() { 1354 void QuicStreamFactory::InitializeQuicSupportedServersAtStartup() {
1398 DCHECK(http_server_properties_); 1355 DCHECK(http_server_properties_);
1399 DCHECK(!quic_supported_servers_at_startup_initialzied_); 1356 DCHECK(!quic_supported_servers_at_startup_initialzied_);
1400 quic_supported_servers_at_startup_initialzied_ = true; 1357 quic_supported_servers_at_startup_initialzied_ = true;
1401 for (const std::pair<const HostPortPair, AlternativeServiceInfoVector>& 1358 for (const std::pair<const HostPortPair, AlternativeServiceInfoVector>&
1402 key_value : http_server_properties_->alternative_service_map()) { 1359 key_value : http_server_properties_->alternative_service_map()) {
1403 for (const AlternativeServiceInfo& alternative_service_info : 1360 for (const AlternativeServiceInfo& alternative_service_info :
1404 key_value.second) { 1361 key_value.second) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 // Since the session was active, there's no longer an 1403 // Since the session was active, there's no longer an
1447 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1404 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1448 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1405 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1449 // it as recently broken, which means that 0-RTT will be disabled but we'll 1406 // it as recently broken, which means that 0-RTT will be disabled but we'll
1450 // still race. 1407 // still race.
1451 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1408 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1452 alternative_service); 1409 alternative_service);
1453 } 1410 }
1454 1411
1455 } // namespace net 1412 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698