#include "base/metrics/histogram_shared_memory.h"
#include <string_view>
#include "base/base_switches.h"
#include "base/debug/crash_logging.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/memory/shared_memory_switch.h"
#include "base/memory/writable_shared_memory_region.h"
#include "base/metrics/histogram_macros_local.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/process/launch.h"
#include "base/process/process_handle.h"
#include "base/process/process_info.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/unguessable_token.h"
#if BUILDFLAG(IS_APPLE)
#include "base/mac/mach_port_rendezvous.h"
#endif
#if BUILDFLAG(IS_POSIX)
#include "base/posix/global_descriptors.h"
#endif
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/win/win_util.h"
#endif
#if BUILDFLAG(IS_FUCHSIA)
#include <lib/zx/vmo.h>
#include <zircon/process.h>
#include "base/fuchsia/fuchsia_logging.h"
#endif
namespace base {
BASE_FEATURE(…);
#if BUILDFLAG(IS_APPLE)
const MachPortsForRendezvous::key_type HistogramSharedMemory::kRendezvousKey =
'hsmr';
#endif
HistogramSharedMemory::SharedMemory::SharedMemory(
UnsafeSharedMemoryRegion r,
std::unique_ptr<PersistentMemoryAllocator> a)
: … { … }
HistogramSharedMemory::SharedMemory::~SharedMemory() = default;
HistogramSharedMemory::SharedMemory::SharedMemory(
HistogramSharedMemory::SharedMemory&&) = default;
HistogramSharedMemory::SharedMemory&
HistogramSharedMemory::SharedMemory::operator=(
HistogramSharedMemory::SharedMemory&&) = default;
std::optional<HistogramSharedMemory::SharedMemory>
HistogramSharedMemory::Create(int process_id,
const HistogramSharedMemory::Config& config) { … }
bool HistogramSharedMemory::PassOnCommandLineIsEnabled(
std::string_view process_type) { … }
void HistogramSharedMemory::AddToLaunchParameters(
UnsafeSharedMemoryRegion histogram_shmem_region,
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE)
GlobalDescriptors::Key descriptor_key,
ScopedFD& descriptor_to_share,
#endif
CommandLine* command_line,
LaunchOptions* launch_options) { … }
void HistogramSharedMemory::InitFromLaunchParameters(
const CommandLine& command_line) { … }
}