| 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" | |
| 8 | |
| 9 using std::string; | 7 using std::string; |
| 10 | 8 |
| 11 namespace net { | 9 namespace net { |
| 12 | 10 |
| 13 namespace { | 11 namespace { |
| 14 | 12 |
| 15 // Default priority for incoming QUIC streams. | 13 // Default priority for incoming QUIC streams. |
| 16 // TODO(zhihuang): Determine if this value is correct. | 14 // TODO(zhihuang): Determine if this value is correct. |
| 17 static const SpdyPriority kDefaultPriority = 3; | 15 static const SpdyPriority kDefaultPriority = 3; |
| 18 | 16 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 266 |
| 269 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { | 267 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { |
| 270 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); | 268 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); |
| 271 if (stream) { | 269 if (stream) { |
| 272 DCHECK(session_delegate_); | 270 DCHECK(session_delegate_); |
| 273 session_delegate_->OnIncomingStream(stream); | 271 session_delegate_->OnIncomingStream(stream); |
| 274 } | 272 } |
| 275 return stream; | 273 return stream; |
| 276 } | 274 } |
| 277 | 275 |
| 278 std::unique_ptr<QuicStream> QuartcSession::CreateStream(QuicStreamId id) { | |
| 279 QuartcStream* stream = CreateDataStream(id, kDefaultPriority); | |
| 280 return QuicWrapUnique(stream); | |
| 281 } | |
| 282 | |
| 283 QuartcStream* QuartcSession::CreateDataStream(QuicStreamId id, | 276 QuartcStream* QuartcSession::CreateDataStream(QuicStreamId id, |
| 284 SpdyPriority priority) { | 277 SpdyPriority priority) { |
| 285 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { | 278 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { |
| 286 // Encryption not active so no stream created | 279 // Encryption not active so no stream created |
| 287 return nullptr; | 280 return nullptr; |
| 288 } | 281 } |
| 289 QuartcStream* stream = new QuartcStream(id, this); | 282 QuartcStream* stream = new QuartcStream(id, this); |
| 290 if (stream) { | 283 if (stream) { |
| 291 // Make QuicSession take ownership of the stream. | 284 // Make QuicSession take ownership of the stream. |
| 292 ActivateStream(std::unique_ptr<QuicStream>(stream)); | 285 ActivateStream(std::unique_ptr<QuicStream>(stream)); |
| 293 // Register the stream to the QuicWriteBlockedList. |priority| is clamped | 286 // Register the stream to the QuicWriteBlockedList. |priority| is clamped |
| 294 // between 0 and 7, with 0 being the highest priority and 7 the lowest | 287 // between 0 and 7, with 0 being the highest priority and 7 the lowest |
| 295 // priority. | 288 // priority. |
| 296 write_blocked_streams()->RegisterStream(stream->id(), priority); | 289 write_blocked_streams()->RegisterStream(stream->id(), priority); |
| 297 } | 290 } |
| 298 return stream; | 291 return stream; |
| 299 } | 292 } |
| 300 | 293 |
| 301 } // namespace net | 294 } // namespace net |
| OLD | NEW |