| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 253   bool success = crypto_stream_->ExportKeyingMaterial(label, quic_context, | 253   bool success = crypto_stream_->ExportKeyingMaterial(label, quic_context, | 
| 254                                                       result_len, &quic_result); | 254                                                       result_len, &quic_result); | 
| 255   quic_result.copy(reinterpret_cast<char*>(result), result_len); | 255   quic_result.copy(reinterpret_cast<char*>(result), result_len); | 
| 256   DCHECK(quic_result.length() == result_len); | 256   DCHECK(quic_result.length() == result_len); | 
| 257   return success; | 257   return success; | 
| 258 } | 258 } | 
| 259 | 259 | 
| 260 QuartcStreamInterface* QuartcSession::CreateOutgoingStream( | 260 QuartcStreamInterface* QuartcSession::CreateOutgoingStream( | 
| 261     const OutgoingStreamParameters& param) { | 261     const OutgoingStreamParameters& param) { | 
| 262   // The |param| is for forward-compatibility. Not used for now. | 262   // The |param| is for forward-compatibility. Not used for now. | 
| 263   return CreateOutgoingDynamicStream(kDefaultPriority); | 263   return CreateOutgoingDynamicStream(kDefaultSpdyPriority); | 
| 264 } | 264 } | 
| 265 | 265 | 
| 266 void QuartcSession::SetDelegate( | 266 void QuartcSession::SetDelegate( | 
| 267     QuartcSessionInterface::Delegate* session_delegate) { | 267     QuartcSessionInterface::Delegate* session_delegate) { | 
| 268   if (session_delegate_) { | 268   if (session_delegate_) { | 
| 269     LOG(WARNING) << "The delegate for the session has already been set."; | 269     LOG(WARNING) << "The delegate for the session has already been set."; | 
| 270   } | 270   } | 
| 271   session_delegate_ = session_delegate; | 271   session_delegate_ = session_delegate; | 
| 272   DCHECK(session_delegate_); | 272   DCHECK(session_delegate_); | 
| 273 } | 273 } | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 299     QuicCryptoClientConfig* client_config) { | 299     QuicCryptoClientConfig* client_config) { | 
| 300   quic_crypto_client_config_.reset(client_config); | 300   quic_crypto_client_config_.reset(client_config); | 
| 301 } | 301 } | 
| 302 | 302 | 
| 303 void QuartcSession::SetServerCryptoConfig( | 303 void QuartcSession::SetServerCryptoConfig( | 
| 304     QuicCryptoServerConfig* server_config) { | 304     QuicCryptoServerConfig* server_config) { | 
| 305   quic_crypto_server_config_.reset(server_config); | 305   quic_crypto_server_config_.reset(server_config); | 
| 306 } | 306 } | 
| 307 | 307 | 
| 308 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { | 308 QuicStream* QuartcSession::CreateIncomingDynamicStream(QuicStreamId id) { | 
| 309   return ActivateDataStream(CreateDataStream(id, kDefaultPriority)); | 309   return ActivateDataStream(CreateDataStream(id, kDefaultSpdyPriority)); | 
| 310 } | 310 } | 
| 311 | 311 | 
| 312 std::unique_ptr<QuartcStream> QuartcSession::CreateDataStream( | 312 std::unique_ptr<QuartcStream> QuartcSession::CreateDataStream( | 
| 313     QuicStreamId id, | 313     QuicStreamId id, | 
| 314     SpdyPriority priority) { | 314     SpdyPriority priority) { | 
| 315   if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { | 315   if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { | 
| 316     // Encryption not active so no stream created | 316     // Encryption not active so no stream created | 
| 317     return nullptr; | 317     return nullptr; | 
| 318   } | 318   } | 
| 319   auto stream = QuicMakeUnique<QuartcStream>(id, this); | 319   auto stream = QuicMakeUnique<QuartcStream>(id, this); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 337   // Transfer ownership of the data stream to the session via ActivateStream(). | 337   // Transfer ownership of the data stream to the session via ActivateStream(). | 
| 338   QuartcStream* raw = stream.release(); | 338   QuartcStream* raw = stream.release(); | 
| 339   if (raw) { | 339   if (raw) { | 
| 340     // Make QuicSession take ownership of the stream. | 340     // Make QuicSession take ownership of the stream. | 
| 341     ActivateStream(std::unique_ptr<QuicStream>(raw)); | 341     ActivateStream(std::unique_ptr<QuicStream>(raw)); | 
| 342   } | 342   } | 
| 343   return raw; | 343   return raw; | 
| 344 } | 344 } | 
| 345 | 345 | 
| 346 }  // namespace net | 346 }  // namespace net | 
| OLD | NEW | 
|---|