OLD | NEW |
---|---|
(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_INTERFACE_H_ | |
6 #define NET_QUIC_QUARTC_QUARTC_SESSION_INTERFACE_H_ | |
7 | |
8 #include "net/quic/quartc/quartc_stream_interface.h" | |
9 | |
10 namespace net { | |
11 | |
12 // This interface defines a session over peer-to-peer transport that | |
13 // negotiates the crypto handshake (using QuicCryptoHandshake) and provides | |
14 // reading/writing of data using QUIC. | |
pthatcher2
2016/10/05 22:12:07
The comment does need "This interface defines a ..
zhihuang1
2016/10/13 06:22:40
Done.
| |
15 class QuartcSessionInterface { | |
16 public: | |
17 virtual ~QuartcSessionInterface() {} | |
18 | |
19 virtual void StartCryptoHandshake() = 0; | |
20 | |
21 // Only needed when using SRTP with QuicTransport | |
22 // Key Exporter interface from RFC 5705 | |
23 // Arguments are: | |
24 // label -- the exporter label. | |
25 // part of the RFC defining each exporter usage (IN) | |
26 // context/context_len -- a context to bind to for this connection; | |
27 // optional, can be NULL, 0 (IN) | |
28 // use_context -- whether to use the context value | |
29 // (needed to distinguish no context from | |
30 // zero-length ones). | |
31 // result -- where to put the computed value | |
32 // result_len -- the length of the computed value | |
33 virtual bool ExportKeyingMaterial(const std::string& label, | |
34 const uint8_t* context, | |
35 size_t context_len, | |
36 bool used_context, | |
37 uint8_t* result, | |
38 size_t result_len) = 0; | |
39 | |
40 // For forward-compatibility. More parameters could be added through the | |
41 // struct without changing the API. | |
42 struct OutgoingStreamParameters {}; | |
43 | |
44 virtual QuartcStreamInterface* CreateOutgoingStream( | |
45 const OutgoingStreamParameters& params) = 0; | |
46 | |
47 // Implemented by WebRTC (ICE) code. Used by QUIC for sending and receiving | |
48 // (hopefully UDP) packets. | |
pthatcher2
2016/10/05 22:12:07
This would be more clear as "Send and receive pack
zhihuang1
2016/10/13 06:22:40
Done.
| |
49 class Transport { | |
50 public: | |
51 virtual ~Transport() {} | |
52 | |
53 // Called by the QuartcPacketWriter to check if the underneath transport | |
54 // writable. | |
pthatcher2
2016/10/05 22:12:07
"transport writable" => "transport is writable"
A
zhihuang1
2016/10/13 06:22:40
Done.
| |
55 virtual bool CanWrite() = 0; | |
56 | |
57 // Called by the QuartcPacketWriter when writing packets to the network. | |
58 virtual int Write(const char* buffer, size_t buf_len) = 0; | |
pthatcher2
2016/10/05 22:12:06
We should comment on what the return value is.
zhihuang1
2016/10/13 06:22:40
Done.
| |
59 | |
60 // Implemented by QUIC code. Used to receive notifications from the | |
61 // WebRTC side through the Transport. | |
pthatcher2
2016/10/05 22:12:07
Would be more clear as "Callbacks called by the Pa
zhihuang1
2016/10/13 06:22:40
I found that moving the callbacks of PacketTranspo
| |
62 class Delegate { | |
63 public: | |
64 virtual ~Delegate() {} | |
65 | |
66 // Called when the WebRTC network layer becomes writable. | |
pthatcher2
2016/10/05 22:12:07
This would be more clear as "Called when CanWrite(
zhihuang1
2016/10/13 06:22:40
Done.
| |
67 virtual void OnCanWrite() = 0; | |
68 | |
69 // Called when the WebRTC network received data. The QUIC side will be | |
70 // responsible for further processing such as decryption. | |
pthatcher2
2016/10/05 22:12:07
I think this would be more clear as just "Called w
zhihuang1
2016/10/13 06:22:40
Done.
| |
71 virtual bool OnReceived(const char* data, size_t data_len) = 0; | |
72 }; | |
73 | |
74 // The |delegate| is not owned by Transport. This method should only be | |
75 // called once. | |
76 virtual void SetDelegate(Delegate* delegate) = 0; | |
77 }; | |
78 | |
79 // Implemented by WebRTC code. Used by the WebRTC to receive notifications | |
80 // from QUIC side. | |
pthatcher2
2016/10/05 22:12:07
"Callbacks called by the QuartcSession to notify t
zhihuang1
2016/10/13 06:22:40
Done.
| |
81 class Delegate { | |
82 public: | |
83 virtual ~Delegate() {} | |
84 | |
85 // Called when the crypto handshake complete. The WebRTC side will change | |
pthatcher2
2016/10/05 22:12:07
"handshake complete" => "handshake is complete"
| |
86 // the QUIC states based on this. | |
pthatcher2
2016/10/05 22:12:07
No need to reference WebRTC here.
zhihuang1
2016/10/13 06:22:40
Done.
| |
87 virtual void OnCryptoHandshakeComplete() = 0; | |
88 | |
89 // Called when the received the data from a incoming stream. | |
pthatcher2
2016/10/05 22:12:07
More clear would be "Called when a new stream is r
| |
90 virtual void OnIncomingStream(QuartcStreamInterface* stream) = 0; | |
91 | |
92 // TODO(zhihuang) Create mapping from integer error code to WebRTC error | |
93 // code. | |
94 virtual void OnConnectionClosed(int error_code, bool from_remote) = 0; | |
pthatcher2
2016/10/05 22:12:06
Needs something like "Called when the connection i
| |
95 | |
96 // TODO(zhihuang): Add proof verification. | |
97 }; | |
98 | |
99 // The |delegate| is not owned by QuartcSession. This method should only be | |
100 // called once. | |
pthatcher2
2016/10/05 22:12:07
Why only once?
zhihuang1
2016/10/13 06:22:40
I feel that the delegate implies a kind of 1:1 rel
| |
101 virtual void SetDelegate(Delegate* delegate) = 0; | |
102 }; | |
103 | |
104 } // namespace net | |
105 | |
106 #endif // NET_QUIC_QUARTC_QUARTC_SESSION_INTERFACE_H_ | |
OLD | NEW |