| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_QUIC_QUIC_HEADERS_STREAM_H_ | |
| 6 #define NET_QUIC_QUIC_HEADERS_STREAM_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "net/base/net_export.h" | |
| 11 #include "net/quic/quic_protocol.h" | |
| 12 #include "net/quic/reliable_quic_stream.h" | |
| 13 #include "net/spdy/spdy_framer.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 // Headers in QUIC are sent as SPDY SYN_STREAM or SYN_REPLY frames | |
| 18 // over a reserved reliable stream with the id 2. Each endpoint (client | |
| 19 // and server) will allocate an instance of QuicHeadersStream to send | |
| 20 // and receive headers. | |
| 21 class NET_EXPORT_PRIVATE QuicHeadersStream : public ReliableQuicStream { | |
| 22 public: | |
| 23 explicit QuicHeadersStream(QuicSession* session); | |
| 24 ~QuicHeadersStream() override; | |
| 25 | |
| 26 // Writes |headers| for |stream_id| in a SYN_STREAM or SYN_REPLY | |
| 27 // frame to the peer. If |fin| is true, the fin flag will be set on | |
| 28 // the SPDY frame. Returns the size, in bytes, of the resulting | |
| 29 // SPDY frame. | |
| 30 size_t WriteHeaders( | |
| 31 QuicStreamId stream_id, | |
| 32 const SpdyHeaderBlock& headers, | |
| 33 bool fin, | |
| 34 QuicPriority priority, | |
| 35 QuicAckNotifier::DelegateInterface* ack_notifier_delegate); | |
| 36 | |
| 37 // ReliableQuicStream implementation | |
| 38 uint32 ProcessRawData(const char* data, uint32 data_len) override; | |
| 39 QuicPriority EffectivePriority() const override; | |
| 40 | |
| 41 void OnSuccessfulVersionNegotiation(QuicVersion version); | |
| 42 | |
| 43 private: | |
| 44 class SpdyFramerVisitor; | |
| 45 | |
| 46 void InitializeFramer(QuicVersion version); | |
| 47 | |
| 48 // The following methods are called by the SimpleVisitor. | |
| 49 | |
| 50 // Called when a SYN_STREAM frame has been received. | |
| 51 void OnSynStream(SpdyStreamId stream_id, | |
| 52 SpdyPriority priority, | |
| 53 bool fin); | |
| 54 | |
| 55 // Called when a SYN_REPLY frame been received. | |
| 56 void OnSynReply(SpdyStreamId stream_id, bool fin); | |
| 57 | |
| 58 // Called when a chunk of header data is available. This is called | |
| 59 // after OnSynStream, or OnSynReply. | |
| 60 // |stream_id| The stream receiving the header data. | |
| 61 // |header_data| A buffer containing the header data chunk received. | |
| 62 // |len| The length of the header data buffer. A length of zero indicates | |
| 63 // that the header data block has been completely sent. | |
| 64 void OnControlFrameHeaderData(SpdyStreamId stream_id, | |
| 65 const char* header_data, | |
| 66 size_t len); | |
| 67 | |
| 68 // Called when the size of the compressed frame payload is available. | |
| 69 void OnCompressedFrameSize(size_t frame_len); | |
| 70 | |
| 71 // Returns true if the session is still connected. | |
| 72 bool IsConnected(); | |
| 73 | |
| 74 // Data about the stream whose headers are being processed. | |
| 75 QuicStreamId stream_id_; | |
| 76 bool fin_; | |
| 77 size_t frame_len_; | |
| 78 | |
| 79 scoped_ptr<SpdyFramer> spdy_framer_; | |
| 80 scoped_ptr<SpdyFramerVisitor> spdy_framer_visitor_; | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(QuicHeadersStream); | |
| 83 }; | |
| 84 | |
| 85 } // namespace net | |
| 86 | |
| 87 #endif // NET_QUIC_QUIC_HEADERS_STREAM_H_ | |
| OLD | NEW |