OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/quic/quartc/quartc_stream.h" | |
6 | |
7 namespace net { | |
8 | |
9 QuartcStream::QuartcStream(QuicStreamId id, QuicSession* session) | |
10 : ReliableQuicStream(id, session) {} | |
11 QuartcStream::~QuartcStream() {} | |
12 | |
13 void QuartcStream::OnDataAvailable() { | |
14 struct iovec iov; | |
15 while (sequencer()->GetReadableRegions(&iov, 1) == 1) { | |
16 DCHECK(delegate_); | |
17 delegate_->OnReceived(this, reinterpret_cast<const char*>(iov.iov_base), | |
18 iov.iov_len); | |
19 sequencer()->MarkConsumed(iov.iov_len); | |
20 } | |
21 } | |
22 | |
23 void QuartcStream::OnClose() { | |
24 ReliableQuicStream::OnClose(); | |
25 DCHECK(delegate_); | |
26 delegate_->OnClose(this, connection_error()); | |
27 } | |
28 | |
29 void QuartcStream::OnCanWrite() { | |
30 ReliableQuicStream::OnCanWrite(); | |
31 DCHECK(delegate_); | |
32 delegate_->OnBufferedAmountChanged(this); | |
33 } | |
34 | |
35 uint32_t QuartcStream::stream_id() { | |
36 return id(); | |
37 } | |
38 | |
39 uint64_t QuartcStream::buffered_amount() { | |
40 return queued_data_bytes(); | |
41 } | |
42 | |
43 void QuartcStream::Write(const char* data, | |
44 size_t size, | |
45 const WriteParameters& param) { | |
46 WriteOrBufferData(base::StringPiece(data, size), param.fin, nullptr); | |
47 } | |
48 | |
49 void QuartcStream::Close() { | |
50 ReliableQuicStream::session()->CloseStream(id()); | |
51 } | |
52 | |
53 void QuartcStream::SetDelegate(QuartcStreamInterface::Delegate* delegate) { | |
54 if (delegate_) { | |
55 DVLOG(1) << "The delegate for Stream " << id() << " has already been set."; | |
56 return; | |
57 } | |
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
| |
58 delegate_ = delegate; | |
59 DCHECK(delegate_); | |
60 } | |
61 | |
62 } // namespace net | |
OLD | NEW |