| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_QUIC_QUIC_SPDY_SESSION_H_ | |
| 6 #define NET_QUIC_QUIC_SPDY_SESSION_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "net/quic/quic_header_list.h" | |
| 14 #include "net/quic/quic_headers_stream.h" | |
| 15 #include "net/quic/quic_session.h" | |
| 16 #include "net/quic/quic_spdy_stream.h" | |
| 17 | |
| 18 namespace net { | |
| 19 | |
| 20 namespace test { | |
| 21 class QuicSpdySessionPeer; | |
| 22 } // namespace test | |
| 23 | |
| 24 // A QUIC session with a headers stream. | |
| 25 class NET_EXPORT_PRIVATE QuicSpdySession : public QuicSession { | |
| 26 public: | |
| 27 QuicSpdySession(QuicConnection* connection, const QuicConfig& config); | |
| 28 | |
| 29 ~QuicSpdySession() override; | |
| 30 | |
| 31 void Initialize() override; | |
| 32 | |
| 33 // Called by |headers_stream_| when headers have been received for a stream. | |
| 34 virtual void OnStreamHeaders(QuicStreamId stream_id, | |
| 35 base::StringPiece headers_data); | |
| 36 // Called by |headers_stream_| when headers with a priority have been | |
| 37 // received for this stream. This method will only be called for server | |
| 38 // streams. | |
| 39 virtual void OnStreamHeadersPriority(QuicStreamId stream_id, | |
| 40 SpdyPriority priority); | |
| 41 // Called by |headers_stream_| when headers have been completely received | |
| 42 // for a stream. |fin| will be true if the fin flag was set in the headers | |
| 43 // frame. | |
| 44 virtual void OnStreamHeadersComplete(QuicStreamId stream_id, | |
| 45 bool fin, | |
| 46 size_t frame_len); | |
| 47 | |
| 48 // Called by |headers_stream_| when headers have been completely received | |
| 49 // for a stream. |fin| will be true if the fin flag was set in the headers | |
| 50 // frame. | |
| 51 virtual void OnStreamHeaderList(QuicStreamId stream_id, | |
| 52 bool fin, | |
| 53 size_t frame_len, | |
| 54 const QuicHeaderList& header_list); | |
| 55 | |
| 56 // Called by |headers_stream_| when push promise headers have been | |
| 57 // received for a stream. | |
| 58 virtual void OnPromiseHeaders(QuicStreamId stream_id, | |
| 59 base::StringPiece headers_data); | |
| 60 | |
| 61 // Called by |headers_stream_| when push promise headers have been | |
| 62 // completely received. |fin| will be true if the fin flag was set | |
| 63 // in the headers. | |
| 64 virtual void OnPromiseHeadersComplete(QuicStreamId stream_id, | |
| 65 QuicStreamId promised_stream_id, | |
| 66 size_t frame_len); | |
| 67 | |
| 68 // Called by |headers_stream_| when push promise headers have been | |
| 69 // completely received. |fin| will be true if the fin flag was set | |
| 70 // in the headers. | |
| 71 virtual void OnPromiseHeaderList(QuicStreamId stream_id, | |
| 72 QuicStreamId promised_stream_id, | |
| 73 size_t frame_len, | |
| 74 const QuicHeaderList& header_list); | |
| 75 | |
| 76 // Writes |headers| for the stream |id| to the dedicated headers stream. | |
| 77 // If |fin| is true, then no more data will be sent for the stream |id|. | |
| 78 // If provided, |ack_notifier_delegate| will be registered to be notified when | |
| 79 // we have seen ACKs for all packets resulting from this call. | |
| 80 virtual size_t WriteHeaders(QuicStreamId id, | |
| 81 SpdyHeaderBlock headers, | |
| 82 bool fin, | |
| 83 SpdyPriority priority, | |
| 84 QuicAckListenerInterface* ack_notifier_delegate); | |
| 85 | |
| 86 QuicHeadersStream* headers_stream() { return headers_stream_.get(); } | |
| 87 | |
| 88 // Called when Head of Line Blocking happens in the headers stream. | |
| 89 // |delta| indicates how long that piece of data has been blocked. | |
| 90 virtual void OnHeadersHeadOfLineBlocking(QuicTime::Delta delta); | |
| 91 | |
| 92 // Called by the stream on creation to set priority in the write blocked list. | |
| 93 void RegisterStreamPriority(QuicStreamId id, SpdyPriority priority); | |
| 94 // Called by the stream on deletion to clear priority crom the write blocked | |
| 95 // list. | |
| 96 void UnregisterStreamPriority(QuicStreamId id); | |
| 97 // Called by the stream on SetPriority to update priority on the write blocked | |
| 98 // list. | |
| 99 void UpdateStreamPriority(QuicStreamId id, SpdyPriority new_priority); | |
| 100 | |
| 101 void OnConfigNegotiated() override; | |
| 102 | |
| 103 // Called by |headers_stream_| when |force_hol_blocking_| is true. | |
| 104 virtual void OnStreamFrameData(QuicStreamId stream_id, | |
| 105 const char* data, | |
| 106 size_t len, | |
| 107 bool fin); | |
| 108 | |
| 109 bool force_hol_blocking() const { return force_hol_blocking_; } | |
| 110 | |
| 111 protected: | |
| 112 // Override CreateIncomingDynamicStream() and CreateOutgoingDynamicStream() | |
| 113 // with QuicSpdyStream return type to make sure that all data streams are | |
| 114 // QuicSpdyStreams. | |
| 115 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override = 0; | |
| 116 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override = | |
| 117 0; | |
| 118 | |
| 119 QuicSpdyStream* GetSpdyDataStream(const QuicStreamId stream_id); | |
| 120 | |
| 121 // If an incoming stream can be created, return true. | |
| 122 virtual bool ShouldCreateIncomingDynamicStream(QuicStreamId id) = 0; | |
| 123 | |
| 124 // If an outgoing stream can be created, return true. | |
| 125 virtual bool ShouldCreateOutgoingDynamicStream() = 0; | |
| 126 | |
| 127 private: | |
| 128 friend class test::QuicSpdySessionPeer; | |
| 129 | |
| 130 std::unique_ptr<QuicHeadersStream> headers_stream_; | |
| 131 | |
| 132 // If set, redirect all data through the headers stream in order to | |
| 133 // simulate forced HOL blocking between streams as happens in | |
| 134 // HTTP/2 over TCP. | |
| 135 bool force_hol_blocking_; | |
| 136 | |
| 137 DISALLOW_COPY_AND_ASSIGN(QuicSpdySession); | |
| 138 }; | |
| 139 | |
| 140 } // namespace net | |
| 141 | |
| 142 #endif // NET_QUIC_QUIC_SPDY_SESSION_H_ | |
| OLD | NEW |