OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_STREAM_CHANNEL_FACTORY_H_ | 5 #ifndef REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_ |
6 #define REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_ | 6 #define REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
13 | 13 |
14 namespace net { | |
15 class Socket; | |
16 class StreamSocket; | |
17 } // namespace net | |
18 | |
19 namespace remoting { | 14 namespace remoting { |
20 namespace protocol { | 15 namespace protocol { |
21 | 16 |
| 17 class P2PStreamSocket; |
| 18 |
22 class StreamChannelFactory : public base::NonThreadSafe { | 19 class StreamChannelFactory : public base::NonThreadSafe { |
23 public: | 20 public: |
24 // TODO(sergeyu): Specify connection error code when channel | 21 // TODO(sergeyu): Specify connection error code when channel |
25 // connection fails. | 22 // connection fails. |
26 typedef base::Callback<void(scoped_ptr<net::StreamSocket>)> | 23 typedef base::Callback<void(scoped_ptr<P2PStreamSocket>)> |
27 ChannelCreatedCallback; | 24 ChannelCreatedCallback; |
28 | 25 |
29 StreamChannelFactory() {} | 26 StreamChannelFactory() {} |
30 | 27 |
31 // Creates new channels and calls the |callback| when then new channel is | 28 // Creates new channels and calls the |callback| when then new channel is |
32 // created and connected. The |callback| is called with nullptr if connection | 29 // created and connected. The |callback| is called with nullptr if connection |
33 // failed for any reason. Callback may be called synchronously, before the | 30 // failed for any reason. Callback may be called synchronously, before the |
34 // call returns. All channels must be destroyed, and CancelChannelCreation() | 31 // call returns. All channels must be destroyed, and CancelChannelCreation() |
35 // called for any pending channels, before the factory is destroyed. | 32 // called for any pending channels, before the factory is destroyed. |
36 virtual void CreateChannel(const std::string& name, | 33 virtual void CreateChannel(const std::string& name, |
37 const ChannelCreatedCallback& callback) = 0; | 34 const ChannelCreatedCallback& callback) = 0; |
38 | 35 |
39 // Cancels a pending CreateChannel() operation for the named channel. If the | 36 // Cancels a pending CreateChannel() operation for the named channel. If the |
40 // channel creation already completed then canceling it has no effect. When | 37 // channel creation already completed then canceling it has no effect. When |
41 // shutting down this method must be called for each channel pending creation. | 38 // shutting down this method must be called for each channel pending creation. |
42 virtual void CancelChannelCreation(const std::string& name) = 0; | 39 virtual void CancelChannelCreation(const std::string& name) = 0; |
43 | 40 |
44 protected: | 41 protected: |
45 virtual ~StreamChannelFactory() {} | 42 virtual ~StreamChannelFactory() {} |
46 | 43 |
47 private: | 44 private: |
48 DISALLOW_COPY_AND_ASSIGN(StreamChannelFactory); | 45 DISALLOW_COPY_AND_ASSIGN(StreamChannelFactory); |
49 }; | 46 }; |
50 | 47 |
51 } // namespace protocol | 48 } // namespace protocol |
52 } // namespace remoting | 49 } // namespace remoting |
53 | 50 |
54 #endif // REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_ | 51 #endif // REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_ |
OLD | NEW |