| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 DCHECK(!alternative_proxy_server_.is_valid() || | 219 DCHECK(!alternative_proxy_server_.is_valid() || |
| 220 !(IsSpdyAlternative() || IsQuicAlternative())); | 220 !(IsSpdyAlternative() || IsQuicAlternative())); |
| 221 // If either the alternative service protocol is specified or if the | 221 // If either the alternative service protocol is specified or if the |
| 222 // alternative proxy server is valid, then the job type must be set to | 222 // alternative proxy server is valid, then the job type must be set to |
| 223 // either ALTERNATIVE or PRECONNECT. | 223 // either ALTERNATIVE or PRECONNECT. |
| 224 DCHECK((alternative_service_.protocol == kProtoUnknown && | 224 DCHECK((alternative_service_.protocol == kProtoUnknown && |
| 225 !alternative_proxy_server_.is_valid()) || | 225 !alternative_proxy_server_.is_valid()) || |
| 226 (job_type_ == ALTERNATIVE || job_type_ == PRECONNECT)); | 226 (job_type_ == ALTERNATIVE || job_type_ == PRECONNECT)); |
| 227 // If the alternative proxy server is valid, then the job type must be | 227 // If the alternative proxy server is valid, then the job type must be |
| 228 // set to ALTERNATIVE. | 228 // set to ALTERNATIVE. |
| 229 DCHECK(!alternative_proxy_server_.is_valid() || job_type_ == ALTERNATIVE); | 229 DCHECK(!alternative_proxy_server_.is_valid() || job_type_ != MAIN); |
| 230 | 230 |
| 231 if (IsSpdyAlternative()) { | 231 if (IsSpdyAlternative()) { |
| 232 DCHECK(origin_url_.SchemeIs(url::kHttpsScheme)); | 232 DCHECK(origin_url_.SchemeIs(url::kHttpsScheme)); |
| 233 } | 233 } |
| 234 if (IsQuicAlternative()) { | 234 if (IsQuicAlternative()) { |
| 235 DCHECK(session_->IsQuicEnabled()); | 235 DCHECK(session_->IsQuicEnabled()); |
| 236 using_quic_ = true; | 236 using_quic_ = true; |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return session_->proxy_service()->GetLoadState(pac_request_); | 291 return session_->proxy_service()->GetLoadState(pac_request_); |
| 292 case STATE_INIT_CONNECTION_COMPLETE: | 292 case STATE_INIT_CONNECTION_COMPLETE: |
| 293 case STATE_CREATE_STREAM_COMPLETE: | 293 case STATE_CREATE_STREAM_COMPLETE: |
| 294 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); | 294 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); |
| 295 default: | 295 default: |
| 296 return LOAD_STATE_IDLE; | 296 return LOAD_STATE_IDLE; |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 void HttpStreamFactoryImpl::Job::Resume() { | 300 void HttpStreamFactoryImpl::Job::Resume() { |
| 301 DCHECK_EQ(job_type_, MAIN); | 301 DCHECK(job_type_ == MAIN || job_type_ == PRECONNECT); |
| 302 DCHECK_EQ(next_state_, STATE_WAIT_COMPLETE); | 302 DCHECK_EQ(next_state_, STATE_WAIT_COMPLETE); |
| 303 OnIOComplete(OK); | 303 OnIOComplete(OK); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void HttpStreamFactoryImpl::Job::Orphan() { | 306 void HttpStreamFactoryImpl::Job::Orphan() { |
| 307 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_ORPHANED); | 307 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_ORPHANED); |
| 308 | 308 |
| 309 if (delegate_->for_websockets()) { | 309 if (delegate_->for_websockets()) { |
| 310 // We cancel this job because a WebSocketHandshakeStream can't be created | 310 // We cancel this job because a WebSocketHandshakeStream can't be created |
| 311 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in | 311 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in |
| 312 // the Request class and isn't retrievable by this job. | 312 // the Request class and isn't retrievable by this job. |
| 313 if (connection_ && connection_->socket()) { | 313 if (connection_ && connection_->socket()) { |
| 314 connection_->socket()->Disconnect(); | 314 connection_->socket()->Disconnect(); |
| 315 } | 315 } |
| 316 delegate_->OnOrphanedJobComplete(this); | 316 delegate_->OnOrphanedJobComplete(this); |
| 317 } | 317 } |
| 318 // |this| may be deleted after this call. | 318 // |this| may be deleted after this call. |
| 319 } | 319 } |
| 320 | 320 |
| 321 void HttpStreamFactoryImpl::Job::SetPriority(RequestPriority priority) { | 321 void HttpStreamFactoryImpl::Job::SetPriority(RequestPriority priority) { |
| 322 priority_ = priority; | 322 priority_ = priority; |
| 323 // TODO(akalin): Propagate this to |connection_| and maybe the | 323 // TODO(akalin): Propagate this to |connection_| and maybe the |
| 324 // preconnect state. | 324 // preconnect state. |
| 325 } | 325 } |
| 326 | 326 |
| 327 void HttpStreamFactoryImpl::Job::RestrictNumStreamsToOne() { |
| 328 DCHECK_EQ(PRECONNECT, job_type_); |
| 329 num_streams_ = 1; |
| 330 } |
| 331 |
| 327 bool HttpStreamFactoryImpl::Job::was_alpn_negotiated() const { | 332 bool HttpStreamFactoryImpl::Job::was_alpn_negotiated() const { |
| 328 return was_alpn_negotiated_; | 333 return was_alpn_negotiated_; |
| 329 } | 334 } |
| 330 | 335 |
| 331 NextProto HttpStreamFactoryImpl::Job::negotiated_protocol() const { | 336 NextProto HttpStreamFactoryImpl::Job::negotiated_protocol() const { |
| 332 return negotiated_protocol_; | 337 return negotiated_protocol_; |
| 333 } | 338 } |
| 334 | 339 |
| 335 bool HttpStreamFactoryImpl::Job::using_spdy() const { | 340 bool HttpStreamFactoryImpl::Job::using_spdy() const { |
| 336 return using_spdy_; | 341 return using_spdy_; |
| (...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 | 1519 |
| 1515 ConnectionAttempts socket_attempts = connection_->connection_attempts(); | 1520 ConnectionAttempts socket_attempts = connection_->connection_attempts(); |
| 1516 if (connection_->socket()) { | 1521 if (connection_->socket()) { |
| 1517 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1522 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
| 1518 } | 1523 } |
| 1519 | 1524 |
| 1520 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); | 1525 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); |
| 1521 } | 1526 } |
| 1522 | 1527 |
| 1523 } // namespace net | 1528 } // namespace net |
| OLD | NEW |