OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_ | |
6 #define REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_ | |
7 | |
8 #include <map> | |
9 #include <memory> | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/callback.h" | |
14 | |
15 namespace remoting { | |
16 namespace protocol { | |
17 | |
18 class DataChannelHandler; | |
19 class MessagePipe; | |
20 | |
21 // DataChannelManager helps to manage optional data channels. Each | |
22 // DataChannelHandler implementation register a factory function to create an | |
joedow
2017/05/30 16:24:18
s/register/registers
Hzj_jie
2017/05/31 00:11:53
Done.
Also the comment does not reflect the lates
| |
23 // instance of itself to handle data from a named data channel. Lifetime of all | |
24 // DataChannelHandler instances are mananged by DataChannelManager instance. | |
joedow
2017/05/30 16:24:18
s/mananged/managed
Hzj_jie
2017/05/31 00:11:52
Done.
| |
25 // Besides releasing when session closing, clients can also actively close the | |
26 // channel by calling DataChannelHandler::Close() function. | |
joedow
2017/05/30 16:24:18
re-write lines 25/26 -> All handlers are closed wh
Hzj_jie
2017/05/31 00:11:53
Done.
| |
27 class DataChannelManager final { | |
28 public: | |
29 using HandlerConstructor = base::Callback<void( | |
joedow
2017/05/30 16:24:18
maybe rename HandlerConstructor to DataChannelHand
Hzj_jie
2017/05/31 00:11:53
Term "DataChannel" seems a little bit redundant, I
| |
30 const std::string& name, | |
31 std::unique_ptr<MessagePipe> pipe)>; | |
32 | |
33 DataChannelManager(); | |
34 ~DataChannelManager(); | |
35 | |
36 // Registers a factory function to create a DataChannelHandler to handle a new | |
37 // incoming data channel with a name matching |regex|. This function fails and | |
38 // returns false when |regex| or |constructor| are empty. | |
joedow
2017/05/30 16:24:18
fix the last sentence:
Returns true if the registr
Hzj_jie
2017/05/31 00:11:53
Same as DataChannelHandler::Send(), I still prefer
| |
39 bool RegisterHandlerFactory(const std::string& regex, | |
joedow
2017/05/30 16:24:18
A regex isn't needed is it? Data channels have a
Hzj_jie
2017/05/31 00:11:52
I do not think there is any restriction of the nam
joedow
2017/06/01 17:25:26
Can you think of a scenario where a regex is requi
Hzj_jie
2017/06/01 19:32:08
By using regex, you can still use "channel-name" w
| |
40 HandlerConstructor constructor); | |
41 | |
42 // Creates a DataChannelHandler to handle the new incoming data channel. This | |
43 // function fails and returns false if no registered factory function matches | |
44 // |name|. | |
joedow
2017/05/30 16:24:18
The last sentence is a bit awkward. It is totally
Hzj_jie
2017/05/31 00:11:52
Done.
| |
45 bool OnIncomingDataChannel(const std::string& name, | |
46 std::unique_ptr<MessagePipe> pipe); | |
47 | |
48 private: | |
49 std::vector<std::pair<std::string, HandlerConstructor>> constructors_; | |
50 }; | |
51 | |
52 } // namespace protocol | |
53 } // namespace remoting | |
54 | |
55 #endif // REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_ | |
OLD | NEW |