| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 net::QuicSession::Initialize(); | 39 net::QuicSession::Initialize(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void QuicSession::SetCryptoStream(net::QuicCryptoStream* crypto_stream) { | 42 void QuicSession::SetCryptoStream(net::QuicCryptoStream* crypto_stream) { |
| 43 crypto_stream_.reset(crypto_stream); | 43 crypto_stream_.reset(crypto_stream); |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool QuicSession::ExportKeyingMaterial(base::StringPiece label, | 46 bool QuicSession::ExportKeyingMaterial(base::StringPiece label, |
| 47 base::StringPiece context, | 47 base::StringPiece context, |
| 48 size_t result_len, | 48 size_t result_len, |
| 49 string* result) { | 49 std::string* result) { |
| 50 return crypto_stream_->ExportKeyingMaterial(label, context, result_len, | 50 return crypto_stream_->ExportKeyingMaterial(label, context, result_len, |
| 51 result); | 51 result); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { | 54 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { |
| 55 net::QuicSession::OnCryptoHandshakeEvent(event); | 55 net::QuicSession::OnCryptoHandshakeEvent(event); |
| 56 if (event == HANDSHAKE_CONFIRMED) { | 56 if (event == HANDSHAKE_CONFIRMED) { |
| 57 LOG(LS_INFO) << "QuicSession handshake complete"; | 57 LOG(LS_INFO) << "QuicSession handshake complete"; |
| 58 RTC_DCHECK(IsEncryptionEstablished()); | 58 RTC_DCHECK(IsEncryptionEstablished()); |
| 59 RTC_DCHECK(IsCryptoHandshakeConfirmed()); | 59 RTC_DCHECK(IsCryptoHandshakeConfirmed()); |
| 60 | 60 |
| 61 SignalHandshakeComplete(); | 61 SignalHandshakeComplete(); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 ReliableQuicStream* QuicSession::CreateIncomingDynamicStream( | 65 ReliableQuicStream* QuicSession::CreateIncomingDynamicStream( |
| 66 net::QuicStreamId id) { | 66 net::QuicStreamId id) { |
| 67 ReliableQuicStream* stream = CreateDataStream(id); | 67 ReliableQuicStream* stream = CreateDataStream(id); |
| 68 if (stream) { | 68 if (stream) { |
| 69 SignalIncomingStream(stream); | 69 SignalIncomingStream(stream); |
| 70 } | 70 } |
| 71 return stream; | 71 return stream; |
| 72 } | 72 } |
| 73 | 73 |
| 74 ReliableQuicStream* QuicSession::CreateOutgoingDynamicStream( | 74 ReliableQuicStream* QuicSession::CreateOutgoingDynamicStream( |
| 75 net::SpdyPriority priority) { | 75 net::SpdyPriority priority) { |
| 76 ReliableQuicStream* stream = CreateDataStream(GetNextOutgoingStreamId()); | 76 return CreateDataStream(GetNextOutgoingStreamId()); |
| 77 if (stream) { | |
| 78 ActivateStream(stream); // QuicSession owns the stream. | |
| 79 } | |
| 80 return stream; | |
| 81 } | 77 } |
| 82 | 78 |
| 83 ReliableQuicStream* QuicSession::CreateDataStream(net::QuicStreamId id) { | 79 ReliableQuicStream* QuicSession::CreateDataStream(net::QuicStreamId id) { |
| 84 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { | 80 if (crypto_stream_ == nullptr || !crypto_stream_->encryption_established()) { |
| 85 // Encryption not active so no stream created | 81 // Encryption not active so no stream created |
| 86 return nullptr; | 82 return nullptr; |
| 87 } | 83 } |
| 88 return new ReliableQuicStream(id, this); | 84 ReliableQuicStream* stream = new ReliableQuicStream(id, this); |
| 85 if (stream) { |
| 86 ActivateStream(stream); // QuicSession owns the stream. |
| 87 } |
| 88 return stream; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void QuicSession::OnConnectionClosed(net::QuicErrorCode error, | 91 void QuicSession::OnConnectionClosed(net::QuicErrorCode error, |
| 92 const std::string& error_details, |
| 92 net::ConnectionCloseSource source) { | 93 net::ConnectionCloseSource source) { |
| 93 net::QuicSession::OnConnectionClosed(error, source); | 94 net::QuicSession::OnConnectionClosed(error, error_details, source); |
| 94 SignalConnectionClosed(error, | 95 SignalConnectionClosed(error, |
| 95 source == net::ConnectionCloseSource::FROM_PEER); | 96 source == net::ConnectionCloseSource::FROM_PEER); |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool QuicSession::OnReadPacket(const char* data, size_t data_len) { | 99 bool QuicSession::OnReadPacket(const char* data, size_t data_len) { |
| 99 net::QuicEncryptedPacket packet(data, data_len); | 100 net::QuicReceivedPacket packet(data, data_len, clock_.Now()); |
| 100 connection()->ProcessUdpPacket(connection()->self_address(), | 101 ProcessUdpPacket(connection()->self_address(), connection()->peer_address(), |
| 101 connection()->peer_address(), packet); | 102 packet); |
| 102 return true; | 103 return true; |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace cricket | 106 } // namespace cricket |
| OLD | NEW |