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

Side by Side Diff: trunk/src/net/quic/reliable_quic_stream.h

Issue 15018013: Revert 198736 "Land Recent QUIC changes" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/net/quic/quic_utils.cc ('k') | trunk/src/net/quic/reliable_quic_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // The base class for client/server reliable streams. 5 // The base class for client/server reliable streams.
6 6
7 #ifndef NET_QUIC_RELIABLE_QUIC_STREAM_H_ 7 #ifndef NET_QUIC_RELIABLE_QUIC_STREAM_H_
8 #define NET_QUIC_RELIABLE_QUIC_STREAM_H_ 8 #define NET_QUIC_RELIABLE_QUIC_STREAM_H_
9 9
10 #include <sys/types.h> 10 #include <sys/types.h>
11 11
12 #include <list> 12 #include <list>
13 13
14 #include "base/strings/string_piece.h"
15 #include "net/base/iovec.h"
16 #include "net/base/net_export.h"
17 #include "net/quic/quic_spdy_decompressor.h"
18 #include "net/quic/quic_stream_sequencer.h" 14 #include "net/quic/quic_stream_sequencer.h"
19 15
20 namespace net { 16 namespace net {
21 17
22 namespace test { 18 namespace test {
23 class ReliableQuicStreamPeer; 19 class ReliableQuicStreamPeer;
24 } // namespace test 20 } // namespace test
25 21
26 class IPEndPoint; 22 class IPEndPoint;
27 class QuicSession; 23 class QuicSession;
28 24
29 // All this does right now is send data to subclasses via the sequencer. 25 // All this does right now is send data to subclasses via the sequencer.
30 class NET_EXPORT_PRIVATE ReliableQuicStream : public 26 class NET_EXPORT_PRIVATE ReliableQuicStream {
31 QuicSpdyDecompressor::Visitor {
32 public: 27 public:
33 // Visitor receives callbacks from the stream. 28 // Visitor receives callbacks from the stream.
34 class Visitor { 29 class Visitor {
35 public: 30 public:
36 Visitor() {} 31 Visitor() {}
37 32
38 // Called when the stream is closed. 33 // Called when the stream is closed.
39 virtual void OnClose(ReliableQuicStream* stream) = 0; 34 virtual void OnClose(ReliableQuicStream* stream) = 0;
40 35
41 protected: 36 protected:
(...skipping 21 matching lines...) Expand all
63 58
64 // Called when we get or send a connection close, and should immediately 59 // Called when we get or send a connection close, and should immediately
65 // close the stream. This is not passed through the sequencer, 60 // close the stream. This is not passed through the sequencer,
66 // but is handled immediately. 61 // but is handled immediately.
67 virtual void ConnectionClose(QuicErrorCode error, bool from_peer); 62 virtual void ConnectionClose(QuicErrorCode error, bool from_peer);
68 63
69 // Called by the sequencer, when we should process a stream termination or 64 // Called by the sequencer, when we should process a stream termination or
70 // stream close from the peer. 65 // stream close from the peer.
71 virtual void TerminateFromPeer(bool half_close); 66 virtual void TerminateFromPeer(bool half_close);
72 67
73 virtual uint32 ProcessRawData(const char* data, uint32 data_len);
74 virtual uint32 ProcessHeaderData();
75
76 virtual uint32 ProcessData(const char* data, uint32 data_len) = 0; 68 virtual uint32 ProcessData(const char* data, uint32 data_len) = 0;
77 69
78 virtual bool OnDecompressedData(base::StringPiece data) OVERRIDE;
79
80 // Called to close the stream from this end. 70 // Called to close the stream from this end.
81 virtual void Close(QuicRstStreamErrorCode error); 71 virtual void Close(QuicRstStreamErrorCode error);
82 72
83 // This block of functions wraps the sequencer's functions of the same 73 // This block of functions wraps the sequencer's functions of the same
84 // name. These methods return uncompressed data until that has 74 // name.
85 // been fully processed. Then they simply delegate to the sequencer.
86 virtual int Readv(const struct iovec* iov, int iov_len);
87 virtual int GetReadableRegions(iovec* iov, int iov_len);
88 virtual bool IsHalfClosed() const; 75 virtual bool IsHalfClosed() const;
89 virtual bool IsClosed() const; 76 virtual bool IsClosed() const;
90 virtual bool HasBytesToRead() const; 77 virtual bool HasBytesToRead() const;
91 78
92 // Called by the session when a decompression blocked stream
93 // becomes unblocked.
94 virtual void OnDecompressorAvailable();
95
96 QuicStreamId id() const { return id_; } 79 QuicStreamId id() const { return id_; }
97 80
98 QuicRstStreamErrorCode stream_error() const { return stream_error_; } 81 QuicRstStreamErrorCode stream_error() const { return stream_error_; }
99 QuicErrorCode connection_error() const { return connection_error_; } 82 QuicErrorCode connection_error() const { return connection_error_; }
100 83
101 bool read_side_closed() const { return read_side_closed_; } 84 bool read_side_closed() const { return read_side_closed_; }
102 bool write_side_closed() const { return write_side_closed_; } 85 bool write_side_closed() const { return write_side_closed_; }
103 86
104 uint64 stream_bytes_read() { return stream_bytes_read_; }
105 uint64 stream_bytes_written() { return stream_bytes_written_; }
106
107 const IPEndPoint& GetPeerAddress() const; 87 const IPEndPoint& GetPeerAddress() const;
108 88
109 Visitor* visitor() { return visitor_; } 89 Visitor* visitor() { return visitor_; }
110 void set_visitor(Visitor* visitor) { visitor_ = visitor; } 90 void set_visitor(Visitor* visitor) { visitor_ = visitor; }
111 91
92 uint64 stream_bytes_read() const { return stream_bytes_read_; }
93 uint64 stream_bytes_written() const { return stream_bytes_written_; }
94
112 protected: 95 protected:
113 // Returns a pair with the number of bytes consumed from data, and a boolean 96 // Returns a pair with the number of bytes consumed from data, and a boolean
114 // indicating if the fin bit was consumed. This does not indicate the data 97 // indicating if the fin bit was consumed. This does not indicate the data
115 // has been sent on the wire: it may have been turned into a packet and queued 98 // has been sent on the wire: it may have been turned into a packet and queued
116 // if the socket was unexpectedly blocked. 99 // if the socket was unexpectedly blocked.
117 // 100 //
118 // The default implementation always consumed all bytes and any fin, but 101 // The default implementation always consumed all bytes and any fin, but
119 // this behavior is not guaranteed for subclasses so callers should check the 102 // this behavior is not guaranteed for subclasses so callers should check the
120 // return value. 103 // return value.
121 virtual QuicConsumedData WriteData(base::StringPiece data, bool fin); 104 virtual QuicConsumedData WriteData(base::StringPiece data, bool fin);
(...skipping 24 matching lines...) Expand all
146 129
147 QuicStreamSequencer sequencer_; 130 QuicStreamSequencer sequencer_;
148 QuicStreamId id_; 131 QuicStreamId id_;
149 QuicSession* session_; 132 QuicSession* session_;
150 // Optional visitor of this stream to be notified when the stream is closed. 133 // Optional visitor of this stream to be notified when the stream is closed.
151 Visitor* visitor_; 134 Visitor* visitor_;
152 // Bytes read and written refer to payload bytes only: they do not include 135 // Bytes read and written refer to payload bytes only: they do not include
153 // framing, encryption overhead etc. 136 // framing, encryption overhead etc.
154 uint64 stream_bytes_read_; 137 uint64 stream_bytes_read_;
155 uint64 stream_bytes_written_; 138 uint64 stream_bytes_written_;
156 // True if the headers have been completely decompresssed.
157 bool headers_complete_;
158 // ID of the header block sent by the peer, once parsed.
159 QuicHeaderId headers_id_;
160 // Buffer into which we write bytes from the headers_id_
161 // until it is fully parsed.
162 string headers_id_buffer_;
163 // Contains a copy of the decompressed headers_ until they are consumed
164 // via ProcessData or Readv.
165 string decompressed_headers_;
166 139
167 // Stream error code received from a RstStreamFrame or error code sent by the 140 // Stream error code received from a RstStreamFrame or error code sent by the
168 // visitor or sequencer in the RstStreamFrame. 141 // visitor or sequencer in the RstStreamFrame.
169 QuicRstStreamErrorCode stream_error_; 142 QuicRstStreamErrorCode stream_error_;
170 // Connection error code due to which the stream was closed. |stream_error_| 143 // Connection error code due to which the stream was closed. |stream_error_|
171 // is set to |QUIC_STREAM_CONNECTION_ERROR| when this happens and consumers 144 // is set to |QUIC_STREAM_CONNECTION_ERROR| when this happens and consumers
172 // should check |connection_error_|. 145 // should check |connection_error_|.
173 QuicErrorCode connection_error_; 146 QuicErrorCode connection_error_;
174 147
175 // True if the read side is closed and further frames should be rejected. 148 // True if the read side is closed and further frames should be rejected.
176 bool read_side_closed_; 149 bool read_side_closed_;
177 // True if the write side is closed, and further writes should fail. 150 // True if the write side is closed, and further writes should fail.
178 bool write_side_closed_; 151 bool write_side_closed_;
179 152
180 bool fin_buffered_; 153 bool fin_buffered_;
181 bool fin_sent_; 154 bool fin_sent_;
182 }; 155 };
183 156
184 } // namespace net 157 } // namespace net
185 158
186 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ 159 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_
OLDNEW
« no previous file with comments | « trunk/src/net/quic/quic_utils.cc ('k') | trunk/src/net/quic/reliable_quic_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698