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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 dict->SetString("proto", *proto); | 65 dict->SetString("proto", *proto); |
66 return dict; | 66 return dict; |
67 } | 67 } |
68 | 68 |
69 HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, | 69 HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, |
70 HttpNetworkSession* session, | 70 HttpNetworkSession* session, |
71 const HttpRequestInfo& request_info, | 71 const HttpRequestInfo& request_info, |
72 RequestPriority priority, | 72 RequestPriority priority, |
73 const SSLConfig& server_ssl_config, | 73 const SSLConfig& server_ssl_config, |
74 const SSLConfig& proxy_ssl_config, | 74 const SSLConfig& proxy_ssl_config, |
75 NetLog* net_log) | 75 NetLog* net_log, |
| 76 AlternateProtocolInfo alternate_protocol) |
76 : request_(NULL), | 77 : request_(NULL), |
77 request_info_(request_info), | 78 request_info_(request_info), |
78 priority_(priority), | 79 priority_(priority), |
79 server_ssl_config_(server_ssl_config), | 80 server_ssl_config_(server_ssl_config), |
80 proxy_ssl_config_(proxy_ssl_config), | 81 proxy_ssl_config_(proxy_ssl_config), |
81 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP_STREAM_JOB)), | 82 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP_STREAM_JOB)), |
82 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), | 83 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), |
83 connection_(new ClientSocketHandle), | 84 connection_(new ClientSocketHandle), |
84 session_(session), | 85 session_(session), |
85 stream_factory_(stream_factory), | 86 stream_factory_(stream_factory), |
86 next_state_(STATE_NONE), | 87 next_state_(STATE_NONE), |
87 pac_request_(NULL), | 88 pac_request_(NULL), |
| 89 alternate_protocol_(alternate_protocol), |
88 blocking_job_(NULL), | 90 blocking_job_(NULL), |
89 waiting_job_(NULL), | 91 waiting_job_(NULL), |
90 using_ssl_(false), | 92 using_ssl_(false), |
91 using_spdy_(false), | 93 using_spdy_(false), |
92 using_quic_(false), | 94 using_quic_(false), |
93 quic_request_(session_->quic_stream_factory()), | 95 quic_request_(session_->quic_stream_factory()), |
94 using_existing_quic_session_(false), | 96 using_existing_quic_session_(false), |
95 spdy_certificate_error_(OK), | 97 spdy_certificate_error_(OK), |
96 establishing_tunnel_(false), | 98 establishing_tunnel_(false), |
97 was_npn_negotiated_(false), | 99 was_npn_negotiated_(false), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 case STATE_RESOLVE_PROXY_COMPLETE: | 158 case STATE_RESOLVE_PROXY_COMPLETE: |
157 return session_->proxy_service()->GetLoadState(pac_request_); | 159 return session_->proxy_service()->GetLoadState(pac_request_); |
158 case STATE_INIT_CONNECTION_COMPLETE: | 160 case STATE_INIT_CONNECTION_COMPLETE: |
159 case STATE_CREATE_STREAM_COMPLETE: | 161 case STATE_CREATE_STREAM_COMPLETE: |
160 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); | 162 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); |
161 default: | 163 default: |
162 return LOAD_STATE_IDLE; | 164 return LOAD_STATE_IDLE; |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 void HttpStreamFactoryImpl::Job::MarkAsAlternate( | 168 void HttpStreamFactoryImpl::Job::MarkAsAlternate(const GURL& original_url) { |
167 const GURL& original_url, | |
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 if (alternate.protocol == QUIC) { | 171 if (alternate_protocol_.protocol == QUIC) { |
172 DCHECK(session_->params().enable_quic); | 172 DCHECK(session_->params().enable_quic); |
173 using_quic_ = true; | 173 using_quic_ = true; |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { | 177 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { |
178 DCHECK_EQ(STATE_NONE, next_state_); | 178 DCHECK_EQ(STATE_NONE, next_state_); |
179 DCHECK_EQ(STATE_NONE, job->next_state_); | 179 DCHECK_EQ(STATE_NONE, job->next_state_); |
180 DCHECK(!blocking_job_); | 180 DCHECK(!blocking_job_); |
181 DCHECK(!job->waiting_job_); | 181 DCHECK(!job->waiting_job_); |
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 void HttpStreamFactoryImpl::Job::MaybeMarkAlternateProtocolBroken() { | 1459 void HttpStreamFactoryImpl::Job::MaybeMarkAlternateProtocolBroken() { |
1460 if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING) | 1460 if (job_status_ == STATUS_RUNNING || other_job_status_ == STATUS_RUNNING) |
1461 return; | 1461 return; |
1462 | 1462 |
1463 bool is_alternate_protocol_job = original_url_.get() != NULL; | 1463 bool is_alternate_protocol_job = original_url_.get() != NULL; |
1464 if (is_alternate_protocol_job) { | 1464 if (is_alternate_protocol_job) { |
1465 if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) { | 1465 if (job_status_ == STATUS_BROKEN && other_job_status_ == STATUS_SUCCEEDED) { |
1466 HistogramBrokenAlternateProtocolLocation( | 1466 HistogramBrokenAlternateProtocolLocation( |
1467 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); | 1467 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT); |
1468 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1468 session_->http_server_properties()->SetBrokenAlternateProtocol( |
1469 HostPortPair::FromURL(*original_url_)); | 1469 HostPortPair::FromURL(*original_url_), alternate_protocol_); |
1470 } | 1470 } |
1471 return; | 1471 return; |
1472 } | 1472 } |
1473 | 1473 |
1474 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { | 1474 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { |
1475 HistogramBrokenAlternateProtocolLocation( | 1475 HistogramBrokenAlternateProtocolLocation( |
1476 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); | 1476 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); |
1477 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1477 session_->http_server_properties()->SetBrokenAlternateProtocol( |
1478 HostPortPair::FromURL(request_info_.url)); | 1478 HostPortPair::FromURL(request_info_.url), alternate_protocol_); |
1479 } | 1479 } |
1480 } | 1480 } |
1481 | 1481 |
1482 } // namespace net | 1482 } // namespace net |
OLD | NEW |