#include "services/service_manager/service_manager.h"
#include <utility>
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/not_fatal_until.h"
#include "base/path_service.h"
#include "base/process/process.h"
#include "base/process/process_handle.h"
#include "base/token.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/constants.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/mojom/connector.mojom.h"
#include "services/service_manager/public/mojom/service.mojom.h"
#include "services/service_manager/public/mojom/service_control.mojom.h"
#include "services/service_manager/public/mojom/service_manager.mojom.h"
#include "services/service_manager/service_instance.h"
#include "services/service_manager/service_process_host.h"
#if !BUILDFLAG(IS_IOS)
#include "services/service_manager/service_process_launcher.h"
#endif
namespace service_manager {
namespace {
const char kCapability_ServiceManager[] = …;
#if BUILDFLAG(IS_WIN)
const char kServiceExecutableExtension[] = ".service.exe";
#elif !BUILDFLAG(IS_IOS)
const char kServiceExecutableExtension[] = …;
#endif
base::ProcessId GetCurrentPid() { … }
const Identity& GetServiceManagerInstanceIdentity() { … }
class DefaultServiceProcessHost : public ServiceProcessHost { … };
class DefaultServiceManagerDelegate : public ServiceManager::Delegate { … };
}
ServiceManager::ServiceManager(const std::vector<Manifest>& manifests,
std::unique_ptr<Delegate> delegate)
: … { … }
ServiceManager::ServiceManager(
const std::vector<Manifest>& manifests,
ServiceExecutablePolicy service_executable_policy)
: … { … }
ServiceManager::~ServiceManager() { … }
ServiceInstance* ServiceManager::FindOrCreateMatchingTargetInstance(
const ServiceInstance& source_instance,
const ServiceFilter& partial_target_filter) { … }
void ServiceManager::StartService(const std::string& service_name) { … }
bool ServiceManager::QueryCatalog(const std::string& service_name,
const base::Token& instance_group,
std::string* sandbox_type) { … }
bool ServiceManager::RegisterService(
const Identity& identity,
mojo::PendingRemote<mojom::Service> service,
mojo::PendingReceiver<mojom::ProcessMetadata> metadata_receiver) { … }
void ServiceManager::MakeInstanceUnreachable(ServiceInstance* instance) { … }
void ServiceManager::DestroyInstance(ServiceInstance* instance) { … }
void ServiceManager::OnInstanceStopped(const Identity& identity) { … }
ServiceInstance* ServiceManager::GetExistingInstance(
const Identity& identity) const { … }
void ServiceManager::NotifyServiceCreated(const ServiceInstance& instance) { … }
void ServiceManager::NotifyServiceStarted(const Identity& identity,
base::ProcessId pid) { … }
void ServiceManager::NotifyServiceFailedToStart(const Identity& identity) { … }
void ServiceManager::NotifyServicePIDReceived(const Identity& identity,
base::ProcessId pid) { … }
ServiceInstance* ServiceManager::CreateServiceInstance(
const Identity& identity,
const Manifest& manifest) { … }
void ServiceManager::AddListener(
mojo::PendingRemote<mojom::ServiceManagerListener> listener) { … }
void ServiceManager::OnBindInterface(
const BindSourceInfo& source_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle receiving_pipe) { … }
}