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.
5 #ifndef NET_QUIC_QUIC_HEADERS_STREAM_H_
6 #define NET_QUIC_QUIC_HEADERS_STREAM_H_
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"
17 class QuicSpdySession
;
19 // Headers in QUIC are sent as SPDY SYN_STREAM or SYN_REPLY frames
20 // over a reserved reliable stream with the id 3. Each endpoint (client
21 // and server) will allocate an instance of QuicHeadersStream to send
22 // and receive headers.
23 class NET_EXPORT_PRIVATE QuicHeadersStream
: public ReliableQuicStream
{
25 explicit QuicHeadersStream(QuicSpdySession
* session
);
26 ~QuicHeadersStream() override
;
28 // Writes |headers| for |stream_id| in a SYN_STREAM or SYN_REPLY
29 // frame to the peer. If |fin| is true, the fin flag will be set on
30 // the SPDY frame. Returns the size, in bytes, of the resulting
33 QuicStreamId stream_id
,
34 const SpdyHeaderBlock
& headers
,
36 QuicPriority priority
,
37 QuicAckNotifier::DelegateInterface
* ack_notifier_delegate
);
39 // ReliableQuicStream implementation
40 uint32
ProcessRawData(const char* data
, uint32 data_len
) override
;
41 QuicPriority
EffectivePriority() const override
;
44 class SpdyFramerVisitor
;
46 // The following methods are called by the SimpleVisitor.
48 // Called when a SYN_STREAM frame has been received.
49 void OnSynStream(SpdyStreamId stream_id
,
50 SpdyPriority priority
,
53 // Called when a SYN_REPLY frame been received.
54 void OnSynReply(SpdyStreamId stream_id
, bool fin
);
56 // Called when a chunk of header data is available. This is called
57 // after OnSynStream, or OnSynReply.
58 // |stream_id| The stream receiving the header data.
59 // |header_data| A buffer containing the header data chunk received.
60 // |len| The length of the header data buffer. A length of zero indicates
61 // that the header data block has been completely sent.
62 void OnControlFrameHeaderData(SpdyStreamId stream_id
,
63 const char* header_data
,
66 // Called when the size of the compressed frame payload is available.
67 void OnCompressedFrameSize(size_t frame_len
);
69 // Returns true if the session is still connected.
72 QuicSpdySession
* spdy_session_
;
74 // Data about the stream whose headers are being processed.
75 QuicStreamId stream_id_
;
79 SpdyFramer spdy_framer_
;
80 scoped_ptr
<SpdyFramerVisitor
> spdy_framer_visitor_
;
82 DISALLOW_COPY_AND_ASSIGN(QuicHeadersStream
);
87 #endif // NET_QUIC_QUIC_HEADERS_STREAM_H_