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