#include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include "base/command_line.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "mojo/public/cpp/platform/platform_channel.h"
#if BUILDFLAG(MOJO_USE_APPLE_CHANNEL)
#include <mach/port.h>
#include "base/apple/scoped_mach_port.h"
#include "base/mac/mach_port_rendezvous.h"
#elif BUILDFLAG(IS_FUCHSIA)
#include <lib/zx/handle.h>
#elif BUILDFLAG(IS_POSIX)
#include "base/files/scoped_file.h"
#include "base/posix/global_descriptors.h"
#elif BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/win/scoped_handle.h"
#endif
#if BUILDFLAG(IS_ANDROID)
#include "base/android/binder.h"
#endif
namespace mojo {
namespace {
#if BUILDFLAG(IS_ANDROID)
constexpr int kAndroidClientHandleDescriptor =
base::GlobalDescriptors::kBaseDescriptor + 10000;
constexpr std::string_view kBinderValuePrefix = "binder:";
#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(MOJO_USE_APPLE_CHANNEL)
bool IsTargetDescriptorUsed(const base::FileHandleMappingVector& mapping,
int target_fd) { … }
#endif
}
PlatformChannelEndpoint::PlatformChannelEndpoint() = default;
PlatformChannelEndpoint::PlatformChannelEndpoint(
PlatformChannelEndpoint&& other) = default;
PlatformChannelEndpoint::PlatformChannelEndpoint(PlatformHandle handle)
: … { … }
PlatformChannelEndpoint::~PlatformChannelEndpoint() = default;
PlatformChannelEndpoint& PlatformChannelEndpoint::operator=(
PlatformChannelEndpoint&& other) = default;
void PlatformChannelEndpoint::reset() { … }
PlatformChannelEndpoint PlatformChannelEndpoint::Clone() const { … }
void PlatformChannelEndpoint::PrepareToPass(HandlePassingInfo& info,
base::CommandLine& command_line) { … }
void PlatformChannelEndpoint::PrepareToPass(HandlePassingInfo& info,
std::string& value) { … }
void PlatformChannelEndpoint::PrepareToPass(base::LaunchOptions& options,
base::CommandLine& command_line) { … }
std::string PlatformChannelEndpoint::PrepareToPass(
base::LaunchOptions& options) { … }
void PlatformChannelEndpoint::ProcessLaunchAttempted() { … }
PlatformChannelEndpoint PlatformChannelEndpoint::RecoverFromString(
std::string_view value) { … }
}