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 #ifndef WEBRTC_P2P_BASE_QUICSESSION_H_ | |
12 #define WEBRTC_P2P_BASE_QUICSESSION_H_ | |
13 | |
14 #include <string> | |
15 | |
16 #include "net/quic/quic_crypto_stream.h" | |
17 #include "net/quic/quic_crypto_client_stream.h" | |
18 #include "net/quic/quic_crypto_server_stream.h" | |
19 #include "net/quic/quic_session.h" | |
20 | |
21 #include "webrtc/base/constructormagic.h" | |
22 #include "webrtc/base/sslidentity.h" | |
23 #include "webrtc/p2p/base/reliablequicstream.h" | |
24 | |
25 #include "webrtc/base/sigslot.h" | |
26 | |
27 namespace cricket { | |
28 | |
29 // This class provides a QUIC session over peer-to-peer transport that | |
30 // negotiates the crypto handshake (using QuicCryptoHandshake) and provides | |
31 // reading/writing of data using QUIC packets. | |
32 class QuicSession : public net::QuicSession, public sigslot::has_slots<> { | |
33 public: | |
34 QuicSession(const net::QuicConfig& config, | |
35 scoped_ptr<net::QuicConnection> connection); | |
36 ~QuicSession() override; | |
37 | |
38 // Inititates client crypto handshake by sending client hello. | |
39 void StartClientHandshake(net::QuicCryptoClientStream* crypto_stream); | |
40 | |
41 // Responds to a client who has inititated the crypto handshake. | |
42 void StartServerHandshake(net::QuicCryptoServerStream* crypto_stream); | |
43 | |
44 // QuicSession overrides. | |
45 net::QuicCryptoStream* GetCryptoStream() override { | |
46 return crypto_stream_.get(); | |
47 } | |
48 ReliableQuicStream* CreateOutgoingDynamicStream( | |
49 net::SpdyPriority priority) override; | |
50 | |
51 // QuicSession optional overrides. | |
52 void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override; | |
53 | |
54 // QuicConnectionVisitorInterface overrides. | |
55 void OnConnectionClosed(net::QuicErrorCode error, bool from_peer) override; | |
56 | |
57 // Exports keying material for SRTP. | |
58 bool ExportKeyingMaterial(base::StringPiece label, | |
59 base::StringPiece context, | |
60 size_t result_len, | |
61 string* result); | |
62 | |
63 // Decrypts an incoming QUIC packet to a data stream. | |
64 bool OnReadPacket(const char* data, size_t data_len); | |
65 | |
66 // Called when peers have established forward-secure encryption | |
67 sigslot::signal0<> SignalHandshakeComplete; | |
68 // Called when connection closes locally, or remotely by peer | |
69 sigslot::signal2<net::QuicErrorCode, bool> SignalConnectionClosed; | |
70 // Called when an incoming QUIC stream is created so we can process data | |
71 // from it by registering a listener to ReliableQuicStream::SignalDataReceived | |
72 sigslot::signal1<ReliableQuicStream*> SignalIncomingStream; | |
73 | |
74 protected: | |
75 // Sets the QUIC crypto stream and takes ownership of it. | |
76 void SetCryptoStream(net::QuicCryptoStream* crypto_stream); | |
77 | |
78 // QuicSession override | |
79 ReliableQuicStream* CreateIncomingDynamicStream( | |
80 net::QuicStreamId id) override; | |
81 | |
82 ReliableQuicStream* CreateDataStream(net::QuicStreamId id); | |
pthatcher1
2016/01/30 03:01:52
Why is this protected but not virtual?
mikescarlett
2016/02/03 17:41:01
I agree this should be virtual for more flexibilit
| |
83 | |
84 private: | |
85 scoped_ptr<net::QuicCryptoStream> crypto_stream_; | |
86 | |
87 RTC_DISALLOW_COPY_AND_ASSIGN(QuicSession); | |
88 }; | |
89 | |
90 } // namespace cricket | |
91 | |
92 #endif // WEBRTC_P2P_BASE_QUICSESSION_H_ | |
OLD | NEW |