summaryrefslogtreecommitdiffstats
path: root/net/quic/reliable_quic_stream.h
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-03 16:55:32 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-03 16:55:32 +0000
commit1bb0fd5dbf2357a6c7fa837c6e3e1e427d9a7e99 (patch)
treea2181772ce5955c2e9a589f09f97bc3e8559265a /net/quic/reliable_quic_stream.h
parent843552f0c31d71c618c8a332c055aa52fbb55ee0 (diff)
downloadchromium_src-1bb0fd5dbf2357a6c7fa837c6e3e1e427d9a7e99.zip
chromium_src-1bb0fd5dbf2357a6c7fa837c6e3e1e427d9a7e99.tar.gz
chromium_src-1bb0fd5dbf2357a6c7fa837c6e3e1e427d9a7e99.tar.bz2
Add QuicStream and friends to QUIC code.
Review URL: https://chromiumcodereview.appspot.com/11300020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic/reliable_quic_stream.h')
-rw-r--r--net/quic/reliable_quic_stream.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/net/quic/reliable_quic_stream.h b/net/quic/reliable_quic_stream.h
new file mode 100644
index 0000000..366a310
--- /dev/null
+++ b/net/quic/reliable_quic_stream.h
@@ -0,0 +1,80 @@
+// Copyright (c) 2012 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.
+//
+// The base class for client/server reliable streams.
+
+#ifndef NET_QUIC_RELIABLE_QUIC_STREAM_H_
+#define NET_QUIC_RELIABLE_QUIC_STREAM_H_
+
+#include "net/quic/quic_stream_sequencer.h"
+
+namespace net {
+
+class QuicSession;
+
+// All this does right now is send data to subclasses via the sequencer.
+class NET_EXPORT_PRIVATE ReliableQuicStream {
+ public:
+ ReliableQuicStream(QuicStreamId id,
+ QuicSession* session);
+
+ virtual ~ReliableQuicStream();
+
+ bool WillAcceptStreamFrame(const QuicStreamFrame& frame) const;
+ bool OnStreamFrame(const QuicStreamFrame& frame);
+
+ // Called when we get a stream reset from the client.
+ // The rst will be passed through the sequencer, which will call
+ // TerminateFromPeer when 'offset' bytes have been processed.
+ void OnStreamReset(QuicErrorCode error, QuicStreamOffset ofset);
+
+ // Called when we get or send a connection close, and should immediately
+ // close the stream. This is not passed through the sequencer,
+ // but is handled immediately.
+ virtual void ConnectionClose(QuicErrorCode error, bool from_peer);
+
+ // Called by the sequencer, when we should process a stream termination or
+ // stream close from the peer.
+ virtual void TerminateFromPeer(bool half_close);
+
+ virtual uint32 ProcessData(const char* data, uint32 data_len) = 0;
+
+ // Called to close the stream from this end.
+ virtual void Close(QuicErrorCode error);
+
+ // This block of functions wraps the sequencer's functions of the same
+ // name.
+ virtual bool IsHalfClosed();
+ virtual bool HasBytesToRead();
+
+ QuicStreamId id() { return id_; }
+
+ QuicErrorCode error() { return error_; }
+
+ protected:
+ virtual int WriteData(base::StringPiece data, bool fin);
+ // Close the read side of the socket. Further frames will not be accepted.
+ virtual void CloseReadSide();
+ // Close the write side of the socket. Further writes will fail.
+ void CloseWriteSide();
+
+ QuicSession* session() { return session_; }
+
+ private:
+ friend class ReliableQuicStreamPeer;
+
+ QuicStreamSequencer sequencer_;
+ QuicStreamId id_;
+ QuicStreamOffset offset_;
+ QuicSession* session_;
+ QuicErrorCode error_;
+ // True if the read side is closed and further frames should be rejected.
+ bool read_side_closed_;
+ // True if the write side is closed, and further writes should fail.
+ bool write_side_closed_;
+};
+
+} // namespace net
+
+#endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_