Complete SyncMessageFilter initialization after SyncChannel initialization
[chromium-blink-merge.git] / net / quic / quic_headers_stream.h
blob52f7399a061b6e68130630cb231430b4782bb658
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"
15 namespace net {
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 {
24 public:
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
31 // SPDY frame.
32 size_t WriteHeaders(
33 QuicStreamId stream_id,
34 const SpdyHeaderBlock& headers,
35 bool fin,
36 QuicPriority priority,
37 QuicAckNotifier::DelegateInterface* ack_notifier_delegate);
39 // ReliableQuicStream implementation
40 void OnDataAvailable() override;
41 QuicPriority EffectivePriority() const override;
43 private:
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,
51 bool fin);
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,
64 size_t len);
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.
70 bool IsConnected();
72 QuicSpdySession* spdy_session_;
74 // Data about the stream whose headers are being processed.
75 QuicStreamId stream_id_;
76 bool fin_;
77 size_t frame_len_;
79 SpdyFramer spdy_framer_;
80 scoped_ptr<SpdyFramerVisitor> spdy_framer_visitor_;
82 DISALLOW_COPY_AND_ASSIGN(QuicHeadersStream);
85 } // namespace net
87 #endif // NET_QUIC_QUIC_HEADERS_STREAM_H_