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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 default: | 161 default: |
162 return LOAD_STATE_IDLE; | 162 return LOAD_STATE_IDLE; |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 void HttpStreamFactoryImpl::Job::MarkAsAlternate( | 166 void HttpStreamFactoryImpl::Job::MarkAsAlternate( |
167 const GURL& original_url, | 167 const GURL& original_url, |
168 AlternateProtocolInfo alternate) { | 168 AlternateProtocolInfo alternate) { |
169 DCHECK(!original_url_.get()); | 169 DCHECK(!original_url_.get()); |
170 original_url_.reset(new GURL(original_url)); | 170 original_url_.reset(new GURL(original_url)); |
| 171 alternate_protocol_ = alternate; |
171 if (alternate.protocol == QUIC) { | 172 if (alternate.protocol == QUIC) { |
172 DCHECK(session_->params().enable_quic); | 173 DCHECK(session_->params().enable_quic); |
173 using_quic_ = true; | 174 using_quic_ = true; |
174 } | 175 } |
175 } | 176 } |
176 | 177 |
177 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { | 178 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { |
178 DCHECK_EQ(STATE_NONE, next_state_); | 179 DCHECK_EQ(STATE_NONE, next_state_); |
179 DCHECK_EQ(STATE_NONE, job->next_state_); | 180 DCHECK_EQ(STATE_NONE, job->next_state_); |
180 DCHECK(!blocking_job_); | 181 DCHECK(!blocking_job_); |
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 } else { | 1447 } else { |
1447 // This job was the normal job, and hence the alternate protocol job lost | 1448 // This job was the normal job, and hence the alternate protocol job lost |
1448 // the race. | 1449 // the race. |
1449 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE); | 1450 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE); |
1450 } | 1451 } |
1451 } | 1452 } |
1452 | 1453 |
1453 void HttpStreamFactoryImpl::Job::MarkOtherJobComplete(const Job& job) { | 1454 void HttpStreamFactoryImpl::Job::MarkOtherJobComplete(const Job& job) { |
1454 DCHECK_EQ(STATUS_RUNNING, other_job_status_); | 1455 DCHECK_EQ(STATUS_RUNNING, other_job_status_); |
1455 other_job_status_ = job.job_status_; | 1456 other_job_status_ = job.job_status_; |
| 1457 other_job_alternate_protocol_ = job.alternate_protocol_; |
1456 MaybeMarkAlternateProtocolBroken(); | 1458 MaybeMarkAlternateProtocolBroken(); |
1457 } | 1459 } |
1458 | 1460 |
1459 void HttpStreamFactoryImpl::Job::MaybeMarkAlternateProtocolBroken() { | 1461 void HttpStreamFactoryImpl::Job::MaybeMarkAlternateProtocolBroken() { |
1460 if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING) | 1462 if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING) |
1461 return; | 1463 return; |
1462 | 1464 |
1463 bool is_alternate_protocol_job = original_url_.get() != NULL; | 1465 bool is_alternate_protocol_job = original_url_.get() != NULL; |
1464 if (is_alternate_protocol_job) { | 1466 if (is_alternate_protocol_job) { |
1465 if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) { | 1467 if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) { |
1466 HistogramBrokenAlternateProtocolLocation( | 1468 HistogramBrokenAlternateProtocolLocation( |
1467 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); | 1469 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); |
1468 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1470 session_->http_server_properties()->SetBrokenAlternateProtocol( |
1469 HostPortPair::FromURL(*original_url_)); | 1471 HostPortPair::FromURL(*original_url_)); |
1470 } | 1472 } |
1471 return; | 1473 return; |
1472 } | 1474 } |
1473 | 1475 |
1474 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { | 1476 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { |
1475 HistogramBrokenAlternateProtocolLocation( | 1477 HistogramBrokenAlternateProtocolLocation( |
1476 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); | 1478 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); |
1477 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1479 session_->http_server_properties()->SetBrokenAlternateProtocol( |
1478 HostPortPair::FromURL(request_info_.url)); | 1480 HostPortPair::FromURL(request_info_.url)); |
1479 } | 1481 } |
1480 } | 1482 } |
1481 | 1483 |
1482 } // namespace net | 1484 } // namespace net |
OLD | NEW |