invitation_dispatcher.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2018 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 MOJO_CORE_INVITATION_DISPATCHER_H_
  5. #define MOJO_CORE_INVITATION_DISPATCHER_H_
  6. #include <stdint.h>
  7. #include "base/containers/flat_map.h"
  8. #include "base/memory/ref_counted.h"
  9. #include "base/synchronization/lock.h"
  10. #include "mojo/core/dispatcher.h"
  11. #include "mojo/core/ports/port_ref.h"
  12. #include "mojo/core/system_impl_export.h"
  13. namespace mojo {
  14. namespace core {
  15. class MOJO_SYSTEM_IMPL_EXPORT InvitationDispatcher : public Dispatcher {
  16. public:
  17. InvitationDispatcher();
  18. InvitationDispatcher(const InvitationDispatcher&) = delete;
  19. InvitationDispatcher& operator=(const InvitationDispatcher&) = delete;
  20. // Dispatcher:
  21. Type GetType() const override;
  22. MojoResult Close() override;
  23. MojoResult AttachMessagePipe(base::StringPiece name,
  24. ports::PortRef remote_peer_port) override;
  25. MojoResult ExtractMessagePipe(base::StringPiece name,
  26. MojoHandle* message_pipe_handle) override;
  27. using PortMapping = base::flat_map<std::string, ports::PortRef>;
  28. PortMapping TakeAttachedPorts();
  29. private:
  30. ~InvitationDispatcher() override;
  31. base::Lock lock_;
  32. bool is_closed_ = false;
  33. PortMapping attached_ports_;
  34. };
  35. } // namespace core
  36. } // namespace mojo
  37. #endif // MOJO_CORE_INVITATION_DISPATCHER_H_