datagram_channel_factory.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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
  3. // found in the LICENSE file.
  4. #ifndef REMOTING_PROTOCOL_DATAGRAM_CHANNEL_FACTORY_H_
  5. #define REMOTING_PROTOCOL_DATAGRAM_CHANNEL_FACTORY_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/callback_forward.h"
  9. namespace remoting {
  10. namespace protocol {
  11. class P2PDatagramSocket;
  12. class DatagramChannelFactory {
  13. public:
  14. typedef base::OnceCallback<void(std::unique_ptr<P2PDatagramSocket>)>
  15. ChannelCreatedCallback;
  16. DatagramChannelFactory() {}
  17. DatagramChannelFactory(const DatagramChannelFactory&) = delete;
  18. DatagramChannelFactory& operator=(const DatagramChannelFactory&) = delete;
  19. // Creates new channels and calls the |callback| when then new channel is
  20. // created and connected. The |callback| is called with nullptr if channel
  21. // setup failed for any reason. Callback may be called synchronously, before
  22. // the call returns. All channels must be destroyed, and
  23. // CancelChannelCreation() called for any pending channels, before the factory
  24. // is destroyed.
  25. virtual void CreateChannel(const std::string& name,
  26. ChannelCreatedCallback callback) = 0;
  27. // Cancels a pending CreateChannel() operation for the named channel. If the
  28. // channel creation already completed then canceling it has no effect. When
  29. // shutting down this method must be called for each channel pending creation.
  30. virtual void CancelChannelCreation(const std::string& name) = 0;
  31. protected:
  32. virtual ~DatagramChannelFactory() {}
  33. };
  34. } // namespace protocol
  35. } // namespace remoting
  36. #endif // REMOTING_PROTOCOL_DATAGRAM_CHANNEL_FACTORY_H_