| OLD | NEW |
| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void QuartcSession::CloseStream(QuicStreamId stream_id) { | 167 void QuartcSession::CloseStream(QuicStreamId stream_id) { |
| 168 if (IsClosedStream(stream_id)) { | 168 if (IsClosedStream(stream_id)) { |
| 169 // When CloseStream has been called recursively (via | 169 // When CloseStream has been called recursively (via |
| 170 // QuicStream::OnClose), the stream is already closed so return. | 170 // QuicStream::OnClose), the stream is already closed so return. |
| 171 return; | 171 return; |
| 172 } | 172 } |
| 173 write_blocked_streams()->UnregisterStream(stream_id); | 173 write_blocked_streams()->UnregisterStream(stream_id); |
| 174 QuicSession::CloseStream(stream_id); | 174 QuicSession::CloseStream(stream_id); |
| 175 } | 175 } |
| 176 | 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 |
| 177 void QuartcSession::OnConnectionClosed(QuicErrorCode error, | 192 void QuartcSession::OnConnectionClosed(QuicErrorCode error, |
| 178 const string& error_details, | 193 const string& error_details, |
| 179 ConnectionCloseSource source) { | 194 ConnectionCloseSource source) { |
| 180 QuicSession::OnConnectionClosed(error, error_details, source); | 195 QuicSession::OnConnectionClosed(error, error_details, source); |
| 181 DCHECK(session_delegate_); | 196 DCHECK(session_delegate_); |
| 182 session_delegate_->OnConnectionClosed( | 197 session_delegate_->OnConnectionClosed( |
| 183 error, source == ConnectionCloseSource::FROM_PEER); | 198 error, source == ConnectionCloseSource::FROM_PEER); |
| 184 } | 199 } |
| 185 | 200 |
| 186 void QuartcSession::StartCryptoHandshake() { | 201 void QuartcSession::StartCryptoHandshake() { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // Encryption not active so no stream created | 297 // Encryption not active so no stream created |
| 283 return nullptr; | 298 return nullptr; |
| 284 } | 299 } |
| 285 auto stream = QuicMakeUnique<QuartcStream>(id, this); | 300 auto stream = QuicMakeUnique<QuartcStream>(id, this); |
| 286 if (stream) { | 301 if (stream) { |
| 287 // Register the stream to the QuicWriteBlockedList. |priority| is clamped | 302 // Register the stream to the QuicWriteBlockedList. |priority| is clamped |
| 288 // between 0 and 7, with 0 being the highest priority and 7 the lowest | 303 // between 0 and 7, with 0 being the highest priority and 7 the lowest |
| 289 // priority. | 304 // priority. |
| 290 write_blocked_streams()->RegisterStream(stream->id(), priority); | 305 write_blocked_streams()->RegisterStream(stream->id(), priority); |
| 291 | 306 |
| 292 // Incoming streams need to be registered with the session_delegate_. | |
| 293 if (IsIncomingStream(id)) { | 307 if (IsIncomingStream(id)) { |
| 294 DCHECK(session_delegate_); | 308 DCHECK(session_delegate_); |
| 309 // Incoming streams need to be registered with the session_delegate_. |
| 295 session_delegate_->OnIncomingStream(stream.get()); | 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); |
| 296 } | 316 } |
| 297 } | 317 } |
| 298 return stream; | 318 return stream; |
| 299 } | 319 } |
| 300 | 320 |
| 301 QuartcStream* QuartcSession::ActivateDataStream( | 321 QuartcStream* QuartcSession::ActivateDataStream( |
| 302 std::unique_ptr<QuartcStream> stream) { | 322 std::unique_ptr<QuartcStream> stream) { |
| 303 // Transfer ownership of the data stream to the session via ActivateStream(). | 323 // Transfer ownership of the data stream to the session via ActivateStream(). |
| 304 QuartcStream* raw = stream.release(); | 324 QuartcStream* raw = stream.release(); |
| 305 if (raw) { | 325 if (raw) { |
| 306 // Make QuicSession take ownership of the stream. | 326 // Make QuicSession take ownership of the stream. |
| 307 ActivateStream(std::unique_ptr<QuicStream>(raw)); | 327 ActivateStream(std::unique_ptr<QuicStream>(raw)); |
| 308 } | 328 } |
| 309 return raw; | 329 return raw; |
| 310 } | 330 } |
| 311 | 331 |
| 312 } // namespace net | 332 } // namespace net |
| OLD | NEW |