Chromium Code Reviews| Index: net/quic/quartc/quartc_stream.cc |
| diff --git a/net/quic/quartc/quartc_stream.cc b/net/quic/quartc/quartc_stream.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f6dc610c02edac75f8c710ab8a7d2b57f0c8383e |
| --- /dev/null |
| +++ b/net/quic/quartc/quartc_stream.cc |
| @@ -0,0 +1,62 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "net/quic/quartc/quartc_stream.h" |
| + |
| +namespace net { |
| + |
| +QuartcStream::QuartcStream(QuicStreamId id, QuicSession* session) |
| + : ReliableQuicStream(id, session) {} |
| +QuartcStream::~QuartcStream() {} |
| + |
| +void QuartcStream::OnDataAvailable() { |
| + struct iovec iov; |
| + while (sequencer()->GetReadableRegions(&iov, 1) == 1) { |
| + DCHECK(delegate_); |
| + delegate_->OnReceived(this, reinterpret_cast<const char*>(iov.iov_base), |
| + iov.iov_len); |
| + sequencer()->MarkConsumed(iov.iov_len); |
| + } |
| +} |
| + |
| +void QuartcStream::OnClose() { |
| + ReliableQuicStream::OnClose(); |
| + DCHECK(delegate_); |
| + delegate_->OnClose(this, connection_error()); |
| +} |
| + |
| +void QuartcStream::OnCanWrite() { |
| + ReliableQuicStream::OnCanWrite(); |
| + DCHECK(delegate_); |
| + delegate_->OnBufferedAmountChanged(this); |
| +} |
| + |
| +uint32_t QuartcStream::stream_id() { |
| + return id(); |
| +} |
| + |
| +uint64_t QuartcStream::buffered_amount() { |
| + return queued_data_bytes(); |
| +} |
| + |
| +void QuartcStream::Write(const char* data, |
| + size_t size, |
| + const WriteParameters& param) { |
| + WriteOrBufferData(base::StringPiece(data, size), param.fin, nullptr); |
| +} |
| + |
| +void QuartcStream::Close() { |
| + ReliableQuicStream::session()->CloseStream(id()); |
| +} |
| + |
| +void QuartcStream::SetDelegate(QuartcStreamInterface::Delegate* delegate) { |
| + if (delegate_) { |
| + DVLOG(1) << "The delegate for Stream " << id() << " has already been set."; |
| + return; |
| + } |
|
pthatcher2
2016/10/05 22:12:07
Why not just set it to something different?
zhihuang1
2016/10/13 06:22:40
Same as before.
I feel that the delegate implies
|
| + delegate_ = delegate; |
| + DCHECK(delegate_); |
| +} |
| + |
| +} // namespace net |