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