| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/quic/chromium/bidirectional_stream_quic_impl.h" | 5 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 void BidirectionalStreamQuicImpl::Start( | 48 void BidirectionalStreamQuicImpl::Start( |
| 49 const BidirectionalStreamRequestInfo* request_info, | 49 const BidirectionalStreamRequestInfo* request_info, |
| 50 const NetLogWithSource& net_log, | 50 const NetLogWithSource& net_log, |
| 51 bool send_request_headers_automatically, | 51 bool send_request_headers_automatically, |
| 52 BidirectionalStreamImpl::Delegate* delegate, | 52 BidirectionalStreamImpl::Delegate* delegate, |
| 53 std::unique_ptr<base::Timer> /* timer */) { | 53 std::unique_ptr<base::Timer> /* timer */) { |
| 54 DCHECK(!stream_); | 54 DCHECK(!stream_); |
| 55 CHECK(delegate); | 55 CHECK(delegate); |
| 56 DLOG_IF(WARNING, !session_->IsConnected()) |
| 57 << "Trying to start request headers after session has been closed."; |
| 56 | 58 |
| 57 send_request_headers_automatically_ = send_request_headers_automatically; | 59 send_request_headers_automatically_ = send_request_headers_automatically; |
| 58 if (!session_->IsConnected()) { | |
| 59 NotifyError(session_->IsCryptoHandshakeConfirmed() | |
| 60 ? ERR_QUIC_PROTOCOL_ERROR | |
| 61 : ERR_QUIC_HANDSHAKE_FAILED); | |
| 62 return; | |
| 63 } | |
| 64 | |
| 65 delegate_ = delegate; | 60 delegate_ = delegate; |
| 66 request_info_ = request_info; | 61 request_info_ = request_info; |
| 67 | 62 |
| 68 int rv = session_->RequestStream( | 63 int rv = session_->RequestStream( |
| 69 request_info_->method == "POST", | 64 request_info_->method == "POST", |
| 70 base::Bind(&BidirectionalStreamQuicImpl::OnStreamReady, | 65 base::Bind(&BidirectionalStreamQuicImpl::OnStreamReady, |
| 71 weak_factory_.GetWeakPtr())); | 66 weak_factory_.GetWeakPtr())); |
| 72 if (rv == ERR_IO_PENDING) | 67 if (rv == ERR_IO_PENDING) |
| 73 return; | 68 return; |
| 74 | 69 |
| 75 if (rv == OK) { | 70 if (rv != OK) { |
| 76 OnStreamReady(rv); | 71 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 77 } else if (!session_->IsCryptoHandshakeConfirmed()) { | 72 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError, |
| 78 NotifyError(ERR_QUIC_HANDSHAKE_FAILED); | 73 weak_factory_.GetWeakPtr(), |
| 74 session_->IsCryptoHandshakeConfirmed() |
| 75 ? rv |
| 76 : ERR_QUIC_HANDSHAKE_FAILED)); |
| 77 return; |
| 79 } | 78 } |
| 79 |
| 80 OnStreamReady(rv); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void BidirectionalStreamQuicImpl::SendRequestHeaders() { | 83 void BidirectionalStreamQuicImpl::SendRequestHeaders() { |
| 83 DCHECK(!has_sent_headers_); | 84 DCHECK(!has_sent_headers_); |
| 84 if (!stream_) { | 85 if (!stream_) { |
| 85 LOG(ERROR) | 86 LOG(ERROR) |
| 86 << "Trying to send request headers after stream has been destroyed."; | 87 << "Trying to send request headers after stream has been destroyed."; |
| 87 base::ThreadTaskRunnerHandle::Get()->PostTask( | 88 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 88 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError, | 89 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError, |
| 89 weak_factory_.GetWeakPtr(), ERR_UNEXPECTED)); | 90 weak_factory_.GetWeakPtr(), ERR_UNEXPECTED)); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 if (!stream_) | 389 if (!stream_) |
| 389 return; | 390 return; |
| 390 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 391 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
| 391 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 392 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
| 392 closed_is_first_stream_ = stream_->IsFirstStream(); | 393 closed_is_first_stream_ = stream_->IsFirstStream(); |
| 393 stream_->ClearDelegate(); | 394 stream_->ClearDelegate(); |
| 394 stream_ = nullptr; | 395 stream_ = nullptr; |
| 395 } | 396 } |
| 396 | 397 |
| 397 } // namespace net | 398 } // namespace net |
| OLD | NEW |