OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 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_API_QUICTRANSPORT_H_ | |
12 #define WEBRTC_API_QUICTRANSPORT_H_ | |
13 | |
14 #include <string> | |
15 #include <unordered_map> | |
16 #include <unordered_set> | |
17 | |
18 #include "webrtc/api/quicdatachannel.h" | |
19 #include "webrtc/base/bytebuffer.h" | |
20 #include "webrtc/base/scoped_ref_ptr.h" | |
pthatcher1
2016/03/30 20:34:49
If these aren't used in this file, please move the
mikescarlett
2016/04/05 19:58:51
Done.
| |
21 #include "webrtc/base/sigslot.h" | |
22 | |
23 namespace net { | |
24 typedef uint32_t QuicStreamId; | |
25 } // namespace net | |
26 | |
27 namespace cricket { | |
28 class QuicTransportChannel; | |
29 class ReliableQuicStream; | |
30 } // namepsace cricket | |
31 | |
32 namespace webrtc { | |
33 | |
34 // QuicTransport dispatches each ReliableQuicStream initiated by the | |
35 // remote peer to its corresponding QuicDataChannel, and encapsulates a | |
pthatcher1
2016/03/30 20:34:49
Might be more clear as "by reading the data channe
mikescarlett
2016/04/05 19:58:51
Done.
| |
36 // <data channel id, QuicDataChannel*> map. It reads the initial stream frame | |
37 // sent by the remote peer's ReliableQuicStream to obtain the data channel id. | |
38 // If the local peer has no existing QuicDataChannel with the given id, then a | |
39 // new QuicDataChannel is created with the given id and remaining data from the | |
40 // ReliableQuicStream. Otherwise the ReliableQuicStream is dispatched to an | |
41 // existing QuicDataChannel, which reads the remaining data. | |
pthatcher1
2016/03/30 20:34:49
Might be more clear as "if the QuicDataChannel exi
mikescarlett
2016/04/05 19:58:51
Done.
| |
42 // | |
43 // Each time the local peer creates a QuicDataChannel, the local peer should | |
44 // call RegisterDataChannel() to register it to the map of QuicDataChannel ids. | |
45 // The local peer should call UnregisterDataChannel() if the QuicDataChannel | |
46 // should no longer be accessed. | |
47 class QuicTransport : public sigslot::has_slots<> { | |
48 public: | |
49 explicit QuicTransport(cricket::QuicTransportChannel* quic_transport_channel); | |
50 // Adds a QUIC data channel to the map of existing QUIC data channels. | |
51 void RegisterDataChannel(QuicDataChannel* data_channel); | |
52 // Removes a QUIC data channel from the map of QUIC data channels. | |
53 void UnregisterDataChannel(int id); | |
pthatcher1
2016/03/30 20:34:49
I think AddDataChannel and RemoveDataChannel would
mikescarlett
2016/04/05 19:58:51
Done.
| |
54 bool has_data_channel(int id) const { | |
pthatcher1
2016/03/30 20:34:49
HasDataChannel
mikescarlett
2016/04/05 19:58:51
Done.
| |
55 return data_channel_map_.find(id) != data_channel_map_.end(); | |
56 } | |
57 | |
58 private: | |
59 // Called by QuicTransportChannel when a QUIC stream is created for incoming | |
60 // data. | |
61 void OnIncomingStream(cricket::ReliableQuicStream* stream); | |
62 // Called by ReliableQuicStream when the first QUIC stream frame is received | |
63 // for incoming data. | |
64 void OnDataReceived(net::QuicStreamId stream_id, | |
65 const char* data, | |
66 size_t len); | |
67 | |
68 // Map of <data channel id, QuicDataChannel*> values. | |
pthatcher1
2016/03/30 20:34:49
Might be easier to read as "data channel ID => Qui
mikescarlett
2016/04/05 19:58:51
Done.
| |
69 std::unordered_map<int, QuicDataChannel*> data_channel_map_; | |
pthatcher1
2016/03/30 20:34:49
I think a better name would be data_channel_by_id_
mikescarlett
2016/04/05 19:58:51
Done.
| |
70 // Map of <QUIC stream id, ReliableQuicStream*> values. | |
pthatcher1
2016/03/30 20:34:49
Similarly, "QUIC stream ID => ReliableQuicStream"
mikescarlett
2016/04/05 19:58:51
Done.
| |
71 std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*> | |
72 quic_stream_map_; | |
pthatcher1
2016/03/30 20:34:49
quic_stream_by_id_
mikescarlett
2016/04/05 19:58:51
Done.
| |
73 }; | |
74 | |
75 } // namespace webrtc | |
76 | |
77 #endif // WEBRTC_API_QUICTRANSPORT_H_ | |
OLD | NEW |