| 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_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void HttpStreamFactoryImpl::Job::Start(Request* request) { | 127 void HttpStreamFactoryImpl::Job::Start(Request* request) { |
| 128 DCHECK(request); | 128 DCHECK(request); |
| 129 request_ = request; | 129 request_ = request; |
| 130 StartInternal(); | 130 StartInternal(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 int HttpStreamFactoryImpl::Job::Preconnect(int num_streams) { | 133 int HttpStreamFactoryImpl::Job::Preconnect(int num_streams) { |
| 134 DCHECK_GT(num_streams, 0); | 134 DCHECK_GT(num_streams, 0); |
| 135 base::WeakPtr<HttpServerProperties> http_server_properties = | 135 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 136 session_->http_server_properties(); | 136 session_->http_server_properties(); |
| 137 if (http_server_properties && http_server_properties->SupportsSpdy( | 137 if (http_server_properties && |
| 138 HostPortPair::FromURL(request_info_.url))) { | 138 http_server_properties->SupportsRequestPriority( |
| 139 HostPortPair::FromURL(request_info_.url))) { |
| 139 num_streams_ = 1; | 140 num_streams_ = 1; |
| 140 } else { | 141 } else { |
| 141 num_streams_ = num_streams; | 142 num_streams_ = num_streams; |
| 142 } | 143 } |
| 143 return StartInternal(); | 144 return StartInternal(); |
| 144 } | 145 } |
| 145 | 146 |
| 146 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth( | 147 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth( |
| 147 const AuthCredentials& credentials) { | 148 const AuthCredentials& credentials) { |
| 148 DCHECK(establishing_tunnel_); | 149 DCHECK(establishing_tunnel_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 161 default: | 162 default: |
| 162 return LOAD_STATE_IDLE; | 163 return LOAD_STATE_IDLE; |
| 163 } | 164 } |
| 164 } | 165 } |
| 165 | 166 |
| 166 void HttpStreamFactoryImpl::Job::MarkAsAlternate( | 167 void HttpStreamFactoryImpl::Job::MarkAsAlternate( |
| 167 const GURL& original_url, | 168 const GURL& original_url, |
| 168 AlternateProtocolInfo alternate) { | 169 AlternateProtocolInfo alternate) { |
| 169 DCHECK(!original_url_.get()); | 170 DCHECK(!original_url_.get()); |
| 170 original_url_.reset(new GURL(original_url)); | 171 original_url_.reset(new GURL(original_url)); |
| 172 alternate_protocol_ = alternate; |
| 171 if (alternate.protocol == QUIC) { | 173 if (alternate.protocol == QUIC) { |
| 172 DCHECK(session_->params().enable_quic); | 174 DCHECK(session_->params().enable_quic); |
| 173 using_quic_ = true; | 175 using_quic_ = true; |
| 174 } | 176 } |
| 175 } | 177 } |
| 176 | 178 |
| 177 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { | 179 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { |
| 178 DCHECK_EQ(STATE_NONE, next_state_); | 180 DCHECK_EQ(STATE_NONE, next_state_); |
| 179 DCHECK_EQ(STATE_NONE, job->next_state_); | 181 DCHECK_EQ(STATE_NONE, job->next_state_); |
| 180 DCHECK(!blocking_job_); | 182 DCHECK(!blocking_job_); |
| (...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 } else { | 1448 } else { |
| 1447 // This job was the normal job, and hence the alternate protocol job lost | 1449 // This job was the normal job, and hence the alternate protocol job lost |
| 1448 // the race. | 1450 // the race. |
| 1449 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE); | 1451 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE); |
| 1450 } | 1452 } |
| 1451 } | 1453 } |
| 1452 | 1454 |
| 1453 void HttpStreamFactoryImpl::Job::MarkOtherJobComplete(const Job& job) { | 1455 void HttpStreamFactoryImpl::Job::MarkOtherJobComplete(const Job& job) { |
| 1454 DCHECK_EQ(STATUS_RUNNING, other_job_status_); | 1456 DCHECK_EQ(STATUS_RUNNING, other_job_status_); |
| 1455 other_job_status_ = job.job_status_; | 1457 other_job_status_ = job.job_status_; |
| 1458 other_job_alternate_protocol_ = job.alternate_protocol_; |
| 1456 MaybeMarkAlternateProtocolBroken(); | 1459 MaybeMarkAlternateProtocolBroken(); |
| 1457 } | 1460 } |
| 1458 | 1461 |
| 1459 void HttpStreamFactoryImpl::Job::MaybeMarkAlternateProtocolBroken() { | 1462 void HttpStreamFactoryImpl::Job::MaybeMarkAlternateProtocolBroken() { |
| 1460 if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING) | 1463 if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING) |
| 1461 return; | 1464 return; |
| 1462 | 1465 |
| 1463 bool is_alternate_protocol_job = original_url_.get() != NULL; | 1466 bool is_alternate_protocol_job = original_url_.get() != NULL; |
| 1464 if (is_alternate_protocol_job) { | 1467 if (is_alternate_protocol_job) { |
| 1465 if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) { | 1468 if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) { |
| 1466 HistogramBrokenAlternateProtocolLocation( | 1469 HistogramBrokenAlternateProtocolLocation( |
| 1467 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); | 1470 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); |
| 1468 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1471 session_->http_server_properties()->SetBrokenAlternateProtocol( |
| 1469 HostPortPair::FromURL(*original_url_)); | 1472 HostPortPair::FromURL(*original_url_)); |
| 1470 } | 1473 } |
| 1471 return; | 1474 return; |
| 1472 } | 1475 } |
| 1473 | 1476 |
| 1474 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { | 1477 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { |
| 1475 HistogramBrokenAlternateProtocolLocation( | 1478 HistogramBrokenAlternateProtocolLocation( |
| 1476 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); | 1479 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); |
| 1477 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1480 session_->http_server_properties()->SetBrokenAlternateProtocol( |
| 1478 HostPortPair::FromURL(request_info_.url)); | 1481 HostPortPair::FromURL(request_info_.url)); |
| 1479 } | 1482 } |
| 1480 } | 1483 } |
| 1481 | 1484 |
| 1482 } // namespace net | 1485 } // namespace net |
| OLD | NEW |