Chromium Code Reviews| Index: net/http/http_stream_factory_impl_job.cc |
| diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc |
| index 2bdc55e0c595149195a04ef1454e2b02a17ac222..a735fba93dfbb5b8158b15635a39b61af39447e3 100644 |
| --- a/net/http/http_stream_factory_impl_job.cc |
| +++ b/net/http/http_stream_factory_impl_job.cc |
| @@ -562,6 +562,8 @@ int HttpStreamFactoryImpl::Job::DoStart() { |
| origin_ = HostPortPair(request_info_.url.HostNoBrackets(), port); |
| origin_url_ = HttpStreamFactory::ApplyHostMappingRules( |
| request_info_.url, &origin_); |
| + http_pipelining_key_.reset(new HttpPipelinedHost::Key( |
| + origin_, (request_info_.load_flags & LOAD_FORCE_HTTP_PIPELINING) != 0)); |
| net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, |
| HttpStreamJobParameters::Create(request_info_.url, |
| @@ -687,11 +689,15 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
| // connections and thus should make fewer preconnections. Explore |
| // preconnecting fewer than the requested num_connections. |
| existing_available_pipeline_ = stream_factory_->http_pipelined_host_pool_. |
| - IsExistingPipelineAvailableForOrigin(origin_); |
| + IsExistingPipelineAvailableForKey(*http_pipelining_key_.get()); |
| if (existing_available_pipeline_) { |
| return OK; |
| } else { |
| - request_->SetHttpPipeliningKey(origin_); |
| + bool was_new_key = request_->SetHttpPipeliningKey( |
| + *http_pipelining_key_.get()); |
| + if (!was_new_key && http_pipelining_key_->force_pipelining()) { |
| + return ERR_IO_PENDING; |
| + } |
| } |
| } |
| @@ -755,6 +761,11 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { |
| waiting_job_ = NULL; |
| } |
| + if (result < 0 && http_pipelining_key_->force_pipelining()) { |
| + stream_factory_->AbortPipelinedRequestsWithKey( |
| + this, *http_pipelining_key_.get(), result, server_ssl_config_); |
| + } |
| + |
| // |result| may be the result of any of the stacked pools. The following |
| // logic is used when determining how to interpret an error. |
| // If |result| < 0: |
| @@ -887,14 +898,17 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() { |
| bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && |
| request_info_.url.SchemeIs("http"); |
| // TODO(simonjam): Support proxies. |
| - if (existing_available_pipeline_) { |
| + if (existing_available_pipeline_ || |
| + stream_factory_->http_pipelined_host_pool_. |
| + IsExistingPipelineAvailableForKey(*http_pipelining_key_.get())) { |
|
mmenke
2012/02/23 18:54:58
nit: Suggest you indent this 4 spaces, so it's a
James Simonsen
2012/02/23 23:49:46
Done.
|
| stream_.reset(stream_factory_->http_pipelined_host_pool_. |
| - CreateStreamOnExistingPipeline(origin_)); |
| + CreateStreamOnExistingPipeline( |
| + *http_pipelining_key_.get())); |
| CHECK(stream_.get()); |
| } else if (!using_proxy && IsRequestEligibleForPipelining()) { |
| stream_.reset( |
| stream_factory_->http_pipelined_host_pool_.CreateStreamOnNewPipeline( |
| - origin_, |
| + *http_pipelining_key_.get(), |
| connection_.release(), |
| server_ssl_config_, |
| proxy_info_, |
| @@ -1209,10 +1223,13 @@ bool HttpStreamFactoryImpl::Job::IsOrphaned() const { |
| } |
| bool HttpStreamFactoryImpl::Job::IsRequestEligibleForPipelining() { |
| - if (!HttpStreamFactory::http_pipelining_enabled()) { |
| + if (IsPreconnecting() || !request_) { |
| return false; |
| } |
| - if (IsPreconnecting() || !request_) { |
| + if (http_pipelining_key_->force_pipelining()) { |
| + return true; |
| + } |
| + if (!HttpStreamFactory::http_pipelining_enabled()) { |
| return false; |
| } |
| if (using_ssl_) { |
| @@ -1221,8 +1238,8 @@ bool HttpStreamFactoryImpl::Job::IsRequestEligibleForPipelining() { |
| if (request_info_.method != "GET" && request_info_.method != "HEAD") { |
| return false; |
| } |
| - return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( |
| - origin_); |
| + return stream_factory_->http_pipelined_host_pool_.IsKeyEligibleForPipelining( |
| + *http_pipelining_key_.get()); |
| } |
| } // namespace net |