OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/tools/quic/quic_simple_server_session.h" | 5 #include "net/tools/quic/quic_simple_server_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "net/quic/core/proto/cached_network_parameters.pb.h" | 9 #include "net/quic/core/proto/cached_network_parameters.pb.h" |
10 #include "net/quic/core/quic_connection.h" | 10 #include "net/quic/core/quic_connection.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return nullptr; | 107 return nullptr; |
108 } | 108 } |
109 | 109 |
110 QuicSimpleServerStream* stream = new QuicSimpleServerStream( | 110 QuicSimpleServerStream* stream = new QuicSimpleServerStream( |
111 GetNextOutgoingStreamId(), this, response_cache_); | 111 GetNextOutgoingStreamId(), this, response_cache_); |
112 stream->SetPriority(priority); | 112 stream->SetPriority(priority); |
113 ActivateStream(QuicWrapUnique(stream)); | 113 ActivateStream(QuicWrapUnique(stream)); |
114 return stream; | 114 return stream; |
115 } | 115 } |
116 | 116 |
117 std::unique_ptr<QuicStream> QuicSimpleServerSession::CreateStream( | |
118 QuicStreamId id) { | |
119 return QuicMakeUnique<QuicSimpleServerStream>(id, this, response_cache_); | |
120 } | |
121 | |
122 void QuicSimpleServerSession::CloseStreamInner(QuicStreamId stream_id, | 117 void QuicSimpleServerSession::CloseStreamInner(QuicStreamId stream_id, |
123 bool locally_reset) { | 118 bool locally_reset) { |
124 QuicSpdySession::CloseStreamInner(stream_id, locally_reset); | 119 QuicSpdySession::CloseStreamInner(stream_id, locally_reset); |
125 HandlePromisedPushRequests(); | 120 HandlePromisedPushRequests(); |
126 } | 121 } |
127 | 122 |
128 void QuicSimpleServerSession::HandleFrameOnNonexistentOutgoingStream( | 123 void QuicSimpleServerSession::HandleFrameOnNonexistentOutgoingStream( |
129 QuicStreamId stream_id) { | 124 QuicStreamId stream_id) { |
130 // If this stream is a promised but not created stream (stream_id within the | 125 // If this stream is a promised but not created stream (stream_id within the |
131 // range of next_outgoing_stream_id_ and highes_promised_stream_id_), | 126 // range of next_outgoing_stream_id_ and highes_promised_stream_id_), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void QuicSimpleServerSession::SendPushPromise(QuicStreamId original_stream_id, | 175 void QuicSimpleServerSession::SendPushPromise(QuicStreamId original_stream_id, |
181 QuicStreamId promised_stream_id, | 176 QuicStreamId promised_stream_id, |
182 SpdyHeaderBlock headers) { | 177 SpdyHeaderBlock headers) { |
183 QUIC_DLOG(INFO) << "stream " << original_stream_id | 178 QUIC_DLOG(INFO) << "stream " << original_stream_id |
184 << " send PUSH_PROMISE for promised stream " | 179 << " send PUSH_PROMISE for promised stream " |
185 << promised_stream_id; | 180 << promised_stream_id; |
186 WritePushPromise(original_stream_id, promised_stream_id, std::move(headers)); | 181 WritePushPromise(original_stream_id, promised_stream_id, std::move(headers)); |
187 } | 182 } |
188 | 183 |
189 void QuicSimpleServerSession::HandlePromisedPushRequests() { | 184 void QuicSimpleServerSession::HandlePromisedPushRequests() { |
190 while (!promised_streams_.empty() && | 185 while (!promised_streams_.empty() && ShouldCreateOutgoingDynamicStream()) { |
191 (FLAGS_quic_reloadable_flag_quic_refactor_stream_creation | |
192 ? ShouldCreateOutgoingDynamicStream2() | |
193 : ShouldCreateOutgoingDynamicStream())) { | |
194 PromisedStreamInfo& promised_info = promised_streams_.front(); | 186 PromisedStreamInfo& promised_info = promised_streams_.front(); |
195 DCHECK_EQ(next_outgoing_stream_id(), promised_info.stream_id); | 187 DCHECK_EQ(next_outgoing_stream_id(), promised_info.stream_id); |
196 | 188 |
197 if (promised_info.is_cancelled) { | 189 if (promised_info.is_cancelled) { |
198 // This stream has been reset by client. Skip this stream id. | 190 // This stream has been reset by client. Skip this stream id. |
199 promised_streams_.pop_front(); | 191 promised_streams_.pop_front(); |
200 GetNextOutgoingStreamId(); | 192 GetNextOutgoingStreamId(); |
201 return; | 193 return; |
202 } | 194 } |
203 | 195 |
204 QuicSimpleServerStream* promised_stream = | 196 QuicSimpleServerStream* promised_stream = |
205 static_cast<QuicSimpleServerStream*>( | 197 static_cast<QuicSimpleServerStream*>( |
206 FLAGS_quic_reloadable_flag_quic_refactor_stream_creation | 198 CreateOutgoingDynamicStream(promised_info.priority)); |
207 ? MaybeCreateOutgoingDynamicStream(promised_info.priority) | |
208 : CreateOutgoingDynamicStream(promised_info.priority)); | |
209 DCHECK_NE(promised_stream, nullptr); | 199 DCHECK_NE(promised_stream, nullptr); |
210 DCHECK_EQ(promised_info.stream_id, promised_stream->id()); | 200 DCHECK_EQ(promised_info.stream_id, promised_stream->id()); |
211 QUIC_DLOG(INFO) << "created server push stream " << promised_stream->id(); | 201 QUIC_DLOG(INFO) << "created server push stream " << promised_stream->id(); |
212 | 202 |
213 SpdyHeaderBlock request_headers(std::move(promised_info.request_headers)); | 203 SpdyHeaderBlock request_headers(std::move(promised_info.request_headers)); |
214 | 204 |
215 promised_streams_.pop_front(); | 205 promised_streams_.pop_front(); |
216 promised_stream->PushResponse(std::move(request_headers)); | 206 promised_stream->PushResponse(std::move(request_headers)); |
217 } | 207 } |
218 } | 208 } |
219 | 209 |
220 } // namespace net | 210 } // namespace net |
OLD | NEW |