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