OLD | NEW |
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 #include "remoting/protocol/data_channel_manager.h" | 5 #include "remoting/protocol/data_channel_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "remoting/protocol/message_pipe.h" | 10 #include "remoting/protocol/message_pipe.h" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 namespace protocol { | 13 namespace protocol { |
14 | 14 |
15 DataChannelManager::DataChannelManager() = default; | 15 DataChannelManager::DataChannelManager() = default; |
16 DataChannelManager::~DataChannelManager() = default; | 16 DataChannelManager::~DataChannelManager() = default; |
17 | 17 |
18 void DataChannelManager::RegisterCreateHandlerCallback( | 18 void DataChannelManager::RegisterCreateHandlerCallback( |
19 const std::string& prefix, | 19 const std::string& prefix, |
20 CreateHandlerCallback constructor) { | 20 CreateHandlerCallback constructor) { |
21 DCHECK(!prefix.empty()); | 21 DCHECK(!prefix.empty()); |
22 DCHECK(constructor); | 22 DCHECK(constructor); |
23 constructors_.push_back(std::make_pair(prefix, constructor)); | 23 constructors_.push_back(std::make_pair(prefix, std::move(constructor))); |
24 } | 24 } |
25 | 25 |
26 bool DataChannelManager::OnIncomingDataChannel( | 26 bool DataChannelManager::OnIncomingDataChannel( |
27 const std::string& name, | 27 const std::string& name, |
28 std::unique_ptr<MessagePipe> pipe) { | 28 std::unique_ptr<MessagePipe> pipe) { |
29 for (auto& constructor : constructors_) { | 29 for (auto& constructor : constructors_) { |
30 if (name.find(constructor.first) == 0) { | 30 if (name.find(constructor.first) == 0) { |
31 constructor.second.Run(name, std::move(pipe)); | 31 constructor.second.Run(name, std::move(pipe)); |
32 return true; | 32 return true; |
33 } | 33 } |
34 } | 34 } |
35 return false; | 35 return false; |
36 } | 36 } |
37 | 37 |
38 } // namespace protocol | 38 } // namespace protocol |
39 } // namespace remoting | 39 } // namespace remoting |
OLD | NEW |