chromium/content/browser/utility_process_host.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/utility_process_host.h"

#include <memory>
#include <utility>

#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/i18n/base_i18n_switches.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "components/services/storage/public/mojom/storage_service.mojom.h"
#include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/child_process_host_impl.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/utility_sandbox_delegate.h"
#include "content/common/features.h"
#include "content/common/in_process_child_thread_params.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_descriptor_keys.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/process_type.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/zygote/zygote_buildflags.h"
#include "media/base/media_switches.h"
#include "media/media_buildflags.h"
#include "media/webrtc/webrtc_features.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#include "sandbox/policy/sandbox_type.h"
#include "sandbox/policy/switches.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gl/gl_switches.h"

#if BUILDFLAG(IS_ANDROID)
#include "services/network/public/mojom/network_service.mojom.h"
#endif

#if BUILDFLAG(IS_MAC)
#include "components/os_crypt/sync/os_crypt_switches.h"
#endif

#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
#include "content/browser/v8_snapshot_files.h"
#endif

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/pickle.h"
#endif

#if BUILDFLAG(IS_WIN)
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "media/capture/capture_switches.h"
#include "services/audio/public/mojom/audio_service.mojom.h"
#include "services/network/public/mojom/network_service.mojom.h"
#endif

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/task/sequenced_task_runner.h"
#include "components/viz/host/gpu_client.h"
#include "media/capture/capture_switches.h"
#include "services/video_capture/public/mojom/video_capture_service.mojom.h"
#endif

namespace content {

namespace {

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
base::ScopedFD PassNetworkContextParentDirs(
    std::vector<base::FilePath> network_context_parent_dirs) {}
#endif  // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)

#if BUILDFLAG(IS_WIN)
base::CommandLine::StringViewType UtilityToAppLaunchPrefetchArg(
    const std::string& utility_type) {
  // Set the default prefetch type for utility processes.
  app_launch_prefetch::SubprocessType prefetch_type =
      app_launch_prefetch::SubprocessType::kUtilityOther;

  if (utility_type == network::mojom::NetworkService::Name_) {
    prefetch_type = app_launch_prefetch::SubprocessType::kUtilityNetworkService;
  } else if (utility_type == storage::mojom::StorageService::Name_) {
    prefetch_type = app_launch_prefetch::SubprocessType::kUtilityStorage;
  } else if (utility_type == audio::mojom::AudioService::Name_) {
    prefetch_type = app_launch_prefetch::SubprocessType::kUtilityAudio;
  }
  return app_launch_prefetch::GetPrefetchSwitch(prefetch_type);
}
#endif  // BUILDFLAG(IS_WIN)

}  // namespace

UtilityMainThreadFactoryFunction g_utility_main_thread_factory =;

void UtilityProcessHost::RegisterUtilityMainThreadFactory(
    UtilityMainThreadFactoryFunction create) {}

UtilityProcessHost::UtilityProcessHost()
    :{}

UtilityProcessHost::UtilityProcessHost(std::unique_ptr<Client> client)
    :{}

UtilityProcessHost::~UtilityProcessHost() {}

base::WeakPtr<UtilityProcessHost> UtilityProcessHost::AsWeakPtr() {}

void UtilityProcessHost::SetSandboxType(sandbox::mojom::Sandbox sandbox_type) {}

const ChildProcessData& UtilityProcessHost::GetData() {}

#if BUILDFLAG(IS_POSIX)
void UtilityProcessHost::SetEnv(const base::EnvironmentMap& env) {}
#endif

bool UtilityProcessHost::Start() {}

void UtilityProcessHost::SetMetricsName(const std::string& metrics_name) {}

void UtilityProcessHost::SetName(const std::u16string& name) {}

void UtilityProcessHost::SetExtraCommandLineSwitches(
    std::vector<std::string> switches) {}

#if BUILDFLAG(IS_WIN)
void UtilityProcessHost::SetPreloadLibraries(
    const std::vector<base::FilePath>& preloads) {
  preload_libraries_ = preloads;
}
#endif  // BUILDFLAG(IS_WIN)

void UtilityProcessHost::SetAllowGpuClient() {}

#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
void UtilityProcessHost::AddFileToPreload(
    std::string key,
    absl::variant<base::FilePath, base::ScopedFD> file) {}
#endif  // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)

#if BUILDFLAG(USE_ZYGOTE)
void UtilityProcessHost::SetZygoteForTesting(ZygoteCommunication* handle) {}
#endif  // BUILDFLAG(USE_ZYGOTE)

mojom::ChildProcess* UtilityProcessHost::GetChildProcess() {}

bool UtilityProcessHost::StartProcess() {}

void UtilityProcessHost::OnProcessLaunched() {}

void UtilityProcessHost::OnProcessLaunchFailed(int error_code) {}

void UtilityProcessHost::OnProcessCrashed(int exit_code) {}

std::optional<std::string> UtilityProcessHost::GetServiceName() {}

}  // namespace content