| 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 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 // Default priority for incoming QUIC streams. | 15 // Default priority for incoming QUIC streams. |
| 16 // TODO(zhihuang): Determine if this value is correct. | 16 // TODO(zhihuang): Determine if this value is correct. |
| 17 static const SpdyPriority kDefaultPriority = 3; | 17 static const SpdyPriority kDefaultSpdyPriority = 3; |
| 18 | 18 |
| 19 // Arbitrary server port number for net::QuicCryptoClientConfig. | 19 // Arbitrary server port number for net::QuicCryptoClientConfig. |
| 20 const int kQuicServerPort = 0; | 20 const int kQuicServerPort = 0; |
| 21 | 21 |
| 22 // Length of HKDF input keying material, equal to its number of bytes. | 22 // Length of HKDF input keying material, equal to its number of bytes. |
| 23 // https://tools.ietf.org/html/rfc5869#section-2.2. | 23 // https://tools.ietf.org/html/rfc5869#section-2.2. |
| 24 // TODO(zhihuang): Verify that input keying material length is correct. | 24 // TODO(zhihuang): Verify that input keying material length is correct. |
| 25 const size_t kInputKeyingMaterialLength = 32; | 25 const size_t kInputKeyingMaterialLength = 32; |
| 26 | 26 |
| 27 // Used by QuicCryptoServerConfig to provide dummy proof credentials. | 27 // Used by QuicCryptoServerConfig to provide dummy proof credentials. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 bool success = crypto_stream_->ExportKeyingMaterial(label, quic_context, | 230 bool success = crypto_stream_->ExportKeyingMaterial(label, quic_context, |
| 231 result_len, &quic_result); | 231 result_len, &quic_result); |
| 232 quic_result.copy(reinterpret_cast<char*>(result), result_len); | 232 quic_result.copy(reinterpret_cast<char*>(result), result_len); |
| 233 DCHECK(quic_result.length() == result_len); | 233 DCHECK(quic_result.length() == result_len); |
| 234 return success; | 234 return success; |
| 235 } | 235 } |
| 236 | 236 |
| 237 QuartcStreamInterface* QuartcSession::CreateOutgoingStream( | 237 QuartcStreamInterface* QuartcSession::CreateOutgoingStream( |
| 238 const OutgoingStreamParameters& param) { | 238 const OutgoingStreamParameters& param) { |
| 239 // The |param| is for forward-compatibility. Not used for now. | 239 // The |param| is for forward-compatibility. Not used for now. |
| 240 return CreateOutgoingDynamicStream(kDefaultPriority); | 240 return CreateOutgoingDynamicStream(kDefaultSpdyPriority); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void QuartcSession::SetDelegate( | 243 void QuartcSession::SetDelegate( |
| 244 QuartcSessionInterface::Delegate* session_delegate) { | 244 QuartcSessionInterface::Delegate* session_delegate) { |
| 245 if (session_delegate_) { | 245 if (session_delegate_) { |
| 246 LOG(WARNING) << "The delegate for the session has already been set."; | 246 LOG(WARNING) << "The delegate for the session has already been set."; |
| 247 } | 247 } |
| 248 session_delegate_ = session_delegate; | 248 session_delegate_ = session_delegate; |
| 249 DCHECK(session_delegate_); | 249 DCHECK(session_delegate_); |
| 250 } | 250 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 276 QuicCryptoClientConfig* client_config) { | 276 QuicCryptoClientConfig* client_config) { |
| 277 quic_crypto_client_config_.reset(client_config); | 277 quic_crypto_client_config_.reset(client_config); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void QuartcSession::SetServerCryptoConfig( | 280 void QuartcSession::SetServerCryptoConfig( |
| 281 QuicCryptoServerConfig* server_config) { | 281 QuicCryptoServerConfig* server_config) { |
| 282 quic_crypto_server_config_.reset(server_config); | 282 quic_crypto_server_config_.reset(server_config); |
| 283 } | 283 } |
| 284 | 284 |
| 285 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { | 285 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { |
| 286 return ActivateDataStream(CreateDataStream(id, kDefaultPriority)); | 286 return ActivateDataStream(CreateDataStream(id, kDefaultSpdyPriority)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 std::unique_ptr<QuicStream> QuartcSession::CreateStream(QuicStreamId id) { | 289 std::unique_ptr<QuicStream> QuartcSession::CreateStream(QuicStreamId id) { |
| 290 return CreateDataStream(id, kDefaultPriority); | 290 return CreateDataStream(id, kDefaultSpdyPriority); |
| 291 } | 291 } |
| 292 | 292 |
| 293 std::unique_ptr<QuartcStream> QuartcSession::CreateDataStream( | 293 std::unique_ptr<QuartcStream> QuartcSession::CreateDataStream( |
| 294 QuicStreamId id, | 294 QuicStreamId id, |
| 295 SpdyPriority priority) { | 295 SpdyPriority priority) { |
| 296 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { | 296 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { |
| 297 // Encryption not active so no stream created | 297 // Encryption not active so no stream created |
| 298 return nullptr; | 298 return nullptr; |
| 299 } | 299 } |
| 300 auto stream = QuicMakeUnique<QuartcStream>(id, this); | 300 auto stream = QuicMakeUnique<QuartcStream>(id, this); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 323 // Transfer ownership of the data stream to the session via ActivateStream(). | 323 // Transfer ownership of the data stream to the session via ActivateStream(). |
| 324 QuartcStream* raw = stream.release(); | 324 QuartcStream* raw = stream.release(); |
| 325 if (raw) { | 325 if (raw) { |
| 326 // Make QuicSession take ownership of the stream. | 326 // Make QuicSession take ownership of the stream. |
| 327 ActivateStream(std::unique_ptr<QuicStream>(raw)); | 327 ActivateStream(std::unique_ptr<QuicStream>(raw)); |
| 328 } | 328 } |
| 329 return raw; | 329 return raw; |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace net | 332 } // namespace net |
| OLD | NEW |