| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DATAGRAM_CHANNEL_FACTORY_H_ | 5 #ifndef REMOTING_PROTOCOL_DATAGRAM_CHANNEL_FACTORY_H_ |
| 6 #define REMOTING_PROTOCOL_DATAGRAM_CHANNEL_FACTORY_H_ | 6 #define REMOTING_PROTOCOL_DATAGRAM_CHANNEL_FACTORY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 | 11 |
| 12 namespace net { | |
| 13 class Socket; | |
| 14 } // namespace net | |
| 15 | |
| 16 namespace remoting { | 12 namespace remoting { |
| 17 namespace protocol { | 13 namespace protocol { |
| 18 | 14 |
| 15 class P2PDatagramSocket; |
| 16 |
| 19 class DatagramChannelFactory { | 17 class DatagramChannelFactory { |
| 20 public: | 18 public: |
| 21 typedef base::Callback<void(scoped_ptr<net::Socket>)> | 19 typedef base::Callback<void(scoped_ptr<P2PDatagramSocket>)> |
| 22 ChannelCreatedCallback; | 20 ChannelCreatedCallback; |
| 23 | 21 |
| 24 DatagramChannelFactory() {} | 22 DatagramChannelFactory() {} |
| 25 | 23 |
| 26 // Creates new channels and calls the |callback| when then new channel is | 24 // Creates new channels and calls the |callback| when then new channel is |
| 27 // created and connected. The |callback| is called with nullptr if channel | 25 // created and connected. The |callback| is called with nullptr if channel |
| 28 // setup failed for any reason. Callback may be called synchronously, before | 26 // setup failed for any reason. Callback may be called synchronously, before |
| 29 // the call returns. All channels must be destroyed, and | 27 // the call returns. All channels must be destroyed, and |
| 30 // CancelChannelCreation() called for any pending channels, before the factory | 28 // CancelChannelCreation() called for any pending channels, before the factory |
| 31 // is destroyed. | 29 // is destroyed. |
| 32 virtual void CreateChannel(const std::string& name, | 30 virtual void CreateChannel(const std::string& name, |
| 33 const ChannelCreatedCallback& callback) = 0; | 31 const ChannelCreatedCallback& callback) = 0; |
| 34 | 32 |
| 35 // Cancels a pending CreateChannel() operation for the named channel. If the | 33 // Cancels a pending CreateChannel() operation for the named channel. If the |
| 36 // channel creation already completed then canceling it has no effect. When | 34 // channel creation already completed then canceling it has no effect. When |
| 37 // shutting down this method must be called for each channel pending creation. | 35 // shutting down this method must be called for each channel pending creation. |
| 38 virtual void CancelChannelCreation(const std::string& name) = 0; | 36 virtual void CancelChannelCreation(const std::string& name) = 0; |
| 39 | 37 |
| 40 protected: | 38 protected: |
| 41 virtual ~DatagramChannelFactory() {} | 39 virtual ~DatagramChannelFactory() {} |
| 42 | 40 |
| 43 private: | 41 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(DatagramChannelFactory); | 42 DISALLOW_COPY_AND_ASSIGN(DatagramChannelFactory); |
| 45 }; | 43 }; |
| 46 | 44 |
| 47 } // namespace protocol | 45 } // namespace protocol |
| 48 } // namespace remoting | 46 } // namespace remoting |
| 49 | 47 |
| 50 #endif // REMOTING_PROTOCOL_DATAGRAM_CHANNEL_FACTORY_H_ | 48 #endif // REMOTING_PROTOCOL_DATAGRAM_CHANNEL_FACTORY_H_ |
| OLD | NEW |