OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_MESSAGE_CHANNEL_FACTORY_H_ | 5 #ifndef REMOTING_PROTOCOL_MESSAGE_CHANNEL_FACTORY_H_ |
6 #define REMOTING_PROTOCOL_MESSAGE_CHANNEL_FACTORY_H_ | 6 #define REMOTING_PROTOCOL_MESSAGE_CHANNEL_FACTORY_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 namespace protocol { | 14 namespace protocol { |
15 | 15 |
16 class MessagePipe; | 16 class MessagePipe; |
17 | 17 |
18 class MessageChannelFactory { | 18 class MessageChannelFactory { |
19 public: | 19 public: |
20 typedef base::Callback<void(scoped_ptr<MessagePipe>)> ChannelCreatedCallback; | 20 typedef base::Callback<void(std::unique_ptr<MessagePipe>)> |
| 21 ChannelCreatedCallback; |
21 | 22 |
22 virtual ~MessageChannelFactory() {} | 23 virtual ~MessageChannelFactory() {} |
23 | 24 |
24 // Creates new channels and calls the |callback| when then new channel is | 25 // Creates new channels and calls the |callback| when then new channel is |
25 // created and connected. Callback may be called synchronously, before the | 26 // created and connected. Callback may be called synchronously, before the |
26 // call returns. If channel creation fails the callback is never called. All | 27 // call returns. If channel creation fails the callback is never called. All |
27 // channels must be destroyed, and CancelChannelCreation() called for any | 28 // channels must be destroyed, and CancelChannelCreation() called for any |
28 // pending channels, before the factory is destroyed. | 29 // pending channels, before the factory is destroyed. |
29 virtual void CreateChannel(const std::string& name, | 30 virtual void CreateChannel(const std::string& name, |
30 const ChannelCreatedCallback& callback) = 0; | 31 const ChannelCreatedCallback& callback) = 0; |
31 | 32 |
32 // Cancels a pending CreateChannel() operation for the named channel. If the | 33 // Cancels a pending CreateChannel() operation for the named channel. If the |
33 // channel creation already completed then canceling it has no effect. When | 34 // channel creation already completed then canceling it has no effect. When |
34 // shutting down this method must be called for each channel pending creation. | 35 // shutting down this method must be called for each channel pending creation. |
35 virtual void CancelChannelCreation(const std::string& name) = 0; | 36 virtual void CancelChannelCreation(const std::string& name) = 0; |
36 }; | 37 }; |
37 | 38 |
38 } // namespace protocol | 39 } // namespace protocol |
39 } // namespace remoting | 40 } // namespace remoting |
40 | 41 |
41 #endif // REMOTING_PROTOCOL_MESSAGE_CHANNEL_FACTORY_H_ | 42 #endif // REMOTING_PROTOCOL_MESSAGE_CHANNEL_FACTORY_H_ |
OLD | NEW |