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

Side by Side Diff: remoting/protocol/data_channel_manager.h

Issue 2967793002: [Chromoting] Remove DataChannelManagerCallbacks constructor parameter of ClientSession (Closed)
Patch Set: Resolve review comments Created 3 years, 5 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
« no previous file with comments | « remoting/host/client_session_unittest.cc ('k') | remoting/protocol/data_channel_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_ 5 #ifndef REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_
6 #define REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_ 6 #define REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 namespace protocol { 15 namespace protocol {
16 16
17 class MessagePipe; 17 class MessagePipe;
18 18
19 // DataChannelManager helps to manage optional data channels. Consumers can 19 // DataChannelManager helps to manage optional data channels. Consumers can
20 // register a function to handle data from a named data channel. 20 // register a function to handle data from a named data channel.
21 class DataChannelManager final { 21 class DataChannelManager final {
22 public: 22 public:
23 using CreateHandlerCallback = base::Callback<void( 23 using CreateHandlerCallback = base::Callback<void(
24 const std::string& name, 24 const std::string& name,
25 std::unique_ptr<MessagePipe> pipe)>; 25 std::unique_ptr<MessagePipe> pipe)>;
26 26
27 using NameCallbackPair = std::pair<std::string, CreateHandlerCallback>;
28
29 DataChannelManager(); 27 DataChannelManager();
30 ~DataChannelManager(); 28 ~DataChannelManager();
31 29
32 // Registers a factory function to handle a new incoming data channel with a 30 // Registers a factory function to handle a new incoming data channel with a
33 // name matching |prefix|. Both |constructor| and |prefix| cannot be empty. 31 // name matching |prefix|. Both |constructor| and |prefix| cannot be empty.
34 void RegisterCreateHandlerCallback(const std::string& prefix, 32 void RegisterCreateHandlerCallback(const std::string& prefix,
35 CreateHandlerCallback constructor); 33 CreateHandlerCallback constructor);
36 34
37 // Executes the registered callback to handle the new incoming data channel. 35 // Executes the registered callback to handle the new incoming data channel.
38 // Returns true if a handler of the new data channel has been executed. 36 // Returns true if a handler of the new data channel has been executed.
39 bool OnIncomingDataChannel(const std::string& name, 37 bool OnIncomingDataChannel(const std::string& name,
40 std::unique_ptr<MessagePipe> pipe); 38 std::unique_ptr<MessagePipe> pipe);
41 39
42 private: 40 private:
43 std::vector<NameCallbackPair> constructors_; 41 std::vector<std::pair<std::string, CreateHandlerCallback>> constructors_;
44 }; 42 };
45 43
46 } // namespace protocol 44 } // namespace protocol
47 } // namespace remoting 45 } // namespace remoting
48 46
49 #endif // REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_ 47 #endif // REMOTING_PROTOCOL_DATA_CHANNEL_MANAGER_H_
OLDNEW
« no previous file with comments | « remoting/host/client_session_unittest.cc ('k') | remoting/protocol/data_channel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698