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.
5 #include "net/quic/quic_spdy_session.h"
7 #include "net/quic/quic_headers_stream.h"
11 QuicSpdySession::QuicSpdySession(QuicConnection
* connection
,
12 const QuicConfig
& config
)
13 : QuicSession(connection
, config
) {
16 QuicSpdySession::~QuicSpdySession() {
19 void QuicSpdySession::Initialize() {
20 QuicSession::Initialize();
22 if (perspective() == Perspective::IS_SERVER
) {
23 set_largest_peer_created_stream_id(kHeadersStreamId
);
25 QuicStreamId headers_stream_id
= GetNextStreamId();
26 DCHECK_EQ(headers_stream_id
, kHeadersStreamId
);
29 headers_stream_
.reset(new QuicHeadersStream(this));
30 DCHECK_EQ(kHeadersStreamId
, headers_stream_
->id());
31 static_streams()[kHeadersStreamId
] = headers_stream_
.get();
34 void QuicSpdySession::OnStreamHeaders(QuicStreamId stream_id
,
35 StringPiece headers_data
) {
36 QuicDataStream
* stream
= GetSpdyDataStream(stream_id
);
38 // It's quite possible to receive headers after a stream has been reset.
41 stream
->OnStreamHeaders(headers_data
);
44 void QuicSpdySession::OnStreamHeadersPriority(QuicStreamId stream_id
,
45 QuicPriority priority
) {
46 QuicDataStream
* stream
= GetSpdyDataStream(stream_id
);
48 // It's quite possible to receive headers after a stream has been reset.
51 stream
->OnStreamHeadersPriority(priority
);
54 void QuicSpdySession::OnStreamHeadersComplete(QuicStreamId stream_id
,
57 QuicDataStream
* stream
= GetSpdyDataStream(stream_id
);
59 // It's quite possible to receive headers after a stream has been reset.
62 stream
->OnStreamHeadersComplete(fin
, frame_len
);
65 size_t QuicSpdySession::WriteHeaders(
67 const SpdyHeaderBlock
& headers
,
69 QuicPriority priority
,
70 QuicAckNotifier::DelegateInterface
* ack_notifier_delegate
) {
71 return headers_stream_
->WriteHeaders(id
, headers
, fin
, priority
,
72 ack_notifier_delegate
);
75 QuicDataStream
* QuicSpdySession::GetSpdyDataStream(
76 const QuicStreamId stream_id
) {
77 return static_cast<QuicDataStream
*>(GetDynamicStream(stream_id
));