| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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/quartc/quartc_stream.h" | 5 #include "net/quic/quartc/quartc_stream.h" |
| 6 | 6 |
| 7 #include "net/quic/platform/api/quic_string_piece.h" | 7 #include "net/quic/platform/api/quic_string_piece.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Notify the delegate by calling the callback function one more time with | 24 // Notify the delegate by calling the callback function one more time with |
| 25 // iov_len = 0. | 25 // iov_len = 0. |
| 26 if (sequencer()->IsClosed()) { | 26 if (sequencer()->IsClosed()) { |
| 27 delegate_->OnReceived(this, reinterpret_cast<const char*>(iov.iov_base), 0); | 27 delegate_->OnReceived(this, reinterpret_cast<const char*>(iov.iov_base), 0); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 void QuartcStream::OnClose() { | 31 void QuartcStream::OnClose() { |
| 32 QuicStream::OnClose(); | 32 QuicStream::OnClose(); |
| 33 DCHECK(delegate_); | 33 DCHECK(delegate_); |
| 34 delegate_->OnClose(this, connection_error()); | 34 delegate_->OnClose(this); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void QuartcStream::OnCanWrite() { | 37 void QuartcStream::OnCanWrite() { |
| 38 QuicStream::OnCanWrite(); | 38 QuicStream::OnCanWrite(); |
| 39 DCHECK(delegate_); | 39 DCHECK(delegate_); |
| 40 delegate_->OnBufferedAmountDecrease(this); | 40 delegate_->OnBufferedAmountDecrease(this); |
| 41 } | 41 } |
| 42 | 42 |
| 43 uint32_t QuartcStream::stream_id() { | 43 uint32_t QuartcStream::stream_id() { |
| 44 return id(); | 44 return id(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 uint64_t QuartcStream::buffered_amount() { | 47 uint64_t QuartcStream::buffered_amount() { |
| 48 return queued_data_bytes(); | 48 return queued_data_bytes(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool QuartcStream::fin_sent() { | 51 bool QuartcStream::fin_sent() { |
| 52 return QuicStream::fin_sent(); | 52 return QuicStream::fin_sent(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 int QuartcStream::stream_error() { |
| 56 return QuicStream::stream_error(); |
| 57 } |
| 58 |
| 59 int QuartcStream::connection_error() { |
| 60 return QuicStream::connection_error(); |
| 61 } |
| 62 |
| 55 void QuartcStream::Write(const char* data, | 63 void QuartcStream::Write(const char* data, |
| 56 size_t size, | 64 size_t size, |
| 57 const WriteParameters& param) { | 65 const WriteParameters& param) { |
| 58 WriteOrBufferData(QuicStringPiece(data, size), param.fin, nullptr); | 66 WriteOrBufferData(QuicStringPiece(data, size), param.fin, nullptr); |
| 59 } | 67 } |
| 60 | 68 |
| 61 void QuartcStream::Close() { | 69 void QuartcStream::Close() { |
| 62 QuicStream::session()->CloseStream(id()); | 70 QuicStream::session()->CloseStream(id()); |
| 63 } | 71 } |
| 64 | 72 |
| 65 void QuartcStream::SetDelegate(QuartcStreamInterface::Delegate* delegate) { | 73 void QuartcStream::SetDelegate(QuartcStreamInterface::Delegate* delegate) { |
| 66 if (delegate_) { | 74 if (delegate_) { |
| 67 LOG(WARNING) << "The delegate for Stream " << id() | 75 LOG(WARNING) << "The delegate for Stream " << id() |
| 68 << " has already been set."; | 76 << " has already been set."; |
| 69 } | 77 } |
| 70 delegate_ = delegate; | 78 delegate_ = delegate; |
| 71 DCHECK(delegate_); | 79 DCHECK(delegate_); |
| 72 } | 80 } |
| 73 | 81 |
| 74 } // namespace net | 82 } // namespace net |
| OLD | NEW |