Chromium Code Reviews| 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 <memory> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/callback.h" | |
| 13 | |
| 14 namespace remoting { | |
| 15 namespace protocol { | |
| 16 | |
| 17 class DataChannelHandler; | |
|
joedow
2017/06/06 23:33:25
remove this fwd declare since it isn't used.
Hzj_jie
2017/06/07 17:31:25
Done.
| |
| 18 class MessagePipe; | |
| 19 | |
| 20 // DataChannelManager helps to manage optional data channels. Each | |
| 21 // DataChannelHandler implementation registers a factory function to create an | |
| 22 // instance of itself to handle data from a named data channel. All handles are | |
| 23 // closed when the associated MessagePipe is closed. Clients can also close a | |
| 24 // data channel manually by calling DataChannelHandler::Close() function. | |
|
joedow
2017/06/06 23:33:25
I don't think the DCM should include any impl deta
Hzj_jie
2017/06/07 17:31:25
The client means "the client of DataChannelHandler
| |
| 25 class DataChannelManager final { | |
| 26 public: | |
| 27 using CreateHandlerCallback = base::Callback<void( | |
| 28 const std::string& name, | |
| 29 std::unique_ptr<MessagePipe> pipe)>; | |
| 30 | |
| 31 DataChannelManager(); | |
| 32 ~DataChannelManager(); | |
|
joedow
2017/06/06 23:33:25
Would it make sense to expose a static function an
Hzj_jie
2017/06/07 17:31:25
The lifetime of a DataChannelManager should be con
| |
| 33 | |
| 34 // Registers a factory function to create a DataChannelHandler to handle a new | |
|
joedow
2017/06/06 23:33:25
As discussed, it may not create a DataChannelHandl
Hzj_jie
2017/06/07 17:31:25
Done.
| |
| 35 // incoming data channel with a name matching |prefix|. Returns false if the | |
| 36 // registration fails, usually it happens when |prefix| or |constructor| are | |
| 37 // empty. | |
| 38 bool RegisterCreateHandlerCallback(const std::string& prefix, | |
| 39 CreateHandlerCallback constructor); | |
| 40 | |
| 41 // Creates a DataChannelHandler to handle the new incoming data channel. | |
| 42 // Returns true if a handler exists for the new data channel. | |
|
joedow
2017/06/06 23:33:25
nit: Doesn't the function return true if a handler
Hzj_jie
2017/06/07 17:31:25
Done.
| |
| 43 bool OnIncomingDataChannel(const std::string& name, | |
| 44 std::unique_ptr<MessagePipe> pipe); | |
| 45 | |
| 46 private: | |
| 47 std::vector<std::pair<std::string, CreateHandlerCallback>> constructors_; | |
| 48 }; | |
| 49 | |
| 50 } // namespace protocol | |
| 51 } // namespace remoting | |
| 52 | |
| 53 #endif // REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_ | |
| OLD | NEW |