#include "mojo/public/cpp/system/invitation.h"
#include <memory>
#include <tuple>
#include <utility>
#include "base/numerics/safe_conversions.h"
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/c/system/invitation.h"
#include "mojo/public/c/system/platform_handle.h"
#include "mojo/public/cpp/system/platform_handle.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
#if !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
#include "mojo/public/cpp/platform/platform_channel_server.h"
#endif
namespace mojo {
namespace {
static constexpr std::string_view kIsolatedPipeName = …;
void ProcessHandleToMojoProcessHandle(base::ProcessHandle target_process,
MojoPlatformProcessHandle* handle) { … }
void PlatformHandleToTransportEndpoint(
PlatformHandle platform_handle,
MojoPlatformHandle* endpoint_handle,
MojoInvitationTransportEndpoint* endpoint) { … }
void RunErrorCallback(uintptr_t context,
const MojoProcessErrorDetails* details) { … }
void SendInvitation(ScopedInvitationHandle invitation,
base::ProcessHandle target_process,
PlatformHandle endpoint_handle,
MojoInvitationTransportType transport_type,
MojoSendInvitationFlags flags,
const ProcessErrorCallback& error_callback,
std::string_view isolated_connection_name) { … }
#if !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
void WaitForServerConnection(
PlatformChannelServerEndpoint server_endpoint,
PlatformChannelServer::ConnectionCallback callback) { … }
base::Process CloneProcessFromHandle(base::ProcessHandle handle) { … }
#endif
}
OutgoingInvitation::OutgoingInvitation() { … }
OutgoingInvitation::OutgoingInvitation(OutgoingInvitation&& other) = default;
OutgoingInvitation::~OutgoingInvitation() = default;
OutgoingInvitation& OutgoingInvitation::operator=(OutgoingInvitation&& other) =
default;
ScopedMessagePipeHandle OutgoingInvitation::AttachMessagePipe(
std::string_view name) { … }
ScopedMessagePipeHandle OutgoingInvitation::AttachMessagePipe(uint64_t name) { … }
ScopedMessagePipeHandle OutgoingInvitation::ExtractMessagePipe(
std::string_view name) { … }
ScopedMessagePipeHandle OutgoingInvitation::ExtractMessagePipe(uint64_t name) { … }
void OutgoingInvitation::Send(OutgoingInvitation invitation,
base::ProcessHandle target_process,
PlatformChannelEndpoint channel_endpoint,
const ProcessErrorCallback& error_callback) { … }
void OutgoingInvitation::Send(OutgoingInvitation invitation,
base::ProcessHandle target_process,
PlatformChannelServerEndpoint server_endpoint,
const ProcessErrorCallback& error_callback) { … }
void OutgoingInvitation::SendAsync(OutgoingInvitation invitation,
base::ProcessHandle target_process,
PlatformChannelEndpoint channel_endpoint,
const ProcessErrorCallback& error_callback) { … }
ScopedMessagePipeHandle OutgoingInvitation::SendIsolated(
PlatformChannelEndpoint channel_endpoint,
std::string_view connection_name,
base::ProcessHandle target_process) { … }
ScopedMessagePipeHandle OutgoingInvitation::SendIsolated(
PlatformChannelServerEndpoint server_endpoint,
std::string_view connection_name,
base::ProcessHandle target_process) { … }
IncomingInvitation::IncomingInvitation() = default;
IncomingInvitation::IncomingInvitation(IncomingInvitation&& other) = default;
IncomingInvitation::IncomingInvitation(ScopedInvitationHandle handle)
: … { … }
IncomingInvitation::~IncomingInvitation() = default;
IncomingInvitation& IncomingInvitation::operator=(IncomingInvitation&& other) =
default;
IncomingInvitation IncomingInvitation::Accept(
PlatformChannelEndpoint channel_endpoint,
MojoAcceptInvitationFlags flags) { … }
IncomingInvitation IncomingInvitation::AcceptAsync(
PlatformChannelEndpoint channel_endpoint) { … }
ScopedMessagePipeHandle IncomingInvitation::AcceptIsolated(
PlatformChannelEndpoint channel_endpoint) { … }
ScopedMessagePipeHandle IncomingInvitation::ExtractMessagePipe(
std::string_view name) { … }
ScopedMessagePipeHandle IncomingInvitation::ExtractMessagePipe(uint64_t name) { … }
}