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

Side by Side Diff: net/quic/quartc/quartc_session.cc

Issue 2916033003: Landing Recent QUIC changes until 03:18 AM, May 28, UTC (Closed)
Patch Set: A few more EXPORTs. Created 3 years, 6 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/quartc/quartc_session.h ('k') | net/quic/quartc/quartc_session_interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 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/quic/quartc/quartc_session.h" 5 #include "net/quic/quartc/quartc_session.h"
6 6
7 #include "net/quic/platform/api/quic_ptr_util.h" 7 #include "net/quic/platform/api/quic_ptr_util.h"
8 8
9 using std::string; 9 using std::string;
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const QuicCryptoStream* QuartcSession::GetCryptoStream() const { 142 const QuicCryptoStream* QuartcSession::GetCryptoStream() const {
143 return crypto_stream_.get(); 143 return crypto_stream_.get();
144 } 144 }
145 145
146 QuicCryptoStream* QuartcSession::GetMutableCryptoStream() { 146 QuicCryptoStream* QuartcSession::GetMutableCryptoStream() {
147 return crypto_stream_.get(); 147 return crypto_stream_.get();
148 } 148 }
149 149
150 QuartcStream* QuartcSession::CreateOutgoingDynamicStream( 150 QuartcStream* QuartcSession::CreateOutgoingDynamicStream(
151 SpdyPriority priority) { 151 SpdyPriority priority) {
152 return CreateDataStream(GetNextOutgoingStreamId(), priority); 152 return ActivateDataStream(
153 CreateDataStream(GetNextOutgoingStreamId(), priority));
153 } 154 }
154 155
155 void QuartcSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { 156 void QuartcSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) {
156 QuicSession::OnCryptoHandshakeEvent(event); 157 QuicSession::OnCryptoHandshakeEvent(event);
157 if (event == HANDSHAKE_CONFIRMED) { 158 if (event == HANDSHAKE_CONFIRMED) {
158 DCHECK(IsEncryptionEstablished()); 159 DCHECK(IsEncryptionEstablished());
159 DCHECK(IsCryptoHandshakeConfirmed()); 160 DCHECK(IsCryptoHandshakeConfirmed());
160 161
161 DCHECK(session_delegate_); 162 DCHECK(session_delegate_);
162 session_delegate_->OnCryptoHandshakeComplete(); 163 session_delegate_->OnCryptoHandshakeComplete();
163 } 164 }
164 } 165 }
165 166
166 void QuartcSession::CloseStream(QuicStreamId stream_id) { 167 void QuartcSession::CloseStream(QuicStreamId stream_id) {
167 if (IsClosedStream(stream_id)) { 168 if (IsClosedStream(stream_id)) {
168 // When CloseStream has been called recursively (via 169 // When CloseStream has been called recursively (via
169 // QuicStream::OnClose), the stream is already closed so return. 170 // QuicStream::OnClose), the stream is already closed so return.
170 return; 171 return;
171 } 172 }
172 write_blocked_streams()->UnregisterStream(stream_id); 173 write_blocked_streams()->UnregisterStream(stream_id);
173 QuicSession::CloseStream(stream_id); 174 QuicSession::CloseStream(stream_id);
174 } 175 }
175 176
177 void QuartcSession::CancelStream(QuicStreamId stream_id) {
178 ResetStream(stream_id, QuicRstStreamErrorCode::QUIC_STREAM_CANCELLED);
179 }
180
181 void QuartcSession::ResetStream(QuicStreamId stream_id,
182 QuicRstStreamErrorCode error) {
183 if (!IsOpenStream(stream_id)) {
184 return;
185 }
186 QuicStream* stream = QuicSession::GetOrCreateStream(stream_id);
187 if (stream) {
188 stream->Reset(error);
189 }
190 }
191
176 void QuartcSession::OnConnectionClosed(QuicErrorCode error, 192 void QuartcSession::OnConnectionClosed(QuicErrorCode error,
177 const string& error_details, 193 const string& error_details,
178 ConnectionCloseSource source) { 194 ConnectionCloseSource source) {
179 QuicSession::OnConnectionClosed(error, error_details, source); 195 QuicSession::OnConnectionClosed(error, error_details, source);
180 DCHECK(session_delegate_); 196 DCHECK(session_delegate_);
181 session_delegate_->OnConnectionClosed( 197 session_delegate_->OnConnectionClosed(
182 error, source == ConnectionCloseSource::FROM_PEER); 198 error, source == ConnectionCloseSource::FROM_PEER);
183 } 199 }
184 200
185 void QuartcSession::StartCryptoHandshake() { 201 void QuartcSession::StartCryptoHandshake() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 QuicCryptoClientConfig* client_config) { 276 QuicCryptoClientConfig* client_config) {
261 quic_crypto_client_config_.reset(client_config); 277 quic_crypto_client_config_.reset(client_config);
262 } 278 }
263 279
264 void QuartcSession::SetServerCryptoConfig( 280 void QuartcSession::SetServerCryptoConfig(
265 QuicCryptoServerConfig* server_config) { 281 QuicCryptoServerConfig* server_config) {
266 quic_crypto_server_config_.reset(server_config); 282 quic_crypto_server_config_.reset(server_config);
267 } 283 }
268 284
269 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { 285 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) {
270 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); 286 return ActivateDataStream(CreateDataStream(id, kDefaultPriority));
287 }
288
289 std::unique_ptr<QuicStream> QuartcSession::CreateStream(QuicStreamId id) {
290 return CreateDataStream(id, kDefaultPriority);
291 }
292
293 std::unique_ptr<QuartcStream> QuartcSession::CreateDataStream(
294 QuicStreamId id,
295 SpdyPriority priority) {
296 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) {
297 // Encryption not active so no stream created
298 return nullptr;
299 }
300 auto stream = QuicMakeUnique<QuartcStream>(id, this);
271 if (stream) { 301 if (stream) {
272 DCHECK(session_delegate_); 302 // Register the stream to the QuicWriteBlockedList. |priority| is clamped
273 session_delegate_->OnIncomingStream(stream); 303 // between 0 and 7, with 0 being the highest priority and 7 the lowest
304 // priority.
305 write_blocked_streams()->RegisterStream(stream->id(), priority);
306
307 if (IsIncomingStream(id)) {
308 DCHECK(session_delegate_);
309 // Incoming streams need to be registered with the session_delegate_.
310 session_delegate_->OnIncomingStream(stream.get());
311 // Quartc doesn't send on incoming streams.
312 stream->set_fin_sent(true);
313 } else {
314 // Quartc doesn't receive on outgoing streams.
315 stream->set_fin_received(true);
316 }
274 } 317 }
275 return stream; 318 return stream;
276 } 319 }
277 320
278 std::unique_ptr<QuicStream> QuartcSession::CreateStream(QuicStreamId id) { 321 QuartcStream* QuartcSession::ActivateDataStream(
279 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); 322 std::unique_ptr<QuartcStream> stream) {
280 return QuicWrapUnique(stream); 323 // Transfer ownership of the data stream to the session via ActivateStream().
281 } 324 QuartcStream* raw = stream.release();
282 325 if (raw) {
283 QuartcStream* QuartcSession::CreateDataStream(QuicStreamId id, 326 // Make QuicSession take ownership of the stream.
284 SpdyPriority priority) { 327 ActivateStream(std::unique_ptr<QuicStream>(raw));
285 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) {
286 // Encryption not active so no stream created
287 return nullptr;
288 } 328 }
289 QuartcStream* stream = new QuartcStream(id, this); 329 return raw;
290 if (stream) {
291 // Make QuicSession take ownership of the stream.
292 ActivateStream(std::unique_ptr<QuicStream>(stream));
293 // Register the stream to the QuicWriteBlockedList. |priority| is clamped
294 // between 0 and 7, with 0 being the highest priority and 7 the lowest
295 // priority.
296 write_blocked_streams()->RegisterStream(stream->id(), priority);
297 }
298 return stream;
299 } 330 }
300 331
301 } // namespace net 332 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quartc/quartc_session.h ('k') | net/quic/quartc/quartc_session_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698