Roll src/third_party/WebKit 3529d49:06e8485 (svn 202554:202555)
[chromium-blink-merge.git] / remoting / protocol / stream_channel_factory.h
blobcbfef254fe915c7df3104ebd28ad8d5911593913
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_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/non_thread_safe.h"
14 namespace remoting {
15 namespace protocol {
17 class P2PStreamSocket;
19 class StreamChannelFactory : public base::NonThreadSafe {
20 public:
21 // TODO(sergeyu): Specify connection error code when channel
22 // connection fails.
23 typedef base::Callback<void(scoped_ptr<P2PStreamSocket>)>
24 ChannelCreatedCallback;
26 StreamChannelFactory() {}
28 // Creates new channels and calls the |callback| when then new channel is
29 // created and connected. The |callback| is called with nullptr if connection
30 // failed for any reason. Callback may be called synchronously, before the
31 // call returns. All channels must be destroyed, and CancelChannelCreation()
32 // called for any pending channels, before the factory is destroyed.
33 virtual void CreateChannel(const std::string& name,
34 const ChannelCreatedCallback& callback) = 0;
36 // Cancels a pending CreateChannel() operation for the named channel. If the
37 // channel creation already completed then canceling it has no effect. When
38 // shutting down this method must be called for each channel pending creation.
39 virtual void CancelChannelCreation(const std::string& name) = 0;
41 protected:
42 virtual ~StreamChannelFactory() {}
44 private:
45 DISALLOW_COPY_AND_ASSIGN(StreamChannelFactory);
48 } // namespace protocol
49 } // namespace remoting
51 #endif // REMOTING_PROTOCOL_STREAM_CHANNEL_FACTORY_H_