OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include <string> | |
12 #include <utility> | |
13 | |
14 #include "webrtc/base/messagehandler.h" | |
15 #include "webrtc/base/messagequeue.h" | |
16 #include "webrtc/p2p/base/quicsession.h" | |
17 #include "webrtc/base/logging.h" | |
18 | |
19 namespace cricket { | |
20 | |
21 QuicSession::QuicSession(const net::QuicConfig& config, | |
22 scoped_ptr<net::QuicConnection> connection) | |
23 : net::QuicSession(connection.release(), config) {} | |
24 | |
25 QuicSession::~QuicSession() {} | |
26 | |
27 void QuicSession::StartClientHandshake( | |
28 net::QuicCryptoClientStream* crypto_stream) { | |
29 SetCryptoStream(crypto_stream); | |
30 net::QuicSession::Initialize(); | |
31 crypto_stream->CryptoConnect(); | |
32 } | |
33 | |
34 void QuicSession::StartServerHandshake( | |
35 net::QuicCryptoServerStream* crypto_stream) { | |
36 SetCryptoStream(crypto_stream); | |
37 net::QuicSession::Initialize(); | |
38 } | |
39 | |
40 void QuicSession::SetCryptoStream(net::QuicCryptoStream* crypto_stream) { | |
41 crypto_stream_.reset(crypto_stream); | |
42 } | |
43 | |
44 bool QuicSession::ExportKeyingMaterial(base::StringPiece label, | |
45 base::StringPiece context, | |
46 size_t result_len, | |
47 string* result) { | |
48 return GetCryptoStream()->ExportKeyingMaterial(label, context, result_len, | |
49 result); | |
50 } | |
51 | |
52 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { | |
53 net::QuicSession::OnCryptoHandshakeEvent(event); | |
54 if (event == HANDSHAKE_CONFIRMED) { | |
55 VLOG(1) << "QuicSession handshake complete"; | |
pthatcher1
2016/01/30 03:01:52
VLOG(1)?
We usually use something like LOG(INFO).
mikescarlett
2016/02/03 17:41:01
Fixed.
| |
56 DCHECK(IsEncryptionEstablished()); | |
57 DCHECK(IsCryptoHandshakeConfirmed()); | |
58 | |
59 SignalHandshakeComplete(); | |
60 } | |
61 } | |
62 | |
63 ReliableQuicStream* QuicSession::CreateIncomingDynamicStream( | |
64 net::QuicStreamId id) { | |
65 ReliableQuicStream* stream = CreateDataStream(id); | |
66 SignalIncomingStream(stream); | |
pthatcher1
2016/01/30 03:01:52
Should this also be in an "if (stream)"?
mikescarlett
2016/02/03 17:41:01
Yes it should.
| |
67 return stream; | |
68 } | |
69 | |
70 ReliableQuicStream* QuicSession::CreateOutgoingDynamicStream( | |
71 net::SpdyPriority priority) { | |
72 ReliableQuicStream* stream = CreateDataStream(GetNextOutgoingStreamId()); | |
73 if (stream) { | |
74 ActivateStream(stream); | |
75 } | |
76 return stream; | |
77 } | |
78 | |
79 ReliableQuicStream* QuicSession::CreateDataStream(net::QuicStreamId id) { | |
80 if (!GetCryptoStream()->encryption_established()) { | |
81 // Encryption not active so no stream created | |
82 return nullptr; | |
83 } | |
84 return new ReliableQuicStream(id, this); | |
85 } | |
86 | |
87 void QuicSession::OnConnectionClosed(net::QuicErrorCode error, bool from_peer) { | |
88 net::QuicSession::OnConnectionClosed(error, from_peer); | |
89 | |
90 SignalConnectionClosed(error, from_peer); | |
91 } | |
92 | |
93 bool QuicSession::OnReadPacket(const char* data, size_t data_len) { | |
94 net::QuicEncryptedPacket packet(data, data_len); | |
95 connection()->ProcessUdpPacket(connection()->self_address(), | |
96 connection()->peer_address(), packet); | |
97 return true; | |
98 } | |
99 | |
100 } // namespace cricket | |
OLD | NEW |