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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cce57b32fae303f194ab989562730fca3133d016
--- /dev/null
+++ b/net/quic/quartc/quartc_stream.cc
@@ -0,0 +1,72 @@
+// 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);
+ }
+ // All the data has been received if the sequencer is closed.
+ // Notify the delegate by calling the callback function one more time with
+ // iov_len = 0.
+ if (sequencer()->IsClosed()) {
+ delegate_->OnReceived(this, reinterpret_cast<const char*>(iov.iov_base), 0);
+ }
+}
+
+void QuartcStream::OnClose() {
+ ReliableQuicStream::OnClose();
+ DCHECK(delegate_);
+ delegate_->OnClose(this, connection_error());
+}
+
+void QuartcStream::OnCanWrite() {
+ ReliableQuicStream::OnCanWrite();
+ DCHECK(delegate_);
+ delegate_->OnBufferedAmountDecrease(this);
+}
+
+uint32_t QuartcStream::stream_id() {
+ return id();
+}
+
+uint64_t QuartcStream::buffered_amount() {
+ return queued_data_bytes();
+}
+
+bool QuartcStream::fin_sent() {
+ return ReliableQuicStream::fin_sent();
+}
+
+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_) {
+ LOG(WARNING) << "The delegate for Stream " << id()
+ << " has already been set.";
+ }
+ delegate_ = delegate;
+ DCHECK(delegate_);
+}
+
+} // namespace net
« 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