| 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/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, | 92 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, |
| 93 proxy_ssl_config, net_log.net_log()); | 93 proxy_ssl_config, net_log.net_log()); |
| 94 request->AttachJob(job); | 94 request->AttachJob(job); |
| 95 | 95 |
| 96 AlternativeService alternative_service = | 96 AlternativeService alternative_service = |
| 97 GetAlternativeServiceFor(request_info.url); | 97 GetAlternativeServiceFor(request_info.url); |
| 98 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 98 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { |
| 99 // Never share connection with other jobs for FTP requests. | 99 // Never share connection with other jobs for FTP requests. |
| 100 DCHECK(!request_info.url.SchemeIs("ftp")); | 100 DCHECK(!request_info.url.SchemeIs("ftp")); |
| 101 | 101 |
| 102 Job* alternate_job = | 102 Job* alternative_job = |
| 103 new Job(this, session_, request_info, priority, server_ssl_config, | 103 new Job(this, session_, request_info, priority, server_ssl_config, |
| 104 proxy_ssl_config, net_log.net_log()); | 104 proxy_ssl_config, alternative_service, net_log.net_log()); |
| 105 request->AttachJob(alternate_job); | 105 request->AttachJob(alternative_job); |
| 106 alternate_job->MarkAsAlternate(alternative_service); | |
| 107 | 106 |
| 108 job->WaitFor(alternate_job); | 107 job->WaitFor(alternative_job); |
| 109 // Make sure to wait until we call WaitFor(), before starting | 108 // Make sure to wait until we call WaitFor(), before starting |
| 110 // |alternate_job|, otherwise |alternate_job| will not notify |job| | 109 // |alternative_job|, otherwise |alternative_job| will not notify |job| |
| 111 // appropriately. | 110 // appropriately. |
| 112 alternate_job->Start(request); | 111 alternative_job->Start(request); |
| 113 } | 112 } |
| 114 | 113 |
| 115 // Even if |alternate_job| has already finished, it won't have notified the | 114 // Even if |alternative_job| has already finished, it will not have notified |
| 116 // request yet, since we defer that to the next iteration of the MessageLoop, | 115 // the request yet, since we defer that to the next iteration of the |
| 117 // so starting |job| is always safe. | 116 // MessageLoop, so starting |job| is always safe. |
| 118 job->Start(request); | 117 job->Start(request); |
| 119 return request; | 118 return request; |
| 120 } | 119 } |
| 121 | 120 |
| 122 void HttpStreamFactoryImpl::PreconnectStreams( | 121 void HttpStreamFactoryImpl::PreconnectStreams( |
| 123 int num_streams, | 122 int num_streams, |
| 124 const HttpRequestInfo& request_info, | 123 const HttpRequestInfo& request_info, |
| 125 RequestPriority priority, | 124 RequestPriority priority, |
| 126 const SSLConfig& server_ssl_config, | 125 const SSLConfig& server_ssl_config, |
| 127 const SSLConfig& proxy_ssl_config) { | 126 const SSLConfig& proxy_ssl_config) { |
| 128 DCHECK(!for_websockets_); | 127 DCHECK(!for_websockets_); |
| 129 AlternativeService alternative_service = | 128 AlternativeService alternative_service = |
| 130 GetAlternativeServiceFor(request_info.url); | 129 GetAlternativeServiceFor(request_info.url); |
| 131 Job* job = new Job(this, session_, request_info, priority, server_ssl_config, | 130 Job* job = |
| 132 proxy_ssl_config, session_->net_log()); | 131 new Job(this, session_, request_info, priority, server_ssl_config, |
| 133 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 132 proxy_ssl_config, alternative_service, session_->net_log()); |
| 134 job->MarkAsAlternate(alternative_service); | |
| 135 } | |
| 136 preconnect_job_set_.insert(job); | 133 preconnect_job_set_.insert(job); |
| 137 job->Preconnect(num_streams); | 134 job->Preconnect(num_streams); |
| 138 } | 135 } |
| 139 | 136 |
| 140 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { | 137 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { |
| 141 return session_->params().host_mapping_rules; | 138 return session_->params().host_mapping_rules; |
| 142 } | 139 } |
| 143 | 140 |
| 144 AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( | 141 AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor( |
| 145 const GURL& original_url) { | 142 const GURL& original_url) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 delete job; | 263 delete job; |
| 267 } | 264 } |
| 268 | 265 |
| 269 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { | 266 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { |
| 270 preconnect_job_set_.erase(job); | 267 preconnect_job_set_.erase(job); |
| 271 delete job; | 268 delete job; |
| 272 OnPreconnectsCompleteInternal(); | 269 OnPreconnectsCompleteInternal(); |
| 273 } | 270 } |
| 274 | 271 |
| 275 } // namespace net | 272 } // namespace net |
| OLD | NEW |