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 <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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 DCHECK(cached); | 596 DCHECK(cached); |
597 if (cached->IsEmpty()) { | 597 if (cached->IsEmpty()) { |
598 quic_server_info = quic_server_info_factory_->GetForServer(server_id); | 598 quic_server_info = quic_server_info_factory_->GetForServer(server_id); |
599 } | 599 } |
600 } | 600 } |
601 // TODO(rtenneti): Initialize task_runner_ in the constructor after | 601 // TODO(rtenneti): Initialize task_runner_ in the constructor after |
602 // WebRequestActionWithThreadsTest.* tests are fixed. | 602 // WebRequestActionWithThreadsTest.* tests are fixed. |
603 if (!task_runner_) | 603 if (!task_runner_) |
604 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); | 604 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); |
605 | 605 |
606 bool was_alternate_protocol_recently_broken = | 606 bool was_alternate_protocol_recently_broken = false; |
607 http_server_properties_ && | 607 if (http_server_properties_ && |
608 http_server_properties_->WasAlternateProtocolRecentlyBroken( | 608 http_server_properties_->HasAlternateProtocol( |
609 server_id.host_port_pair()); | 609 server_id.host_port_pair())) { |
| 610 AlternateProtocols alternate_protocols = |
| 611 http_server_properties_->GetAlternateProtocol( |
| 612 server_id.host_port_pair()); |
| 613 AlternateProtocolInfo alternate_protocol = alternate_protocols[0]; |
| 614 was_alternate_protocol_recently_broken = |
| 615 http_server_properties_->WasAlternateProtocolRecentlyBroken( |
| 616 server_id.host_port_pair(), alternate_protocol); |
| 617 } |
610 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, is_https, | 618 scoped_ptr<Job> job(new Job(this, host_resolver_, host_port_pair, is_https, |
611 was_alternate_protocol_recently_broken, | 619 was_alternate_protocol_recently_broken, |
612 privacy_mode, method, quic_server_info, net_log)); | 620 privacy_mode, method, quic_server_info, net_log)); |
613 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, | 621 int rv = job->Run(base::Bind(&QuicStreamFactory::OnJobComplete, |
614 base::Unretained(this), job.get())); | 622 base::Unretained(this), job.get())); |
615 | 623 |
616 if (rv == ERR_IO_PENDING) { | 624 if (rv == ERR_IO_PENDING) { |
617 active_requests_[request] = job.get(); | 625 active_requests_[request] = job.get(); |
618 job_requests_map_[job.get()].insert(request); | 626 job_requests_map_[job.get()].insert(request); |
619 active_jobs_[server_id] = job.release(); | 627 active_jobs_[server_id] = job.release(); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 // alternate-protocol state is unknown. | 1042 // alternate-protocol state is unknown. |
1035 if (!http_server_properties_->HasAlternateProtocol(server)) | 1043 if (!http_server_properties_->HasAlternateProtocol(server)) |
1036 return; | 1044 return; |
1037 | 1045 |
1038 // TODO(rch): In the special case where the session has received no | 1046 // TODO(rch): In the special case where the session has received no |
1039 // packets from the peer, we should consider blacklisting this | 1047 // packets from the peer, we should consider blacklisting this |
1040 // differently so that we still race TCP but we don't consider the | 1048 // differently so that we still race TCP but we don't consider the |
1041 // session connected until the handshake has been confirmed. | 1049 // session connected until the handshake has been confirmed. |
1042 HistogramBrokenAlternateProtocolLocation( | 1050 HistogramBrokenAlternateProtocolLocation( |
1043 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY); | 1051 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY); |
1044 AlternateProtocolInfo alternate = | 1052 |
| 1053 const AlternateProtocols alternate_protocols = |
1045 http_server_properties_->GetAlternateProtocol(server); | 1054 http_server_properties_->GetAlternateProtocol(server); |
1046 DCHECK_EQ(QUIC, alternate.protocol); | 1055 AlternateProtocols::const_iterator alternate; |
| 1056 for (alternate = alternate_protocols.begin(); |
| 1057 alternate != alternate_protocols.end(); |
| 1058 ++alternate) { |
| 1059 if (alternate->protocol == QUIC) { |
| 1060 break; |
| 1061 } |
| 1062 } |
| 1063 // Do not use DCHECK_NE as operator<<(ostream, iterator) is not defined. |
| 1064 DCHECK(alternate != alternate_protocols.end()) |
| 1065 << "No QUIC alternate protocol found"; |
1047 | 1066 |
1048 // Since the session was active, there's no longer an | 1067 // Since the session was active, there's no longer an |
1049 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the | 1068 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the |
1050 // TCP job also fails. So to avoid not using QUIC when we otherwise could, | 1069 // TCP job also fails. So to avoid not using QUIC when we otherwise could, |
1051 // we mark it as broken, and then immediately re-enable it. This leaves | 1070 // we mark it as broken, and then immediately re-enable it. This leaves |
1052 // QUIC as "recently broken" which means that 0-RTT will be disabled but | 1071 // QUIC as "recently broken" which means that 0-RTT will be disabled but |
1053 // we'll still race. | 1072 // we'll still race. |
1054 http_server_properties_->SetBrokenAlternateProtocol(server); | 1073 http_server_properties_->SetBrokenAlternateProtocol(server, *alternate); |
1055 http_server_properties_->ClearAlternateProtocol(server); | 1074 http_server_properties_->RemoveAlternateProtocol(server, *alternate); |
1056 http_server_properties_->SetAlternateProtocol( | 1075 http_server_properties_->AddAlternateProtocol( |
1057 server, alternate.port, alternate.protocol, 1); | 1076 server, alternate->port, alternate->protocol, 1); |
1058 DCHECK_EQ(QUIC, | |
1059 http_server_properties_->GetAlternateProtocol(server).protocol); | |
1060 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1077 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
1061 server)); | 1078 server, *alternate)); |
1062 } | 1079 } |
1063 | 1080 |
1064 } // namespace net | 1081 } // namespace net |
OLD | NEW |