Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: net/quic/quic_spdy_session.cc

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_spdy_session.h ('k') | net/quic/quic_spdy_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "net/quic/quic_spdy_session.h"
6
7 #include <utility>
8
9 #include "net/quic/quic_bug_tracker.h"
10 #include "net/quic/quic_headers_stream.h"
11
12 using base::StringPiece;
13 using std::string;
14
15 namespace net {
16
17 QuicSpdySession::QuicSpdySession(QuicConnection* connection,
18 const QuicConfig& config)
19 : QuicSession(connection, config), force_hol_blocking_(false) {}
20
21 QuicSpdySession::~QuicSpdySession() {
22 // Set the streams' session pointers in closed and dynamic stream lists
23 // to null to avoid subsequent use of this session.
24 for (auto* stream : *closed_streams()) {
25 static_cast<QuicSpdyStream*>(stream)->ClearSession();
26 }
27 for (auto const& kv : dynamic_streams()) {
28 static_cast<QuicSpdyStream*>(kv.second)->ClearSession();
29 }
30 }
31
32 void QuicSpdySession::Initialize() {
33 QuicSession::Initialize();
34
35 if (perspective() == Perspective::IS_SERVER) {
36 set_largest_peer_created_stream_id(kHeadersStreamId);
37 } else {
38 QuicStreamId headers_stream_id = GetNextOutgoingStreamId();
39 DCHECK_EQ(headers_stream_id, kHeadersStreamId);
40 }
41
42 headers_stream_.reset(new QuicHeadersStream(this));
43 DCHECK_EQ(kHeadersStreamId, headers_stream_->id());
44 static_streams()[kHeadersStreamId] = headers_stream_.get();
45 }
46
47 void QuicSpdySession::OnStreamHeaders(QuicStreamId stream_id,
48 StringPiece headers_data) {
49 QuicSpdyStream* stream = GetSpdyDataStream(stream_id);
50 if (!stream) {
51 // It's quite possible to receive headers after a stream has been reset.
52 return;
53 }
54 stream->OnStreamHeaders(headers_data);
55 }
56
57 void QuicSpdySession::OnStreamHeadersPriority(QuicStreamId stream_id,
58 SpdyPriority priority) {
59 QuicSpdyStream* stream = GetSpdyDataStream(stream_id);
60 if (!stream) {
61 // It's quite possible to receive headers after a stream has been reset.
62 return;
63 }
64 stream->OnStreamHeadersPriority(priority);
65 }
66
67 void QuicSpdySession::OnStreamHeadersComplete(QuicStreamId stream_id,
68 bool fin,
69 size_t frame_len) {
70 QuicSpdyStream* stream = GetSpdyDataStream(stream_id);
71 if (!stream) {
72 // It's quite possible to receive headers after a stream has been reset.
73 return;
74 }
75 stream->OnStreamHeadersComplete(fin, frame_len);
76 }
77
78 void QuicSpdySession::OnStreamHeaderList(QuicStreamId stream_id,
79 bool fin,
80 size_t frame_len,
81 const QuicHeaderList& header_list) {
82 QuicSpdyStream* stream = GetSpdyDataStream(stream_id);
83 if (!stream) {
84 // It's quite possible to receive headers after a stream has been reset.
85 return;
86 }
87 stream->OnStreamHeaderList(fin, frame_len, header_list);
88 }
89
90 size_t QuicSpdySession::WriteHeaders(
91 QuicStreamId id,
92 SpdyHeaderBlock headers,
93 bool fin,
94 SpdyPriority priority,
95 QuicAckListenerInterface* ack_notifier_delegate) {
96 return headers_stream_->WriteHeaders(id, std::move(headers), fin, priority,
97 ack_notifier_delegate);
98 }
99
100 void QuicSpdySession::OnHeadersHeadOfLineBlocking(QuicTime::Delta delta) {
101 // Implemented in Chromium for stats tracking.
102 }
103
104 void QuicSpdySession::RegisterStreamPriority(QuicStreamId id,
105 SpdyPriority priority) {
106 write_blocked_streams()->RegisterStream(id, priority);
107 }
108
109 void QuicSpdySession::UnregisterStreamPriority(QuicStreamId id) {
110 write_blocked_streams()->UnregisterStream(id);
111 }
112
113 void QuicSpdySession::UpdateStreamPriority(QuicStreamId id,
114 SpdyPriority new_priority) {
115 write_blocked_streams()->UpdateStreamPriority(id, new_priority);
116 }
117
118 QuicSpdyStream* QuicSpdySession::GetSpdyDataStream(
119 const QuicStreamId stream_id) {
120 return static_cast<QuicSpdyStream*>(GetOrCreateDynamicStream(stream_id));
121 }
122
123 void QuicSpdySession::OnPromiseHeaders(QuicStreamId stream_id,
124 StringPiece headers_data) {
125 string error = "OnPromiseHeaders should be overriden in client code.";
126 QUIC_BUG << error;
127 connection()->CloseConnection(QUIC_INTERNAL_ERROR, error,
128 ConnectionCloseBehavior::SILENT_CLOSE);
129 }
130
131 void QuicSpdySession::OnPromiseHeadersComplete(QuicStreamId stream_id,
132 QuicStreamId promised_stream_id,
133 size_t frame_len) {
134 string error = "OnPromiseHeadersComplete should be overriden in client code.";
135 QUIC_BUG << error;
136 connection()->CloseConnection(QUIC_INTERNAL_ERROR, error,
137 ConnectionCloseBehavior::SILENT_CLOSE);
138 }
139
140 void QuicSpdySession::OnPromiseHeaderList(QuicStreamId stream_id,
141 QuicStreamId promised_stream_id,
142 size_t frame_len,
143 const QuicHeaderList& header_list) {
144 string error = "OnPromiseHeaderList should be overriden in client code.";
145 QUIC_BUG << error;
146 connection()->CloseConnection(QUIC_INTERNAL_ERROR, error,
147 ConnectionCloseBehavior::SILENT_CLOSE);
148 }
149
150 void QuicSpdySession::OnConfigNegotiated() {
151 QuicSession::OnConfigNegotiated();
152 if (FLAGS_quic_disable_hpack_dynamic_table &&
153 config()->HasClientSentConnectionOption(kDHDT, perspective())) {
154 headers_stream_->DisableHpackDynamicTable();
155 }
156 const QuicVersion version = connection()->version();
157 if (version > QUIC_VERSION_35 && config()->ForceHolBlocking(perspective())) {
158 force_hol_blocking_ = true;
159 // Autotuning makes sure that the headers stream flow control does
160 // not get in the way, and normal stream and connection level flow
161 // control are active anyway. This is really only for the client
162 // side (and mainly there just in tests and toys), where
163 // autotuning and/or large buffers are not enabled by default.
164 headers_stream_->flow_controller()->set_auto_tune_receive_window(true);
165 }
166 }
167
168 void QuicSpdySession::OnStreamFrameData(QuicStreamId stream_id,
169 const char* data,
170 size_t len,
171 bool fin) {
172 QuicSpdyStream* stream = GetSpdyDataStream(stream_id);
173 if (stream == nullptr) {
174 return;
175 }
176 const QuicStreamOffset offset =
177 stream->flow_controller()->highest_received_byte_offset();
178 const QuicStreamFrame frame(stream_id, fin, offset, StringPiece(data, len));
179 DVLOG(1) << "De-encapsulating DATA frame for stream " << stream_id
180 << " offset " << offset << " len " << len << " fin " << fin;
181 OnStreamFrame(frame);
182 }
183
184 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_spdy_session.h ('k') | net/quic/quic_spdy_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698