| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 DCHECK(IsCryptoHandshakeConfirmed()); | 155 DCHECK(IsCryptoHandshakeConfirmed()); |
| 156 | 156 |
| 157 DCHECK(session_delegate_); | 157 DCHECK(session_delegate_); |
| 158 session_delegate_->OnCryptoHandshakeComplete(); | 158 session_delegate_->OnCryptoHandshakeComplete(); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 void QuartcSession::CloseStream(QuicStreamId stream_id) { | 162 void QuartcSession::CloseStream(QuicStreamId stream_id) { |
| 163 if (IsClosedStream(stream_id)) { | 163 if (IsClosedStream(stream_id)) { |
| 164 // When CloseStream has been called recursively (via | 164 // When CloseStream has been called recursively (via |
| 165 // ReliableQuicStream::OnClose), the stream is already closed so return. | 165 // QuicStream::OnClose), the stream is already closed so return. |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 write_blocked_streams()->UnregisterStream(stream_id); | 168 write_blocked_streams()->UnregisterStream(stream_id); |
| 169 QuicSession::CloseStream(stream_id); | 169 QuicSession::CloseStream(stream_id); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void QuartcSession::OnConnectionClosed(QuicErrorCode error, | 172 void QuartcSession::OnConnectionClosed(QuicErrorCode error, |
| 173 const std::string& error_details, | 173 const std::string& error_details, |
| 174 ConnectionCloseSource source) { | 174 ConnectionCloseSource source) { |
| 175 QuicSession::OnConnectionClosed(error, error_details, source); | 175 QuicSession::OnConnectionClosed(error, error_details, source); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 void QuartcSession::SetClientCryptoConfig( | 255 void QuartcSession::SetClientCryptoConfig( |
| 256 QuicCryptoClientConfig* client_config) { | 256 QuicCryptoClientConfig* client_config) { |
| 257 quic_crypto_client_config_.reset(client_config); | 257 quic_crypto_client_config_.reset(client_config); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void QuartcSession::SetServerCryptoConfig( | 260 void QuartcSession::SetServerCryptoConfig( |
| 261 QuicCryptoServerConfig* server_config) { | 261 QuicCryptoServerConfig* server_config) { |
| 262 quic_crypto_server_config_.reset(server_config); | 262 quic_crypto_server_config_.reset(server_config); |
| 263 } | 263 } |
| 264 | 264 |
| 265 ReliableQuicStream* QuartcSession::CreateIncomingDynamicStream( | 265 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { |
| 266 QuicStreamId id) { | |
| 267 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); | 266 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); |
| 268 if (stream) { | 267 if (stream) { |
| 269 DCHECK(session_delegate_); | 268 DCHECK(session_delegate_); |
| 270 session_delegate_->OnIncomingStream(stream); | 269 session_delegate_->OnIncomingStream(stream); |
| 271 } | 270 } |
| 272 return stream; | 271 return stream; |
| 273 } | 272 } |
| 274 | 273 |
| 275 QuartcStream* QuartcSession::CreateDataStream(QuicStreamId id, | 274 QuartcStream* QuartcSession::CreateDataStream(QuicStreamId id, |
| 276 SpdyPriority priority) { | 275 SpdyPriority priority) { |
| 277 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { | 276 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { |
| 278 // Encryption not active so no stream created | 277 // Encryption not active so no stream created |
| 279 return nullptr; | 278 return nullptr; |
| 280 } | 279 } |
| 281 QuartcStream* stream = new QuartcStream(id, this); | 280 QuartcStream* stream = new QuartcStream(id, this); |
| 282 if (stream) { | 281 if (stream) { |
| 283 // Make QuicSession take ownership of the stream. | 282 // Make QuicSession take ownership of the stream. |
| 284 ActivateStream(std::unique_ptr<ReliableQuicStream>(stream)); | 283 ActivateStream(std::unique_ptr<QuicStream>(stream)); |
| 285 // Register the stream to the QuicWriteBlockedList. |priority| is clamped | 284 // Register the stream to the QuicWriteBlockedList. |priority| is clamped |
| 286 // between 0 and 7, with 0 being the highest priority and 7 the lowest | 285 // between 0 and 7, with 0 being the highest priority and 7 the lowest |
| 287 // priority. | 286 // priority. |
| 288 write_blocked_streams()->RegisterStream(stream->id(), priority); | 287 write_blocked_streams()->RegisterStream(stream->id(), priority); |
| 289 } | 288 } |
| 290 return stream; | 289 return stream; |
| 291 } | 290 } |
| 292 | 291 |
| 293 } // namespace net | 292 } // namespace net |
| OLD | NEW |