Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / net / quic / quic_spdy_session.cc
blob0a8dda6929e139c0c6542f580b91c6d254095d39
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"
9 namespace net {
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);
24 } else {
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);
37 if (!stream) {
38 // It's quite possible to receive headers after a stream has been reset.
39 return;
41 stream->OnStreamHeaders(headers_data);
44 void QuicSpdySession::OnStreamHeadersPriority(QuicStreamId stream_id,
45 QuicPriority priority) {
46 QuicDataStream* stream = GetSpdyDataStream(stream_id);
47 if (!stream) {
48 // It's quite possible to receive headers after a stream has been reset.
49 return;
51 stream->OnStreamHeadersPriority(priority);
54 void QuicSpdySession::OnStreamHeadersComplete(QuicStreamId stream_id,
55 bool fin,
56 size_t frame_len) {
57 QuicDataStream* stream = GetSpdyDataStream(stream_id);
58 if (!stream) {
59 // It's quite possible to receive headers after a stream has been reset.
60 return;
62 stream->OnStreamHeadersComplete(fin, frame_len);
65 size_t QuicSpdySession::WriteHeaders(
66 QuicStreamId id,
67 const SpdyHeaderBlock& headers,
68 bool fin,
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));
80 } // namespace net