| 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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 WasQuicRecentlyBroken(server_id), privacy_mode, |
| 650 privacy_mode, method == "POST" /* is_post */, | 650 method == "POST" /* is_post */, quic_server_info, |
| 651 quic_server_info, net_log)); | 651 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(), WasQuicRecentlyBroken(server_id), |
| 672 WasAlternateProtocolRecentlyBroken(server_id), | |
| 673 server_id.privacy_mode(), is_post, nullptr, net_log); | 672 server_id.privacy_mode(), is_post, nullptr, net_log); |
| 674 active_jobs_[server_id].insert(aux_job); | 673 active_jobs_[server_id].insert(aux_job); |
| 675 task_runner_->PostTask(FROM_HERE, | 674 task_runner_->PostTask(FROM_HERE, |
| 676 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob, | 675 base::Bind(&QuicStreamFactory::Job::RunAuxilaryJob, |
| 677 aux_job->GetWeakPtr())); | 676 aux_job->GetWeakPtr())); |
| 678 } | 677 } |
| 679 | 678 |
| 680 bool QuicStreamFactory::OnResolution( | 679 bool QuicStreamFactory::OnResolution( |
| 681 const QuicServerId& server_id, | 680 const QuicServerId& server_id, |
| 682 const AddressList& address_list) { | 681 const AddressList& address_list) { |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 if (!http_server_properties_) | 1055 if (!http_server_properties_) |
| 1057 return 0; | 1056 return 0; |
| 1058 const ServerNetworkStats* stats = | 1057 const ServerNetworkStats* stats = |
| 1059 http_server_properties_->GetServerNetworkStats( | 1058 http_server_properties_->GetServerNetworkStats( |
| 1060 server_id.host_port_pair()); | 1059 server_id.host_port_pair()); |
| 1061 if (stats == nullptr) | 1060 if (stats == nullptr) |
| 1062 return 0; | 1061 return 0; |
| 1063 return stats->srtt.InMicroseconds(); | 1062 return stats->srtt.InMicroseconds(); |
| 1064 } | 1063 } |
| 1065 | 1064 |
| 1066 bool QuicStreamFactory::WasAlternateProtocolRecentlyBroken( | 1065 bool QuicStreamFactory::WasQuicRecentlyBroken( |
| 1067 const QuicServerId& server_id) const { | 1066 const QuicServerId& server_id) const { |
| 1068 return http_server_properties_ && | 1067 if (!http_server_properties_) |
| 1069 http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1068 return false; |
| 1070 server_id.host_port_pair()); | 1069 const AlternativeService alternative_service(QUIC, |
| 1070 server_id.host_port_pair()); |
| 1071 return http_server_properties_->WasAlternativeServiceRecentlyBroken( |
| 1072 alternative_service); |
| 1071 } | 1073 } |
| 1072 | 1074 |
| 1073 bool QuicStreamFactory::CryptoConfigCacheIsEmpty( | 1075 bool QuicStreamFactory::CryptoConfigCacheIsEmpty( |
| 1074 const QuicServerId& server_id) { | 1076 const QuicServerId& server_id) { |
| 1075 QuicCryptoClientConfig::CachedState* cached = | 1077 QuicCryptoClientConfig::CachedState* cached = |
| 1076 crypto_config_.LookupOrCreate(server_id); | 1078 crypto_config_.LookupOrCreate(server_id); |
| 1077 return cached->IsEmpty(); | 1079 return cached->IsEmpty(); |
| 1078 } | 1080 } |
| 1079 | 1081 |
| 1080 void QuicStreamFactory::InitializeCachedStateInCryptoConfig( | 1082 void QuicStreamFactory::InitializeCachedStateInCryptoConfig( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1160 // 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 | 1161 // 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 | 1162 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1161 // still race. | 1163 // still race. |
| 1162 const HostPortPair& server = server_id.host_port_pair(); | 1164 const HostPortPair& server = server_id.host_port_pair(); |
| 1163 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1165 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1164 AlternativeService(QUIC, server.host(), server.port())); | 1166 AlternativeService(QUIC, server.host(), server.port())); |
| 1165 } | 1167 } |
| 1166 | 1168 |
| 1167 } // namespace net | 1169 } // namespace net |
| OLD | NEW |