#ifndef BASE_MEMORY_SHARED_MEMORY_SWITCH_H_
#define BASE_MEMORY_SHARED_MEMORY_SWITCH_H_
#include <string_view>
#include "base/base_export.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/types/expected.h"
#include "build/blink_buildflags.h"
#include "build/build_config.h"
#if !BUILDFLAG(USE_BLINK)
#error "This is only intended for platforms that use blink."
#endif
#if BUILDFLAG(IS_APPLE)
#include "base/mac/mach_port_rendezvous.h"
#endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE)
#include "base/files/platform_file.h"
#include "base/posix/global_descriptors.h"
#endif
namespace base {
class CommandLine;
struct LaunchOptions;
namespace shared_memory {
enum class SharedMemoryError { … };
BASE_EXPORT void AddToLaunchParameters(
std::string_view switch_name,
ReadOnlySharedMemoryRegion read_only_memory_region,
#if BUILDFLAG(IS_APPLE)
MachPortsForRendezvous::key_type rendezvous_key,
#elif BUILDFLAG(IS_POSIX)
GlobalDescriptors::Key descriptor_key,
ScopedFD& out_descriptor_to_share,
#endif
CommandLine* command_line,
LaunchOptions* launch_options);
BASE_EXPORT void AddToLaunchParameters(
std::string_view switch_name,
UnsafeSharedMemoryRegion unsafe_memory_region,
#if BUILDFLAG(IS_APPLE)
MachPortsForRendezvous::key_type rendezvous_key,
#elif BUILDFLAG(IS_POSIX)
GlobalDescriptors::Key descriptor_key,
ScopedFD& out_descriptor_to_share,
#endif
CommandLine* command_line,
LaunchOptions* launch_options);
BASE_EXPORT expected<UnsafeSharedMemoryRegion, SharedMemoryError>
UnsafeSharedMemoryRegionFrom(std::string_view switch_value);
BASE_EXPORT expected<ReadOnlySharedMemoryRegion, SharedMemoryError>
ReadOnlySharedMemoryRegionFrom(std::string_view switch_value);
}
}
#endif