| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 streams which deliver data to/from an application. | 5 // The base class for streams which deliver data to/from an application. |
| 6 // In each direction, the data on such a stream first contains compressed | 6 // In each direction, the data on such a stream first contains compressed |
| 7 // headers then body data. | 7 // headers then body data. |
| 8 | 8 |
| 9 #ifndef NET_QUIC_QUIC_SPDY_STREAM_H_ | 9 #ifndef NET_QUIC_QUIC_SPDY_STREAM_H_ |
| 10 #define NET_QUIC_QUIC_SPDY_STREAM_H_ | 10 #define NET_QUIC_QUIC_SPDY_STREAM_H_ |
| 11 | 11 |
| 12 #include <stddef.h> | 12 #include <stddef.h> |
| 13 #include <sys/types.h> | 13 #include <sys/types.h> |
| 14 | 14 |
| 15 #include <list> | 15 #include <list> |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
| 20 #include "net/base/iovec.h" | 20 #include "net/base/iovec.h" |
| 21 #include "net/base/ip_endpoint.h" | 21 #include "net/base/ip_endpoint.h" |
| 22 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
| 23 #include "net/quic/core/quic_flags.h" | 23 #include "net/quic/core/quic_flags.h" |
| 24 #include "net/quic/core/quic_header_list.h" | 24 #include "net/quic/core/quic_header_list.h" |
| 25 #include "net/quic/core/quic_protocol.h" | 25 #include "net/quic/core/quic_protocol.h" |
| 26 #include "net/quic/core/quic_stream.h" |
| 26 #include "net/quic/core/quic_stream_sequencer.h" | 27 #include "net/quic/core/quic_stream_sequencer.h" |
| 27 #include "net/quic/core/reliable_quic_stream.h" | |
| 28 #include "net/spdy/spdy_framer.h" | 28 #include "net/spdy/spdy_framer.h" |
| 29 | 29 |
| 30 namespace net { | 30 namespace net { |
| 31 | 31 |
| 32 namespace test { | 32 namespace test { |
| 33 class QuicSpdyStreamPeer; | 33 class QuicSpdyStreamPeer; |
| 34 class ReliableQuicStreamPeer; | 34 class QuicStreamPeer; |
| 35 } // namespace test | 35 } // namespace test |
| 36 | 36 |
| 37 class QuicSpdySession; | 37 class QuicSpdySession; |
| 38 | 38 |
| 39 // This is somewhat arbitrary. It's possible, but unlikely, we will either fail | 39 // This is somewhat arbitrary. It's possible, but unlikely, we will either fail |
| 40 // to set a priority client-side, or cancel a stream before stripping the | 40 // to set a priority client-side, or cancel a stream before stripping the |
| 41 // priority from the wire server-side. In either case, start out with a | 41 // priority from the wire server-side. In either case, start out with a |
| 42 // priority in the middle. | 42 // priority in the middle. |
| 43 const SpdyPriority kDefaultPriority = 3; | 43 const SpdyPriority kDefaultPriority = 3; |
| 44 | 44 |
| 45 // A QUIC stream that can send and receive HTTP2 (SPDY) headers. | 45 // A QUIC stream that can send and receive HTTP2 (SPDY) headers. |
| 46 class NET_EXPORT_PRIVATE QuicSpdyStream : public ReliableQuicStream { | 46 class NET_EXPORT_PRIVATE QuicSpdyStream : public QuicStream { |
| 47 public: | 47 public: |
| 48 // Visitor receives callbacks from the stream. | 48 // Visitor receives callbacks from the stream. |
| 49 class NET_EXPORT_PRIVATE Visitor { | 49 class NET_EXPORT_PRIVATE Visitor { |
| 50 public: | 50 public: |
| 51 Visitor() {} | 51 Visitor() {} |
| 52 | 52 |
| 53 // Called when the stream is closed. | 53 // Called when the stream is closed. |
| 54 virtual void OnClose(QuicSpdyStream* stream) = 0; | 54 virtual void OnClose(QuicSpdyStream* stream) = 0; |
| 55 | 55 |
| 56 // Allows subclasses to override and do work. | 56 // Allows subclasses to override and do work. |
| 57 virtual void OnPromiseHeadersComplete(QuicStreamId promised_id, | 57 virtual void OnPromiseHeadersComplete(QuicStreamId promised_id, |
| 58 size_t frame_len) {} | 58 size_t frame_len) {} |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 virtual ~Visitor() {} | 61 virtual ~Visitor() {} |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(Visitor); | 64 DISALLOW_COPY_AND_ASSIGN(Visitor); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session); | 67 QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session); |
| 68 ~QuicSpdyStream() override; | 68 ~QuicSpdyStream() override; |
| 69 | 69 |
| 70 // Override the base class to send QUIC_STREAM_NO_ERROR to the peer | 70 // Override the base class to send QUIC_STREAM_NO_ERROR to the peer |
| 71 // when the stream has not received all the data. | 71 // when the stream has not received all the data. |
| 72 void CloseWriteSide() override; | 72 void CloseWriteSide() override; |
| 73 void StopReading() override; | 73 void StopReading() override; |
| 74 | 74 |
| 75 // ReliableQuicStream implementation | 75 // QuicStream implementation |
| 76 void OnClose() override; | 76 void OnClose() override; |
| 77 | 77 |
| 78 // Override to maybe close the write side after writing. | 78 // Override to maybe close the write side after writing. |
| 79 void OnCanWrite() override; | 79 void OnCanWrite() override; |
| 80 | 80 |
| 81 // Called by the session when headers with a priority have been received | 81 // Called by the session when headers with a priority have been received |
| 82 // for this stream. This method will only be called for server streams. | 82 // for this stream. This method will only be called for server streams. |
| 83 virtual void OnStreamHeadersPriority(SpdyPriority priority); | 83 virtual void OnStreamHeadersPriority(SpdyPriority priority); |
| 84 | 84 |
| 85 // Called by the session when decompressed headers have been completely | 85 // Called by the session when decompressed headers have been completely |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // Redirects to the headers stream if force HOL blocking enabled, | 196 // Redirects to the headers stream if force HOL blocking enabled, |
| 197 // otherwise just pass through. | 197 // otherwise just pass through. |
| 198 QuicConsumedData WritevDataInner( | 198 QuicConsumedData WritevDataInner( |
| 199 QuicIOVector iov, | 199 QuicIOVector iov, |
| 200 QuicStreamOffset offset, | 200 QuicStreamOffset offset, |
| 201 bool fin, | 201 bool fin, |
| 202 QuicAckListenerInterface* ack_notifier_delegate) override; | 202 QuicAckListenerInterface* ack_notifier_delegate) override; |
| 203 | 203 |
| 204 private: | 204 private: |
| 205 friend class test::QuicSpdyStreamPeer; | 205 friend class test::QuicSpdyStreamPeer; |
| 206 friend class test::ReliableQuicStreamPeer; | 206 friend class test::QuicStreamPeer; |
| 207 friend class QuicStreamUtils; | 207 friend class QuicStreamUtils; |
| 208 | 208 |
| 209 QuicSpdySession* spdy_session_; | 209 QuicSpdySession* spdy_session_; |
| 210 | 210 |
| 211 Visitor* visitor_; | 211 Visitor* visitor_; |
| 212 // If true, allow sending of a request to continue while the response is | 212 // If true, allow sending of a request to continue while the response is |
| 213 // arriving. | 213 // arriving. |
| 214 bool allow_bidirectional_data_; | 214 bool allow_bidirectional_data_; |
| 215 // True if the headers have been completely decompressed. | 215 // True if the headers have been completely decompressed. |
| 216 bool headers_decompressed_; | 216 bool headers_decompressed_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 227 bool trailers_consumed_; | 227 bool trailers_consumed_; |
| 228 // The parsed trailers received from the peer. | 228 // The parsed trailers received from the peer. |
| 229 SpdyHeaderBlock received_trailers_; | 229 SpdyHeaderBlock received_trailers_; |
| 230 | 230 |
| 231 DISALLOW_COPY_AND_ASSIGN(QuicSpdyStream); | 231 DISALLOW_COPY_AND_ASSIGN(QuicSpdyStream); |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 } // namespace net | 234 } // namespace net |
| 235 | 235 |
| 236 #endif // NET_QUIC_QUIC_SPDY_STREAM_H_ | 236 #endif // NET_QUIC_QUIC_SPDY_STREAM_H_ |
| OLD | NEW |