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 |
117 void QuicSimpleServerSession::CloseStreamInner(QuicStreamId stream_id, | 122 void QuicSimpleServerSession::CloseStreamInner(QuicStreamId stream_id, |
118 bool locally_reset) { | 123 bool locally_reset) { |
119 QuicSpdySession::CloseStreamInner(stream_id, locally_reset); | 124 QuicSpdySession::CloseStreamInner(stream_id, locally_reset); |
120 HandlePromisedPushRequests(); | 125 HandlePromisedPushRequests(); |
121 } | 126 } |
122 | 127 |
123 void QuicSimpleServerSession::HandleFrameOnNonexistentOutgoingStream( | 128 void QuicSimpleServerSession::HandleFrameOnNonexistentOutgoingStream( |
124 QuicStreamId stream_id) { | 129 QuicStreamId stream_id) { |
125 // If this stream is a promised but not created stream (stream_id within the | 130 // If this stream is a promised but not created stream (stream_id within the |
126 // range of next_outgoing_stream_id_ and highes_promised_stream_id_), | 131 // range of next_outgoing_stream_id_ and highes_promised_stream_id_), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void QuicSimpleServerSession::SendPushPromise(QuicStreamId original_stream_id, | 180 void QuicSimpleServerSession::SendPushPromise(QuicStreamId original_stream_id, |
176 QuicStreamId promised_stream_id, | 181 QuicStreamId promised_stream_id, |
177 SpdyHeaderBlock headers) { | 182 SpdyHeaderBlock headers) { |
178 QUIC_DLOG(INFO) << "stream " << original_stream_id | 183 QUIC_DLOG(INFO) << "stream " << original_stream_id |
179 << " send PUSH_PROMISE for promised stream " | 184 << " send PUSH_PROMISE for promised stream " |
180 << promised_stream_id; | 185 << promised_stream_id; |
181 WritePushPromise(original_stream_id, promised_stream_id, std::move(headers)); | 186 WritePushPromise(original_stream_id, promised_stream_id, std::move(headers)); |
182 } | 187 } |
183 | 188 |
184 void QuicSimpleServerSession::HandlePromisedPushRequests() { | 189 void QuicSimpleServerSession::HandlePromisedPushRequests() { |
185 while (!promised_streams_.empty() && ShouldCreateOutgoingDynamicStream()) { | 190 while (!promised_streams_.empty() && |
| 191 (FLAGS_quic_reloadable_flag_quic_refactor_stream_creation |
| 192 ? ShouldCreateOutgoingDynamicStream2() |
| 193 : ShouldCreateOutgoingDynamicStream())) { |
186 PromisedStreamInfo& promised_info = promised_streams_.front(); | 194 PromisedStreamInfo& promised_info = promised_streams_.front(); |
187 DCHECK_EQ(next_outgoing_stream_id(), promised_info.stream_id); | 195 DCHECK_EQ(next_outgoing_stream_id(), promised_info.stream_id); |
188 | 196 |
189 if (promised_info.is_cancelled) { | 197 if (promised_info.is_cancelled) { |
190 // This stream has been reset by client. Skip this stream id. | 198 // This stream has been reset by client. Skip this stream id. |
191 promised_streams_.pop_front(); | 199 promised_streams_.pop_front(); |
192 GetNextOutgoingStreamId(); | 200 GetNextOutgoingStreamId(); |
193 return; | 201 return; |
194 } | 202 } |
195 | 203 |
196 QuicSimpleServerStream* promised_stream = | 204 QuicSimpleServerStream* promised_stream = |
197 static_cast<QuicSimpleServerStream*>( | 205 static_cast<QuicSimpleServerStream*>( |
198 CreateOutgoingDynamicStream(promised_info.priority)); | 206 FLAGS_quic_reloadable_flag_quic_refactor_stream_creation |
| 207 ? MaybeCreateOutgoingDynamicStream(promised_info.priority) |
| 208 : CreateOutgoingDynamicStream(promised_info.priority)); |
199 DCHECK_NE(promised_stream, nullptr); | 209 DCHECK_NE(promised_stream, nullptr); |
200 DCHECK_EQ(promised_info.stream_id, promised_stream->id()); | 210 DCHECK_EQ(promised_info.stream_id, promised_stream->id()); |
201 QUIC_DLOG(INFO) << "created server push stream " << promised_stream->id(); | 211 QUIC_DLOG(INFO) << "created server push stream " << promised_stream->id(); |
202 | 212 |
203 SpdyHeaderBlock request_headers(std::move(promised_info.request_headers)); | 213 SpdyHeaderBlock request_headers(std::move(promised_info.request_headers)); |
204 | 214 |
205 promised_streams_.pop_front(); | 215 promised_streams_.pop_front(); |
206 promised_stream->PushResponse(std::move(request_headers)); | 216 promised_stream->PushResponse(std::move(request_headers)); |
207 } | 217 } |
208 } | 218 } |
209 | 219 |
210 } // namespace net | 220 } // namespace net |
OLD | NEW |