| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 void set_visitor(Visitor* visitor) { visitor_ = visitor; } | 130 void set_visitor(Visitor* visitor) { visitor_ = visitor; } |
| 131 | 131 |
| 132 QuicSpdyCompressor* compressor(); | 132 QuicSpdyCompressor* compressor(); |
| 133 | 133 |
| 134 // Gets the SSL connection information. | 134 // Gets the SSL connection information. |
| 135 bool GetSSLInfo(SSLInfo* ssl_info); | 135 bool GetSSLInfo(SSLInfo* ssl_info); |
| 136 | 136 |
| 137 bool headers_decompressed() const { return headers_decompressed_; } | 137 bool headers_decompressed() const { return headers_decompressed_; } |
| 138 | 138 |
| 139 protected: | 139 protected: |
| 140 // Returns a pair with the number of bytes consumed from data, and a boolean | 140 // Sends as much of 'data' to the connection as the connection will consume, |
| 141 // indicating if the fin bit was consumed. This does not indicate the data | 141 // and then buffers any remaining data in queued_data_. |
| 142 // has been sent on the wire: it may have been turned into a packet and queued | 142 void WriteOrBufferData(base::StringPiece data, bool fin); |
| 143 // if the socket was unexpectedly blocked. | 143 |
| 144 // | 144 // Sends as many bytes in the first |count| buffers of |iov| to the connection |
| 145 // The default implementation always consumed all bytes and any fin, but | 145 // as the connection will consume. |
| 146 // this behavior is not guaranteed for subclasses so callers should check the | 146 // If |ack_notifier_delegate| is provided, then it will be notified once all |
| 147 // return value. | 147 // the ACKs for this write have been received. |
| 148 virtual QuicConsumedData WriteData(base::StringPiece data, bool fin); | 148 // Returns the number of bytes consumed by the connection. |
| 149 QuicConsumedData WritevData( |
| 150 const struct iovec* iov, |
| 151 int iov_count, |
| 152 bool fin, |
| 153 QuicAckNotifier::DelegateInterface* ack_notifier_delegate); |
| 149 | 154 |
| 150 // Close the read side of the socket. Further frames will not be accepted. | 155 // Close the read side of the socket. Further frames will not be accepted. |
| 151 virtual void CloseReadSide(); | 156 virtual void CloseReadSide(); |
| 152 | 157 |
| 153 // Close the write side of the socket. Further writes will fail. | 158 // Close the write side of the socket. Further writes will fail. |
| 154 void CloseWriteSide(); | 159 void CloseWriteSide(); |
| 155 | 160 |
| 156 bool HasBufferedData(); | 161 bool HasBufferedData(); |
| 157 | 162 |
| 158 bool fin_buffered() { return fin_buffered_; } | 163 bool fin_buffered() { return fin_buffered_; } |
| 159 | 164 |
| 160 QuicSession* session() { return session_; } | 165 QuicSession* session() { return session_; } |
| 161 | 166 |
| 162 // Sets priority_ to priority. This should only be called before bytes are | 167 // Sets priority_ to priority. This should only be called before bytes are |
| 163 // written to the server. | 168 // written to the server. |
| 164 void set_priority(QuicPriority priority); | 169 void set_priority(QuicPriority priority); |
| 165 // This is protected because external classes should use EffectivePriority | 170 // This is protected because external classes should use EffectivePriority |
| 166 // instead. | 171 // instead. |
| 167 QuicPriority priority() const { return priority_; } | 172 QuicPriority priority() const { return priority_; } |
| 168 | 173 |
| 169 // Sends as much of 'data' to the connection as the connection will consume, | |
| 170 // and then buffers any remaining data in queued_data_. | |
| 171 // Returns (data.size(), true) as it always consumed all data: it returns for | |
| 172 // convenience to have the same return type as WriteDataInternal. | |
| 173 QuicConsumedData WriteOrBuffer(base::StringPiece data, bool fin); | |
| 174 | |
| 175 // Sends as much of 'data' to the connection as the connection will consume. | |
| 176 // Returns the number of bytes consumed by the connection. | |
| 177 QuicConsumedData WriteDataInternal(base::StringPiece data, bool fin); | |
| 178 | |
| 179 // Sends as many bytes in the first |count| buffers of |iov| to the connection | |
| 180 // as the connection will consume. | |
| 181 // If |ack_notifier_delegate| is provided, then it will be notified once all | |
| 182 // the ACKs for this write have been received. | |
| 183 // Returns the number of bytes consumed by the connection. | |
| 184 QuicConsumedData WritevDataInternal( | |
| 185 const struct iovec* iov, | |
| 186 int iov_count, | |
| 187 bool fin, | |
| 188 QuicAckNotifier::DelegateInterface* ack_notifier_delegate); | |
| 189 | |
| 190 private: | 174 private: |
| 191 friend class test::ReliableQuicStreamPeer; | 175 friend class test::ReliableQuicStreamPeer; |
| 192 friend class QuicStreamUtils; | 176 friend class QuicStreamUtils; |
| 193 | 177 |
| 194 uint32 ProcessHeaderData(); | 178 uint32 ProcessHeaderData(); |
| 195 | 179 |
| 196 uint32 StripPriorityAndHeaderId(const char* data, uint32 data_len); | 180 uint32 StripPriorityAndHeaderId(const char* data, uint32 data_len); |
| 197 | 181 |
| 198 std::list<string> queued_data_; | 182 std::list<string> queued_data_; |
| 199 | 183 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 bool fin_buffered_; | 223 bool fin_buffered_; |
| 240 bool fin_sent_; | 224 bool fin_sent_; |
| 241 | 225 |
| 242 // True if the session this stream is running under is a server session. | 226 // True if the session this stream is running under is a server session. |
| 243 bool is_server_; | 227 bool is_server_; |
| 244 }; | 228 }; |
| 245 | 229 |
| 246 } // namespace net | 230 } // namespace net |
| 247 | 231 |
| 248 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ | 232 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ |
| OLD | NEW |