Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: net/quic/quartc/quartc_session.h

Issue 2324833004: Define Stable API for WebRTC/Quartc (Closed)
Patch Set: Add virtual destructors required by WebRTC compiler. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_QUIC_QUARTC_QUARTC_SESSION_H_
6 #define NET_QUIC_QUARTC_QUARTC_SESSION_H_
7
8 #include "net/quic/core/quic_crypto_client_stream.h"
9 #include "net/quic/core/quic_crypto_server_stream.h"
10 #include "net/quic/core/quic_crypto_stream.h"
11 #include "net/quic/core/quic_session.h"
12 #include "net/quic/quartc/quartc_connection_helper.h"
13 #include "net/quic/quartc/quartc_session_interface.h"
14 #include "net/quic/quartc/quartc_stream.h"
15
16 namespace net {
17
18 // This class is used for creating the QuicCryptoServerStream.
Ryan Hamilton 2016/10/10 19:48:30 Is this used for "creating" the crypto stream or i
zhihuang1 2016/10/13 06:22:40 Should be "used by"
19 class NET_EXPORT_PRIVATE QuartcCryptoServerStreamHelper
20 : public QuicCryptoServerStream::Helper {
21 public:
22 QuicConnectionId GenerateConnectionIdForReject(
23 QuicConnectionId connection_id) const override;
24
25 bool CanAcceptClientHello(const CryptoHandshakeMessage& message,
26 const IPEndPoint& self_address,
27 std::string* error_details) const override;
28 };
29
30 // This class is used to solve the issue that the interface and the base class
31 // have the same function signature.
32 class NET_EXPORT_PRIVATE QuartcSessionTransportDelegate
33 : public QuartcSessionInterface::Transport::Delegate {
34 public:
35 void OnCanWrite() override;
36
37 protected:
38 virtual void OnQuartcCanWrite() = 0;
39 };
40
41 class NET_EXPORT_PRIVATE QuartcSession
42 : public QuicSession,
43 public QuartcSessionInterface,
44 public QuartcSessionTransportDelegate,
45 public QuicCryptoClientStream::ProofHandler {
46 public:
47 QuartcSession(std::unique_ptr<QuicConnection> connection,
48 const QuicConfig& config,
49 const std::string& remote_fingerprint_value,
50 Perspective perspective,
51 QuartcSessionInterface::Transport* session_transport);
52 ~QuartcSession() override;
53
54 // QuicSession overrides.
55 QuicCryptoStream* GetCryptoStream() override;
56
57 QuartcStream* CreateOutgoingDynamicStream(SpdyPriority priority) override;
58
59 void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override;
60
61 void CloseStream(QuicStreamId stream_id) override;
62
63 // QuicConnectionVisitorInterface overrides.
64 void OnConnectionClosed(QuicErrorCode error,
65 const std::string& error_details,
66 ConnectionCloseSource source) override;
67
68 // QuartcSessionInterface overrides
69 void StartCryptoHandshake() override;
70
71 bool ExportKeyingMaterial(const std::string& label,
72 const uint8_t* context,
73 size_t context_len,
74 bool used_context,
75 uint8_t* result,
76 size_t result_len) override;
77
78 QuartcStreamInterface* CreateOutgoingStream(
79 const OutgoingStreamParameters& param) override;
80
81 void SetDelegate(QuartcSessionInterface::Delegate* session_delegate) override;
82
83 // QuartcSessionTransportDelegate overrides.
84 void OnQuartcCanWrite() override;
85
86 // QuartcSessionInterface::Transport::Delegate overrides.
87 // Decrypts an incoming QUIC packet to a data stream.
88 bool OnReceived(const char* data, size_t data_len) override;
89
90 // ProofHandler overrides.
91 void OnProofValid(const QuicCryptoClientConfig::CachedState& cached) override;
92
93 // Called by the client crypto handshake when proof verification details
94 // become available, either because proof verification is complete, or when
95 // cached details are used.
96 void OnProofVerifyDetailsAvailable(
97 const ProofVerifyDetails& verify_details) override;
98
99 // Override the default crypto configuration.
100 // The session will take the ownership of the configurations.
101 void SetClientCryptoConfig(QuicCryptoClientConfig* client_config);
102
103 void SetServerCryptoConfig(QuicCryptoServerConfig* server_config);
104
105 protected:
106 // QuicSession override.
107 ReliableQuicStream* CreateIncomingDynamicStream(QuicStreamId id) override;
108
109 QuartcStream* CreateDataStream(QuicStreamId id, SpdyPriority priority);
110
111 private:
112 // For crypto handshake.
113 std::unique_ptr<QuicCryptoStream> crypto_stream_;
114 // For recording packet receipt time
115 QuicClock clock_;
116 const std::string remote_fingerprint_value_;
117 Perspective perspective_;
118 // Take ownership of the QuicConnection.
119 std::unique_ptr<QuicConnection> connection_;
120 // Not owned by QuartcSession.
121 QuartcSessionInterface::Transport* session_transport_ = nullptr;
122 // Not owned by QuartcSession.
123 QuartcSessionInterface::Delegate* session_delegate_ = nullptr;
124 QuartcConnectionHelper helper_;
125 // Used by QUIC crypto server stream to track most recently compressed certs.
126 std::unique_ptr<QuicCompressedCertsCache> quic_compressed_certs_cache_;
127 // This helper is needed when create QuicCryptoServerStream.
128 QuartcCryptoServerStreamHelper stream_helper_;
129 // Config for QUIC crypto client stream, used by the client.
130 std::unique_ptr<QuicCryptoClientConfig> quic_crypto_client_config_;
131 // Config for QUIC crypto server stream, used by the server.
132 std::unique_ptr<QuicCryptoServerConfig> quic_crypto_server_config_;
133
134 DISALLOW_COPY_AND_ASSIGN(QuartcSession);
135 };
136
137 } // namespace net
138
139 #endif // NET_QUIC_QUARTC_QUARTC_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698