#include "content/browser/child_process_launcher_helper.h"
#include <optional>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/shared_memory_switch.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/histogram_shared_memory.h"
#include "base/no_destructor.h"
#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/lazy_thread_pool_task_runner.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/single_thread_task_runner_thread_mode.h"
#include "base/task/task_traits.h"
#include "build/build_config.h"
#include "components/tracing/common/tracing_switches.h"
#include "components/variations/active_field_trials.h"
#include "content/browser/child_process_launcher.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_launcher_utils.h"
#include "content/public/common/content_descriptors.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "mojo/core/configuration.h"
#include "mojo/public/cpp/platform/platform_channel.h"
#include "services/tracing/public/cpp/trace_startup.h"
#if BUILDFLAG(IS_ANDROID)
#include "content/browser/android/launcher_thread.h"
#endif
#if BUILDFLAG(IS_IOS)
#include "base/mac/mach_port_rendezvous.h"
#endif
namespace content {
namespace internal {
namespace {
void RecordHistogramsOnLauncherThread(base::TimeDelta launch_time) { … }
void PassHistogramSharedMemoryHandle(
[[maybe_unused]] base::UnsafeSharedMemoryRegion histogram_memory_region,
[[maybe_unused]] base::CommandLine* command_line,
[[maybe_unused]] base::LaunchOptions* launch_options,
[[maybe_unused]] FileMappedForLaunch* files_to_register) { … }
void PassFieldTrialSharedMemoryHandle(
[[maybe_unused]] base::CommandLine* command_line,
[[maybe_unused]] base::LaunchOptions* launch_options,
[[maybe_unused]] FileMappedForLaunch* files_to_register) { … }
void PassStartupTracingConfigSharedMemoryHandle(
[[maybe_unused]] base::ReadOnlySharedMemoryRegion read_only_memory_region,
[[maybe_unused]] base::CommandLine* command_line,
[[maybe_unused]] base::LaunchOptions* launch_options,
[[maybe_unused]] FileMappedForLaunch* files_to_register) { … }
}
ChildProcessLauncherHelper::Process::Process() = default;
ChildProcessLauncherHelper::Process::~Process() = default;
ChildProcessLauncherHelper::Process::Process(Process&& other)
: … { … }
ChildProcessLauncherHelper::Process&
ChildProcessLauncherHelper::Process::Process::operator=(
ChildProcessLauncherHelper::Process&& other) = default;
ChildProcessLauncherHelper::ChildProcessLauncherHelper(
int child_process_id,
std::unique_ptr<base::CommandLine> command_line,
std::unique_ptr<SandboxedProcessLauncherDelegate> delegate,
const base::WeakPtr<ChildProcessLauncher>& child_process_launcher,
bool terminate_on_shutdown,
#if BUILDFLAG(IS_ANDROID)
bool can_use_warm_up_connection,
#endif
mojo::OutgoingInvitation mojo_invitation,
const mojo::ProcessErrorCallback& process_error_callback,
std::unique_ptr<ChildProcessLauncherFileData> file_data,
base::UnsafeSharedMemoryRegion histogram_memory_region,
base::ReadOnlySharedMemoryRegion tracing_config_memory_region)
: … { … }
ChildProcessLauncherHelper::~ChildProcessLauncherHelper() { … }
void ChildProcessLauncherHelper::StartLaunchOnClientThread() { … }
void ChildProcessLauncherHelper::LaunchOnLauncherThread() { … }
void ChildProcessLauncherHelper::PostLaunchOnLauncherThread(
ChildProcessLauncherHelper::Process process,
#if BUILDFLAG(IS_WIN)
DWORD last_error,
#endif
int launch_result) { … }
void ChildProcessLauncherHelper::PostLaunchOnClientThread(
ChildProcessLauncherHelper::Process process,
#if BUILDFLAG(IS_WIN)
DWORD last_error,
#endif
int error_code) { … }
std::string ChildProcessLauncherHelper::GetProcessType() { … }
void ChildProcessLauncherHelper::ForceNormalProcessTerminationAsync(
ChildProcessLauncherHelper::Process process) { … }
#if !BUILDFLAG(IS_WIN)
void ChildProcessLauncherHelper::PassLoggingSwitches(
base::LaunchOptions* launch_options,
base::CommandLine* cmd_line) { … }
#endif
}
base::SingleThreadTaskRunner* GetProcessLauncherTaskRunner() { … }
bool CurrentlyOnProcessLauncherTaskRunner() { … }
}