Index: webrtc/p2p/quic/quicsession.h |
diff --git a/webrtc/p2p/quic/quicsession.h b/webrtc/p2p/quic/quicsession.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..689d43709e1fcd12f71c0fde6b19b168274662b7 |
--- /dev/null |
+++ b/webrtc/p2p/quic/quicsession.h |
@@ -0,0 +1,94 @@ |
+/* |
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#ifndef WEBRTC_P2P_QUIC_QUICSESSION_H_ |
+#define WEBRTC_P2P_QUIC_QUICSESSION_H_ |
+ |
+#include <string> |
+ |
+#include "net/quic/quic_crypto_client_stream.h" |
+#include "net/quic/quic_crypto_server_stream.h" |
+#include "net/quic/quic_crypto_stream.h" |
+#include "net/quic/quic_session.h" |
+#include "webrtc/base/constructormagic.h" |
+#include "webrtc/base/sigslot.h" |
+#include "webrtc/base/sslidentity.h" |
+#include "webrtc/p2p/quic/reliablequicstream.h" |
+ |
+namespace cricket { |
+ |
+// This class provides a QUIC session over peer-to-peer transport that |
+// negotiates the crypto handshake (using QuicCryptoHandshake) and provides |
+// reading/writing of data using QUIC packets. |
+class QuicSession : public net::QuicSession, public sigslot::has_slots<> { |
+ public: |
+ QuicSession(scoped_ptr<net::QuicConnection> connection, |
+ const net::QuicConfig& config); |
+ ~QuicSession() override; |
+ |
+ // Initiates client crypto handshake by sending client hello. |
+ void StartClientHandshake(net::QuicCryptoClientStream* crypto_stream); |
+ |
+ // Responds to a client who has inititated the crypto handshake. |
+ void StartServerHandshake(net::QuicCryptoServerStream* crypto_stream); |
+ |
+ // QuicSession overrides. |
+ net::QuicCryptoStream* GetCryptoStream() override { |
+ return crypto_stream_.get(); |
+ } |
+ // TODO(mikescarlett): Verify whether outgoing streams should be owned by |
+ // caller. It appears these are deleted in the net::QuicSession destructor, |
+ // but Chromium's documentation says this should not happen. |
+ ReliableQuicStream* CreateOutgoingDynamicStream( |
+ net::SpdyPriority priority) override; |
+ |
+ // QuicSession optional overrides. |
+ void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override; |
+ |
+ // QuicConnectionVisitorInterface overrides. |
+ void OnConnectionClosed(net::QuicErrorCode error, bool from_peer) override; |
+ |
+ // Exports keying material for SRTP. |
+ bool ExportKeyingMaterial(base::StringPiece label, |
+ base::StringPiece context, |
+ size_t result_len, |
+ string* result); |
+ |
+ // Decrypts an incoming QUIC packet to a data stream. |
+ bool OnReadPacket(const char* data, size_t data_len); |
+ |
+ // Called when peers have established forward-secure encryption |
+ sigslot::signal0<> SignalHandshakeComplete; |
+ // Called when connection closes locally, or remotely by peer. |
+ sigslot::signal2<net::QuicErrorCode, bool> SignalConnectionClosed; |
+ // Called when an incoming QUIC stream is created so we can process data |
+ // from it by registering a listener to |
+ // ReliableQuicStream::SignalDataReceived. |
+ sigslot::signal1<ReliableQuicStream*> SignalIncomingStream; |
+ |
+ protected: |
+ // Sets the QUIC crypto stream and takes ownership of it. |
+ void SetCryptoStream(net::QuicCryptoStream* crypto_stream); |
+ |
+ // QuicSession override. |
+ ReliableQuicStream* CreateIncomingDynamicStream( |
+ net::QuicStreamId id) override; |
+ |
+ virtual ReliableQuicStream* CreateDataStream(net::QuicStreamId id); |
+ |
+ private: |
+ scoped_ptr<net::QuicCryptoStream> crypto_stream_; |
+ |
+ RTC_DISALLOW_COPY_AND_ASSIGN(QuicSession); |
+}; |
+ |
+} // namespace cricket |
+ |
+#endif // WEBRTC_P2P_QUIC_QUICSESSION_H_ |