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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 327 } |
328 | 328 |
329 void HttpStreamFactoryImpl::Job::Resume() { | 329 void HttpStreamFactoryImpl::Job::Resume() { |
330 DCHECK_EQ(job_type_, MAIN); | 330 DCHECK_EQ(job_type_, MAIN); |
331 DCHECK_EQ(next_state_, STATE_WAIT_COMPLETE); | 331 DCHECK_EQ(next_state_, STATE_WAIT_COMPLETE); |
332 OnIOComplete(OK); | 332 OnIOComplete(OK); |
333 } | 333 } |
334 | 334 |
335 void HttpStreamFactoryImpl::Job::Orphan() { | 335 void HttpStreamFactoryImpl::Job::Orphan() { |
336 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_ORPHANED); | 336 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_ORPHANED); |
| 337 |
| 338 if (delegate_->for_websockets()) { |
| 339 // We cancel this job because a WebSocketHandshakeStream can't be created |
| 340 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in |
| 341 // the Request class and isn't retrievable by this job. |
| 342 if (connection_ && connection_->socket()) { |
| 343 connection_->socket()->Disconnect(); |
| 344 } |
| 345 delegate_->OnOrphanedJobComplete(this); |
| 346 } |
| 347 // |this| may be deleted after this call. |
337 } | 348 } |
338 | 349 |
339 void HttpStreamFactoryImpl::Job::SetPriority(RequestPriority priority) { | 350 void HttpStreamFactoryImpl::Job::SetPriority(RequestPriority priority) { |
340 priority_ = priority; | 351 priority_ = priority; |
341 // Ownership of |connection_| is passed to the newly created stream | 352 // Ownership of |connection_| is passed to the newly created stream |
342 // or H2 session in DoCreateStream(), and the consumer is not | 353 // or H2 session in DoCreateStream(), and the consumer is not |
343 // notified immediately, so this call may occur when |connection_| | 354 // notified immediately, so this call may occur when |connection_| |
344 // is null. | 355 // is null. |
345 // | 356 // |
346 // Note that streams are created without a priority associated with them, | 357 // Note that streams are created without a priority associated with them, |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 | 725 |
715 int HttpStreamFactoryImpl::Job::StartInternal() { | 726 int HttpStreamFactoryImpl::Job::StartInternal() { |
716 CHECK_EQ(STATE_NONE, next_state_); | 727 CHECK_EQ(STATE_NONE, next_state_); |
717 next_state_ = STATE_START; | 728 next_state_ = STATE_START; |
718 int rv = RunLoop(OK); | 729 int rv = RunLoop(OK); |
719 DCHECK_EQ(ERR_IO_PENDING, rv); | 730 DCHECK_EQ(ERR_IO_PENDING, rv); |
720 return rv; | 731 return rv; |
721 } | 732 } |
722 | 733 |
723 int HttpStreamFactoryImpl::Job::DoStart() { | 734 int HttpStreamFactoryImpl::Job::DoStart() { |
724 const NetLogWithSource* net_log = delegate_->GetNetLog(); | 735 const NetLogWithSource* net_log = delegate_->GetNetLog(this); |
725 | 736 |
726 if (net_log) { | 737 if (net_log) { |
727 net_log_.BeginEvent( | 738 net_log_.BeginEvent( |
728 NetLogEventType::HTTP_STREAM_JOB, | 739 NetLogEventType::HTTP_STREAM_JOB, |
729 base::Bind(&NetLogHttpStreamJobCallback, net_log->source(), | 740 base::Bind(&NetLogHttpStreamJobCallback, net_log->source(), |
730 &request_info_.url, &origin_url_, &alternative_service_, | 741 &request_info_.url, &origin_url_, &alternative_service_, |
731 priority_)); | 742 priority_)); |
732 net_log->AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_STARTED_JOB, | 743 net_log->AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_STARTED_JOB, |
733 net_log_.source().ToEventParametersCallback()); | 744 net_log_.source().ToEventParametersCallback()); |
734 } | 745 } |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 | 1548 |
1538 ConnectionAttempts socket_attempts = connection_->connection_attempts(); | 1549 ConnectionAttempts socket_attempts = connection_->connection_attempts(); |
1539 if (connection_->socket()) { | 1550 if (connection_->socket()) { |
1540 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1551 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
1541 } | 1552 } |
1542 | 1553 |
1543 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); | 1554 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); |
1544 } | 1555 } |
1545 | 1556 |
1546 } // namespace net | 1557 } // namespace net |
OLD | NEW |