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_CHANNEL_FACTORY_H_
6 #define REMOTING_PROTOCOL_CHANNEL_FACTORY_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/non_thread_safe.h"
20 class ChannelFactory
: public base::NonThreadSafe
{
22 // TODO(sergeyu): Specify connection error code when channel
24 typedef base::Callback
<void(scoped_ptr
<net::StreamSocket
>)>
25 StreamChannelCallback
;
26 typedef base::Callback
<void(scoped_ptr
<net::Socket
>)>
27 DatagramChannelCallback
;
31 // Creates new channels for this connection. The specified callback is called
32 // when then new channel is created and connected. The callback is called with
33 // NULL if connection failed for any reason. Callback may be called
34 // synchronously, before the call returns. All channels must be destroyed
35 // before the factory is destroyed and CancelChannelCreation() must be called
36 // to cancel creation of channels for which the |callback| hasn't been called
38 virtual void CreateStreamChannel(
39 const std::string
& name
, const StreamChannelCallback
& callback
) = 0;
40 virtual void CreateDatagramChannel(
41 const std::string
& name
, const DatagramChannelCallback
& callback
) = 0;
43 // Cancels a pending CreateStreamChannel() or CreateDatagramChannel()
44 // operation for the named channel. If the channel creation already
45 // completed then canceling it has no effect. When shutting down
46 // this method must be called for each channel pending creation.
47 virtual void CancelChannelCreation(const std::string
& name
) = 0;
50 virtual ~ChannelFactory() {}
53 DISALLOW_COPY_AND_ASSIGN(ChannelFactory
);
56 } // namespace protocol
57 } // namespace remoting
59 #endif // REMOTING_PROTOCOL_CHANNEL_FACTORY_H_