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