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