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.
5 #ifndef REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_
6 #define REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/non_thread_safe.h"
22 class StreamChannelFactory
: public base::NonThreadSafe
{
24 // TODO(sergeyu): Specify connection error code when channel
26 typedef base::Callback
<void(scoped_ptr
<net::StreamSocket
>)>
27 ChannelCreatedCallback
;
29 StreamChannelFactory() {}
31 // Creates new channels and calls the |callback| when then new channel is
32 // created and connected. The |callback| is called with NULL if connection
33 // failed for any reason. Callback may be called synchronously, before the
34 // call returns. All channels must be destroyed, and CancelChannelCreation()
35 // called for any pending channels, before the factory is destroyed.
36 virtual void CreateChannel(const std::string
& name
,
37 const ChannelCreatedCallback
& callback
) = 0;
39 // Cancels a pending CreateChannel() operation for the named channel. If the
40 // channel creation already completed then canceling it has no effect. When
41 // shutting down this method must be called for each channel pending creation.
42 virtual void CancelChannelCreation(const std::string
& name
) = 0;
45 virtual ~StreamChannelFactory() {}
48 DISALLOW_COPY_AND_ASSIGN(StreamChannelFactory
);
51 } // namespace protocol
52 } // namespace remoting
54 #endif // REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_