message_channel_factory.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2016 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_MESSAGE_CHANNEL_FACTORY_H_
  5. #define REMOTING_PROTOCOL_MESSAGE_CHANNEL_FACTORY_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/callback_forward.h"
  9. namespace remoting {
  10. namespace protocol {
  11. class MessagePipe;
  12. class MessageChannelFactory {
  13. public:
  14. typedef base::OnceCallback<void(std::unique_ptr<MessagePipe>)>
  15. ChannelCreatedCallback;
  16. virtual ~MessageChannelFactory() {}
  17. // Creates new channels and calls the |callback| when then new channel is
  18. // created and connected. Callback may be called synchronously, before the
  19. // call returns. If channel creation fails the callback is never called. All
  20. // channels must be destroyed, and CancelChannelCreation() called for any
  21. // pending channels, before the factory is destroyed.
  22. virtual void CreateChannel(const std::string& name,
  23. ChannelCreatedCallback callback) = 0;
  24. // Cancels a pending CreateChannel() operation for the named channel. If the
  25. // channel creation already completed then canceling it has no effect. When
  26. // shutting down this method must be called for each channel pending creation.
  27. virtual void CancelChannelCreation(const std::string& name) = 0;
  28. };
  29. } // namespace protocol
  30. } // namespace remoting
  31. #endif // REMOTING_PROTOCOL_MESSAGE_CHANNEL_FACTORY_H_