| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 case STATE_INIT_CONNECTION_COMPLETE: | 160 case STATE_INIT_CONNECTION_COMPLETE: |
| 161 case STATE_CREATE_STREAM_COMPLETE: | 161 case STATE_CREATE_STREAM_COMPLETE: |
| 162 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); | 162 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); |
| 163 default: | 163 default: |
| 164 return LOAD_STATE_IDLE; | 164 return LOAD_STATE_IDLE; |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 void HttpStreamFactoryImpl::Job::MarkAsAlternate( | 168 void HttpStreamFactoryImpl::Job::MarkAsAlternate( |
| 169 const GURL& original_url, | 169 const GURL& original_url, |
| 170 AlternateProtocolInfo alternate) { | 170 AlternativeService alternative_service) { |
| 171 DCHECK(!original_url_.get()); | 171 DCHECK(!original_url_.get()); |
| 172 original_url_.reset(new GURL(original_url)); | 172 original_url_.reset(new GURL(original_url)); |
| 173 alternate_protocol_ = alternate; | 173 alternative_service_ = alternative_service; |
| 174 if (alternate.protocol == QUIC) { | 174 if (alternative_service.protocol == QUIC) { |
| 175 DCHECK(session_->params().enable_quic); | 175 DCHECK(session_->params().enable_quic); |
| 176 using_quic_ = true; | 176 using_quic_ = true; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { | 180 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { |
| 181 DCHECK_EQ(STATE_NONE, next_state_); | 181 DCHECK_EQ(STATE_NONE, next_state_); |
| 182 DCHECK_EQ(STATE_NONE, job->next_state_); | 182 DCHECK_EQ(STATE_NONE, job->next_state_); |
| 183 DCHECK(!blocking_job_); | 183 DCHECK(!blocking_job_); |
| 184 DCHECK(!job->waiting_job_); | 184 DCHECK(!job->waiting_job_); |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 } else { | 1474 } else { |
| 1475 // This job was the normal job, and hence the alternate protocol job lost | 1475 // This job was the normal job, and hence the alternate protocol job lost |
| 1476 // the race. | 1476 // the race. |
| 1477 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE); | 1477 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE); |
| 1478 } | 1478 } |
| 1479 } | 1479 } |
| 1480 | 1480 |
| 1481 void HttpStreamFactoryImpl::Job::MarkOtherJobComplete(const Job& job) { | 1481 void HttpStreamFactoryImpl::Job::MarkOtherJobComplete(const Job& job) { |
| 1482 DCHECK_EQ(STATUS_RUNNING, other_job_status_); | 1482 DCHECK_EQ(STATUS_RUNNING, other_job_status_); |
| 1483 other_job_status_ = job.job_status_; | 1483 other_job_status_ = job.job_status_; |
| 1484 other_job_alternate_protocol_ = job.alternate_protocol_; | 1484 other_job_alternative_service_ = job.alternative_service_; |
| 1485 MaybeMarkAlternateProtocolBroken(); | 1485 MaybeMarkAlternateProtocolBroken(); |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 void HttpStreamFactoryImpl::Job::MaybeMarkAlternateProtocolBroken() { | 1488 void HttpStreamFactoryImpl::Job::MaybeMarkAlternateProtocolBroken() { |
| 1489 if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING) | 1489 if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING) |
| 1490 return; | 1490 return; |
| 1491 | 1491 |
| 1492 bool is_alternate_protocol_job = original_url_.get() != NULL; | 1492 bool is_alternate_protocol_job = original_url_.get() != NULL; |
| 1493 if (is_alternate_protocol_job) { | 1493 if (is_alternate_protocol_job) { |
| 1494 if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) { | 1494 if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) { |
| 1495 HistogramBrokenAlternateProtocolLocation( | 1495 HistogramBrokenAlternateProtocolLocation( |
| 1496 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); | 1496 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); |
| 1497 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1497 session_->http_server_properties()->SetBrokenAlternateProtocol( |
| 1498 HostPortPair::FromURL(*original_url_)); | 1498 HostPortPair::FromURL(*original_url_)); |
| 1499 } | 1499 } |
| 1500 return; | 1500 return; |
| 1501 } | 1501 } |
| 1502 | 1502 |
| 1503 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { | 1503 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { |
| 1504 HistogramBrokenAlternateProtocolLocation( | 1504 HistogramBrokenAlternateProtocolLocation( |
| 1505 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); | 1505 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); |
| 1506 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1506 session_->http_server_properties()->SetBrokenAlternateProtocol( |
| 1507 HostPortPair::FromURL(request_info_.url)); | 1507 HostPortPair::FromURL(request_info_.url)); |
| 1508 } | 1508 } |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 } // namespace net | 1511 } // namespace net |
| OLD | NEW |