| OLD | NEW |
| 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> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // been fully processed. Then they simply delegate to the sequencer. | 88 // been fully processed. Then they simply delegate to the sequencer. |
| 89 virtual size_t Readv(const struct iovec* iov, size_t iov_len); | 89 virtual size_t Readv(const struct iovec* iov, size_t iov_len); |
| 90 virtual int GetReadableRegions(iovec* iov, size_t iov_len); | 90 virtual int GetReadableRegions(iovec* iov, size_t iov_len); |
| 91 virtual bool IsHalfClosed() const; | 91 virtual bool IsHalfClosed() const; |
| 92 virtual bool HasBytesToRead() const; | 92 virtual bool HasBytesToRead() const; |
| 93 | 93 |
| 94 // Called by the session when a decompression blocked stream | 94 // Called by the session when a decompression blocked stream |
| 95 // becomes unblocked. | 95 // becomes unblocked. |
| 96 virtual void OnDecompressorAvailable(); | 96 virtual void OnDecompressorAvailable(); |
| 97 | 97 |
| 98 // By default, this is the same as priority(), however it allows streams |
| 99 // to temporarily alter effective priority. For example if a SPDY stream has |
| 100 // compressed but not written headers it can write the headers with a higher |
| 101 // priority. |
| 102 virtual QuicPriority EffectivePriority() const; |
| 103 |
| 98 QuicStreamId id() const { return id_; } | 104 QuicStreamId id() const { return id_; } |
| 99 | 105 |
| 100 QuicRstStreamErrorCode stream_error() const { return stream_error_; } | 106 QuicRstStreamErrorCode stream_error() const { return stream_error_; } |
| 101 QuicErrorCode connection_error() const { return connection_error_; } | 107 QuicErrorCode connection_error() const { return connection_error_; } |
| 102 | 108 |
| 103 bool read_side_closed() const { return read_side_closed_; } | 109 bool read_side_closed() const { return read_side_closed_; } |
| 104 bool write_side_closed() const { return write_side_closed_; } | 110 bool write_side_closed() const { return write_side_closed_; } |
| 105 | 111 |
| 106 uint64 stream_bytes_read() { return stream_bytes_read_; } | 112 uint64 stream_bytes_read() { return stream_bytes_read_; } |
| 107 uint64 stream_bytes_written() { return stream_bytes_written_; } | 113 uint64 stream_bytes_written() { return stream_bytes_written_; } |
| 108 | 114 |
| 109 const IPEndPoint& GetPeerAddress() const; | 115 const IPEndPoint& GetPeerAddress() const; |
| 110 | 116 |
| 111 void set_visitor(Visitor* visitor) { visitor_ = visitor; } | 117 void set_visitor(Visitor* visitor) { visitor_ = visitor; } |
| 112 | 118 |
| 113 QuicSpdyCompressor* compressor(); | 119 QuicSpdyCompressor* compressor(); |
| 114 | 120 |
| 115 // Gets the SSL connection information. | 121 // Gets the SSL connection information. |
| 116 bool GetSSLInfo(SSLInfo* ssl_info); | 122 bool GetSSLInfo(SSLInfo* ssl_info); |
| 117 | 123 |
| 118 bool headers_decompressed() const { return headers_decompressed_; } | 124 bool headers_decompressed() const { return headers_decompressed_; } |
| 119 QuicPriority priority() const { return priority_; } | |
| 120 | 125 |
| 121 protected: | 126 protected: |
| 122 // Returns a pair with the number of bytes consumed from data, and a boolean | 127 // Returns a pair with the number of bytes consumed from data, and a boolean |
| 123 // indicating if the fin bit was consumed. This does not indicate the data | 128 // indicating if the fin bit was consumed. This does not indicate the data |
| 124 // has been sent on the wire: it may have been turned into a packet and queued | 129 // has been sent on the wire: it may have been turned into a packet and queued |
| 125 // if the socket was unexpectedly blocked. | 130 // if the socket was unexpectedly blocked. |
| 126 // | 131 // |
| 127 // The default implementation always consumed all bytes and any fin, but | 132 // The default implementation always consumed all bytes and any fin, but |
| 128 // this behavior is not guaranteed for subclasses so callers should check the | 133 // this behavior is not guaranteed for subclasses so callers should check the |
| 129 // return value. | 134 // return value. |
| 130 virtual QuicConsumedData WriteData(base::StringPiece data, bool fin); | 135 virtual QuicConsumedData WriteData(base::StringPiece data, bool fin); |
| 131 | 136 |
| 132 // Close the read side of the socket. Further frames will not be accepted. | 137 // Close the read side of the socket. Further frames will not be accepted. |
| 133 virtual void CloseReadSide(); | 138 virtual void CloseReadSide(); |
| 134 | 139 |
| 135 // Close the write side of the socket. Further writes will fail. | 140 // Close the write side of the socket. Further writes will fail. |
| 136 void CloseWriteSide(); | 141 void CloseWriteSide(); |
| 137 | 142 |
| 138 bool HasBufferedData(); | 143 bool HasBufferedData(); |
| 139 | 144 |
| 140 bool fin_buffered() { return fin_buffered_; } | 145 bool fin_buffered() { return fin_buffered_; } |
| 141 | 146 |
| 142 QuicSession* session() { return session_; } | 147 QuicSession* session() { return session_; } |
| 143 | 148 |
| 149 // Sets priority_ to priority. This should only be called before bytes are |
| 150 // written to the server. |
| 151 void set_priority(QuicPriority priority); |
| 152 // This is protected because external classes should use EffectivePriority |
| 153 // instead. |
| 154 QuicPriority priority() const { return priority_; } |
| 155 |
| 144 // Sends as much of 'data' to the connection as the connection will consume, | 156 // Sends as much of 'data' to the connection as the connection will consume, |
| 145 // and then buffers any remaining data in queued_data_. | 157 // and then buffers any remaining data in queued_data_. |
| 146 // Returns (data.size(), true) as it always consumed all data: it returns for | 158 // Returns (data.size(), true) as it always consumed all data: it returns for |
| 147 // convenience to have the same return type as WriteDataInternal. | 159 // convenience to have the same return type as WriteDataInternal. |
| 148 QuicConsumedData WriteOrBuffer(base::StringPiece data, bool fin); | 160 QuicConsumedData WriteOrBuffer(base::StringPiece data, bool fin); |
| 149 | 161 |
| 150 // Sends as much of 'data' to the connection as the connection will consume. | 162 // Sends as much of 'data' to the connection as the connection will consume. |
| 151 // Returns the number of bytes consumed by the connection. | 163 // Returns the number of bytes consumed by the connection. |
| 152 QuicConsumedData WriteDataInternal(base::StringPiece data, bool fin); | 164 QuicConsumedData WriteDataInternal(base::StringPiece data, bool fin); |
| 153 | 165 |
| 166 // Sends as many bytes in the first |count| buffers of |iov| to the connection |
| 167 // as the connection will consume. |
| 168 // Returns the number of bytes consumed by the connection. |
| 169 QuicConsumedData WritevDataInternal(const struct iovec* iov, |
| 170 int count, |
| 171 bool fin); |
| 172 |
| 154 private: | 173 private: |
| 155 friend class test::ReliableQuicStreamPeer; | 174 friend class test::ReliableQuicStreamPeer; |
| 156 friend class QuicStreamUtils; | 175 friend class QuicStreamUtils; |
| 157 | 176 |
| 158 uint32 StripPriorityAndHeaderId(const char* data, uint32 data_len); | 177 uint32 StripPriorityAndHeaderId(const char* data, uint32 data_len); |
| 159 | 178 |
| 160 std::list<string> queued_data_; | 179 std::list<string> queued_data_; |
| 161 | 180 |
| 162 QuicStreamSequencer sequencer_; | 181 QuicStreamSequencer sequencer_; |
| 163 QuicStreamId id_; | 182 QuicStreamId id_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 217 |
| 199 // True if the priority has been read, false otherwise. | 218 // True if the priority has been read, false otherwise. |
| 200 bool priority_parsed_; | 219 bool priority_parsed_; |
| 201 bool fin_buffered_; | 220 bool fin_buffered_; |
| 202 bool fin_sent_; | 221 bool fin_sent_; |
| 203 }; | 222 }; |
| 204 | 223 |
| 205 } // namespace net | 224 } // namespace net |
| 206 | 225 |
| 207 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ | 226 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ |
| OLD | NEW |