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

Unified Diff: net/quic/quartc/quartc_reliable_stream.cc

Issue 2324833004: Define Stable API for WebRTC/Quartc (Closed)
Patch Set: Patch Set 4 : Create QuartcFactory. Made modification on the API. Change the constructor of QuartcS… Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/quartc/quartc_reliable_stream.cc
diff --git a/net/quic/quartc/quartc_reliable_stream.cc b/net/quic/quartc/quartc_reliable_stream.cc
new file mode 100644
index 0000000000000000000000000000000000000000..880a7b987a546afc6c3fb9f4f880716d0e2201af
--- /dev/null
+++ b/net/quic/quartc/quartc_reliable_stream.cc
@@ -0,0 +1,59 @@
+// 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_reliable_stream.h"
+
+namespace net {
+
+QuartcReliableStream::QuartcReliableStream(QuicStreamId id,
+ QuicSession* session)
+ : ReliableQuicStream(id, session) {}
+QuartcReliableStream::~QuartcReliableStream() {}
+
+void QuartcReliableStream::OnDataAvailable() {
+ struct iovec iov;
+ while (sequencer()->GetReadableRegions(&iov, 1) == 1) {
+ DCHECK(observer_);
+ observer_->OnReceived(this, reinterpret_cast<const char*>(iov.iov_base),
+ iov.iov_len);
+ sequencer()->MarkConsumed(iov.iov_len);
+ }
+}
+
+void QuartcReliableStream::OnClose() {
+ ReliableQuicStream::OnClose();
+ DCHECK(observer_);
+ observer_->OnClose(this, connection_error());
+}
+
+void QuartcReliableStream::OnCanWrite() {
+ ReliableQuicStream::OnCanWrite();
+ DCHECK(observer_);
+ observer_->OnBufferedAmountChanged(this);
+}
+
+uint32_t QuartcReliableStream::stream_id() {
+ return id();
+}
+
+uint64_t QuartcReliableStream::buffered_amount() {
+ return queued_data_bytes();
+}
+
+void QuartcReliableStream::Write(const char* data,
+ size_t size,
+ const WriteParameters& param) {
+ WriteOrBufferData(base::StringPiece(data, size), param.fin, nullptr);
+}
+
+void QuartcReliableStream::Close() {
+ ReliableQuicStream::session()->CloseStream(id());
+}
+
+void QuartcReliableStream::SetObserver(
+ QuartcReliableStream::Observer* observer) {
+ observer_ = observer;
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698