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

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

Issue 2324833004: Define Stable API for WebRTC/Quartc (Closed)
Patch Set: Create Quartc API Created 4 years, 2 months 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_reliable_stream.h"
6
7 namespace net {
8
9 QuartcReliableStream::QuartcReliableStream(QuicStreamId id,
10 QuicSession* session)
11 : ReliableQuicStream(id, session) {}
12 QuartcReliableStream::~QuartcReliableStream() {}
13
14 void QuartcReliableStream::OnDataAvailable() {
15 struct iovec iov;
16 while (sequencer()->GetReadableRegions(&iov, 1) == 1) {
17 DCHECK(observer_);
18 observer_->OnReceived(this, reinterpret_cast<const char*>(iov.iov_base),
19 iov.iov_len);
20 sequencer()->MarkConsumed(iov.iov_len);
21 }
22 }
23
24 void QuartcReliableStream::OnClose() {
25 ReliableQuicStream::OnClose();
26 DCHECK(observer_);
27 observer_->OnClose(this, connection_error());
28 }
29
30 void QuartcReliableStream::OnCanWrite() {
31 ReliableQuicStream::OnCanWrite();
32 DCHECK(observer_);
33 observer_->OnBufferedAmountChanged(this);
34 }
35
36 uint32_t QuartcReliableStream::stream_id() {
37 return id();
38 }
39
40 uint64_t QuartcReliableStream::buffered_amount() {
41 return queued_data_bytes();
42 }
43
44 void QuartcReliableStream::Write(const char* data,
45 size_t size,
46 const WriteParameters& param) {
47 WriteOrBufferData(base::StringPiece(data, size), param.fin, nullptr);
48 }
49
50 void QuartcReliableStream::Close() {
51 ReliableQuicStream::session()->CloseStream(id());
52 }
53
54 void QuartcReliableStream::SetObserver(
55 QuartcReliableStream::Observer* observer) {
56 observer_ = observer;
57 }
58
59 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698