Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: net/quic/quartc/quartc_stream.cc

Issue 2324833004: Define Stable API for WebRTC/Quartc (Closed)
Patch Set: Fix the IOS simulator and merge. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quartc/quartc_stream.h ('k') | net/quic/quartc/quartc_stream_interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // All the data has been received if the sequencer is closed.
22 // Notify the delegate by calling the callback function one more time with
23 // iov_len = 0.
24 if (sequencer()->IsClosed()) {
25 delegate_->OnReceived(this, reinterpret_cast<const char*>(iov.iov_base), 0);
26 }
27 }
28
29 void QuartcStream::OnClose() {
30 ReliableQuicStream::OnClose();
31 DCHECK(delegate_);
32 delegate_->OnClose(this, connection_error());
33 }
34
35 void QuartcStream::OnCanWrite() {
36 ReliableQuicStream::OnCanWrite();
37 DCHECK(delegate_);
38 delegate_->OnBufferedAmountDecrease(this);
39 }
40
41 uint32_t QuartcStream::stream_id() {
42 return id();
43 }
44
45 uint64_t QuartcStream::buffered_amount() {
46 return queued_data_bytes();
47 }
48
49 bool QuartcStream::fin_sent() {
50 return ReliableQuicStream::fin_sent();
51 }
52
53 void QuartcStream::Write(const char* data,
54 size_t size,
55 const WriteParameters& param) {
56 WriteOrBufferData(base::StringPiece(data, size), param.fin, nullptr);
57 }
58
59 void QuartcStream::Close() {
60 ReliableQuicStream::session()->CloseStream(id());
61 }
62
63 void QuartcStream::SetDelegate(QuartcStreamInterface::Delegate* delegate) {
64 if (delegate_) {
65 LOG(WARNING) << "The delegate for Stream " << id()
66 << " has already been set.";
67 }
68 delegate_ = delegate;
69 DCHECK(delegate_);
70 }
71
72 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quartc/quartc_stream.h ('k') | net/quic/quartc/quartc_stream_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698