Commit 48e1890c authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Clean up unused Service Manager code

There's a bunch of stuff here to support non-Content processes like a
standalone Service Manager and Content-free service processes. None of
it is used in production anymore (since the end of mus+ash), so this CL
deletes all of it.

Bug: 977637
Change-Id: I93c9a54ccf39e5659d0aae2f495bc1c378ae5c4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410919Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#806854}
parent 8481860c
...@@ -268,7 +268,6 @@ void AdjustLinuxOOMScore(const std::string& process_type) { ...@@ -268,7 +268,6 @@ void AdjustLinuxOOMScore(const std::string& process_type) {
} else if (process_type == switches::kUtilityProcess || } else if (process_type == switches::kUtilityProcess ||
process_type == switches::kGpuProcess || process_type == switches::kGpuProcess ||
process_type == switches::kCloudPrintServiceProcess || process_type == switches::kCloudPrintServiceProcess ||
process_type == service_manager::switches::kProcessTypeService ||
process_type == switches::kPpapiBrokerProcess) { process_type == switches::kPpapiBrokerProcess) {
score = content::kMiscOomScore; score = content::kMiscOomScore;
#if BUILDFLAG(ENABLE_NACL) #if BUILDFLAG(ENABLE_NACL)
...@@ -277,8 +276,6 @@ void AdjustLinuxOOMScore(const std::string& process_type) { ...@@ -277,8 +276,6 @@ void AdjustLinuxOOMScore(const std::string& process_type) {
score = content::kPluginOomScore; score = content::kPluginOomScore;
#endif #endif
} else if (process_type == service_manager::switches::kZygoteProcess || } else if (process_type == service_manager::switches::kZygoteProcess ||
process_type ==
service_manager::switches::kProcessTypeServiceManager ||
process_type.empty()) { process_type.empty()) {
// For zygotes and unlabeled process types, we want to still make // For zygotes and unlabeled process types, we want to still make
// them killable by the OOM killer. // them killable by the OOM killer.
...@@ -1238,16 +1235,6 @@ ChromeMainDelegate::CreateContentUtilityClient() { ...@@ -1238,16 +1235,6 @@ ChromeMainDelegate::CreateContentUtilityClient() {
return g_chrome_content_utility_client.Pointer(); return g_chrome_content_utility_client.Pointer();
} }
service_manager::ProcessType ChromeMainDelegate::OverrideProcessType() {
const auto& command_line = *base::CommandLine::ForCurrentProcess();
if (command_line.GetSwitchValueASCII(switches::kProcessType) ==
service_manager::switches::kProcessTypeService) {
// Don't mess with embedded service command lines.
return service_manager::ProcessType::kDefault;
}
return service_manager::ProcessType::kDefault;
}
void ChromeMainDelegate::PreCreateMainMessageLoop() { void ChromeMainDelegate::PreCreateMainMessageLoop() {
#if defined(OS_MAC) #if defined(OS_MAC)
// Tell Cocoa to finish its initialization, which we want to do manually // Tell Cocoa to finish its initialization, which we want to do manually
......
...@@ -58,7 +58,6 @@ class ChromeMainDelegate : public content::ContentMainDelegate { ...@@ -58,7 +58,6 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
delegates) override; delegates) override;
void ZygoteForked() override; void ZygoteForked() override;
#endif #endif
service_manager::ProcessType OverrideProcessType() override;
void PreCreateMainMessageLoop() override; void PreCreateMainMessageLoop() override;
void PostEarlyInitialization(bool is_running_tests) override; void PostEarlyInitialization(bool is_running_tests) override;
bool ShouldCreateFeatureList() override; bool ShouldCreateFeatureList() override;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "content/common/mojo_core_library_support.h" #include "content/common/mojo_core_library_support.h"
#include "content/public/app/content_main_delegate.h" #include "content/public/app/content_main_delegate.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/common/service_names.mojom.h"
#include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/platform/platform_channel.h" #include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/system/dynamic_library_support.h" #include "mojo/public/cpp/system/dynamic_library_support.h"
...@@ -66,11 +65,6 @@ void ContentServiceManagerMainDelegate::ShutDownEmbedderProcess() { ...@@ -66,11 +65,6 @@ void ContentServiceManagerMainDelegate::ShutDownEmbedderProcess() {
#endif #endif
} }
service_manager::ProcessType
ContentServiceManagerMainDelegate::OverrideProcessType() {
return content_main_params_.delegate->OverrideProcessType();
}
void ContentServiceManagerMainDelegate::InitializeMojo( void ContentServiceManagerMainDelegate::InitializeMojo(
mojo::core::Configuration* config) { mojo::core::Configuration* config) {
// If this is the browser process and there's no Mojo invitation pipe on the // If this is the browser process and there's no Mojo invitation pipe on the
...@@ -117,58 +111,6 @@ void ContentServiceManagerMainDelegate::InitializeMojo( ...@@ -117,58 +111,6 @@ void ContentServiceManagerMainDelegate::InitializeMojo(
CHECK_EQ(MOJO_RESULT_OK, result); CHECK_EQ(MOJO_RESULT_OK, result);
} }
std::vector<service_manager::Manifest>
ContentServiceManagerMainDelegate::GetServiceManifests() {
return std::vector<service_manager::Manifest>();
}
bool ContentServiceManagerMainDelegate::ShouldLaunchAsServiceProcess(
const service_manager::Identity& identity) {
return identity.name() != mojom::kPackagedServicesServiceName;
}
void ContentServiceManagerMainDelegate::AdjustServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {
base::CommandLine::StringVector args_without_switches;
if (identity.name() == mojom::kPackagedServicesServiceName) {
// Ensure other arguments like URL are not lost.
args_without_switches = command_line->GetArgs();
// When launching the browser process, ensure that we don't inherit any
// process type flag. When content embeds Service Manager, a process with no
// type is launched as a browser process.
base::CommandLine::SwitchMap switches = command_line->GetSwitches();
switches.erase(switches::kProcessType);
*command_line = base::CommandLine(command_line->GetProgram());
for (const auto& sw : switches)
command_line->AppendSwitchNative(sw.first, sw.second);
}
content_main_params_.delegate->AdjustServiceProcessCommandLine(identity,
command_line);
// Append other arguments back to |command_line| after the second call to
// delegate as long as it can still remove all the arguments without switches.
for (const auto& arg : args_without_switches)
command_line->AppendArgNative(arg);
}
void ContentServiceManagerMainDelegate::OnServiceManagerInitialized(
base::OnceClosure quit_closure,
service_manager::BackgroundServiceManager* service_manager) {
return content_main_params_.delegate->OnServiceManagerInitialized(
std::move(quit_closure), service_manager);
}
std::unique_ptr<service_manager::Service>
ContentServiceManagerMainDelegate::CreateEmbeddedService(
const std::string& service_name) {
// TODO
return nullptr;
}
void ContentServiceManagerMainDelegate::SetStartServiceManagerOnly( void ContentServiceManagerMainDelegate::SetStartServiceManagerOnly(
bool start_service_manager_only) { bool start_service_manager_only) {
start_service_manager_only_ = start_service_manager_only; start_service_manager_only_ = start_service_manager_only;
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/single_thread_task_runner.h"
#include "build/build_config.h"
#include "content/public/app/content_main.h" #include "content/public/app/content_main.h"
#include "services/service_manager/embedder/main_delegate.h" #include "services/service_manager/embedder/main_delegate.h"
...@@ -28,19 +25,7 @@ class ContentServiceManagerMainDelegate : public service_manager::MainDelegate { ...@@ -28,19 +25,7 @@ class ContentServiceManagerMainDelegate : public service_manager::MainDelegate {
bool IsEmbedderSubprocess() override; bool IsEmbedderSubprocess() override;
int RunEmbedderProcess() override; int RunEmbedderProcess() override;
void ShutDownEmbedderProcess() override; void ShutDownEmbedderProcess() override;
service_manager::ProcessType OverrideProcessType() override;
void InitializeMojo(mojo::core::Configuration* config) override; void InitializeMojo(mojo::core::Configuration* config) override;
std::vector<service_manager::Manifest> GetServiceManifests() override;
bool ShouldLaunchAsServiceProcess(
const service_manager::Identity& identity) override;
void AdjustServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) override;
void OnServiceManagerInitialized(
base::OnceClosure quit_closure,
service_manager::BackgroundServiceManager* service_manager) override;
std::unique_ptr<service_manager::Service> CreateEmbeddedService(
const std::string& service_name) override;
// Sets the flag whether to start the Service Manager without starting the // Sets the flag whether to start the Service Manager without starting the
// full browser. // full browser.
......
...@@ -36,18 +36,6 @@ int ContentMainDelegate::TerminateForFatalInitializationError() { ...@@ -36,18 +36,6 @@ int ContentMainDelegate::TerminateForFatalInitializationError() {
return 0; return 0;
} }
service_manager::ProcessType ContentMainDelegate::OverrideProcessType() {
return service_manager::ProcessType::kDefault;
}
void ContentMainDelegate::AdjustServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {}
void ContentMainDelegate::OnServiceManagerInitialized(
base::OnceClosure quit_closure,
service_manager::BackgroundServiceManager* service_manager) {}
bool ContentMainDelegate::ShouldCreateFeatureList() { bool ContentMainDelegate::ShouldCreateFeatureList() {
return true; return true;
} }
......
...@@ -9,19 +9,8 @@ ...@@ -9,19 +9,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/callback_forward.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "services/service_manager/embedder/process_type.h"
namespace base {
class CommandLine;
}
namespace service_manager {
class BackgroundServiceManager;
class Identity;
} // namespace service_manager
namespace content { namespace content {
...@@ -76,25 +65,6 @@ class CONTENT_EXPORT ContentMainDelegate { ...@@ -76,25 +65,6 @@ class CONTENT_EXPORT ContentMainDelegate {
// returning initialization error code. Default behavior is CHECK(false). // returning initialization error code. Default behavior is CHECK(false).
virtual int TerminateForFatalInitializationError(); virtual int TerminateForFatalInitializationError();
// Overrides the Service Manager process type to use for the currently running
// process.
virtual service_manager::ProcessType OverrideProcessType();
// Allows the content embedder to adjust arbitrary command line arguments for
// any service process started by the Service Manager.
virtual void AdjustServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line);
// Allows the embedder to perform arbitrary initialization within the Service
// Manager process immediately before the Service Manager runs its main loop.
//
// |quit_closure| is a callback the embedder may retain and invoke at any time
// to cleanly terminate Service Manager execution.
virtual void OnServiceManagerInitialized(
base::OnceClosure quit_closure,
service_manager::BackgroundServiceManager* service_manager);
// Allows the embedder to perform platform-specific initialization before // Allows the embedder to perform platform-specific initialization before
// creating the main message loop. // creating the main message loop.
virtual void PreCreateMainMessageLoop() {} virtual void PreCreateMainMessageLoop() {}
......
...@@ -12,7 +12,6 @@ if (!is_ios) { ...@@ -12,7 +12,6 @@ if (!is_ios) {
public = [ public = [
"main.h", "main.h",
"main_delegate.h", "main_delegate.h",
"process_type.h",
"set_process_title.h", "set_process_title.h",
"shared_file_util.h", "shared_file_util.h",
] ]
......
...@@ -35,13 +35,9 @@ ...@@ -35,13 +35,9 @@
#include "mojo/public/cpp/base/shared_memory_utils.h" #include "mojo/public/cpp/base/shared_memory_utils.h"
#include "sandbox/policy/sandbox_type.h" #include "sandbox/policy/sandbox_type.h"
#include "services/service_manager/embedder/main_delegate.h" #include "services/service_manager/embedder/main_delegate.h"
#include "services/service_manager/embedder/process_type.h"
#include "services/service_manager/embedder/set_process_title.h" #include "services/service_manager/embedder/set_process_title.h"
#include "services/service_manager/embedder/shared_file_util.h" #include "services/service_manager/embedder/shared_file_util.h"
#include "services/service_manager/embedder/switches.h" #include "services/service_manager/embedder/switches.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_executable/service_executable_environment.h"
#include "services/service_manager/public/cpp/service_executable/switches.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
...@@ -150,100 +146,6 @@ void CommonSubprocessInit() { ...@@ -150,100 +146,6 @@ void CommonSubprocessInit() {
#endif #endif
} }
void NonEmbedderProcessInit() {
logging::LoggingSettings settings;
settings.logging_dest =
logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
logging::InitLogging(settings);
// To view log output with IDs and timestamps use "adb logcat -v threadtime".
logging::SetLogItems(true, // Process ID
true, // Thread ID
true, // Timestamp
true); // Tick count
#if !defined(OFFICIAL_BUILD)
// Initialize stack dumping before initializing sandbox to make sure symbol
// names in all loaded libraries will be cached.
// NOTE: On Chrome OS, crash reporting for the root process and non-browser
// service processes is handled by the OS-level crash_reporter.
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableInProcessStackTraces)) {
base::debug::EnableInProcessStackDumping();
}
#endif
base::ThreadPoolInstance::CreateAndStartWithDefaultParams(
"ServiceManagerProcess");
}
int RunServiceManager(MainDelegate* delegate) {
NonEmbedderProcessInit();
base::SingleThreadTaskExecutor main_thread_task_executor(
base::MessagePumpType::UI);
base::Thread ipc_thread("IPC thread");
ipc_thread.StartWithOptions(
base::Thread::Options(base::MessagePumpType::IO, 0));
mojo::core::ScopedIPCSupport ipc_support(
ipc_thread.task_runner(),
mojo::core::ScopedIPCSupport::ShutdownPolicy::FAST);
service_manager::BackgroundServiceManager background_service_manager(
delegate->GetServiceManifests());
base::RunLoop run_loop;
delegate->OnServiceManagerInitialized(run_loop.QuitClosure(),
&background_service_manager);
run_loop.Run();
ipc_thread.Stop();
base::ThreadPoolInstance::Get()->Shutdown();
return 0;
}
void InitializeResources() {
const std::string locale =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
::switches::kLang);
// This loads the embedder's common resources (e.g. chrome_100_percent.pak for
// Chrome.)
ui::ResourceBundle::InitSharedInstanceWithLocale(
locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
}
int RunService(MainDelegate* delegate) {
NonEmbedderProcessInit();
InitializeResources();
service_manager::ServiceExecutableEnvironment environment;
base::SingleThreadTaskExecutor main_thread_task_executor(
base::MessagePumpType::UI);
base::RunLoop run_loop;
std::string service_name =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kServiceName);
if (service_name.empty()) {
LOG(ERROR) << "Service process requires --service-name";
return 1;
}
std::unique_ptr<Service> service =
delegate->CreateEmbeddedService(service_name);
if (!service) {
LOG(ERROR) << "Failed to start embedded service: " << service_name;
return 1;
}
service->set_termination_closure(run_loop.QuitClosure());
run_loop.Run();
return 0;
}
} // namespace } // namespace
MainParams::MainParams(MainDelegate* delegate) : delegate(delegate) {} MainParams::MainParams(MainDelegate* delegate) : delegate(delegate) {}
...@@ -256,7 +158,6 @@ int Main(const MainParams& params) { ...@@ -256,7 +158,6 @@ int Main(const MainParams& params) {
int exit_code = -1; int exit_code = -1;
base::debug::GlobalActivityTracker* tracker = nullptr; base::debug::GlobalActivityTracker* tracker = nullptr;
ProcessType process_type = delegate->OverrideProcessType();
#if defined(OS_MAC) #if defined(OS_MAC)
std::unique_ptr<base::mac::ScopedNSAutoreleasePool> autorelease_pool; std::unique_ptr<base::mac::ScopedNSAutoreleasePool> autorelease_pool;
#endif #endif
...@@ -336,10 +237,8 @@ int Main(const MainParams& params) { ...@@ -336,10 +237,8 @@ int Main(const MainParams& params) {
SetupSignalHandlers(); SetupSignalHandlers();
#endif #endif
const auto& command_line = *base::CommandLine::ForCurrentProcess();
#if defined(OS_WIN) #if defined(OS_WIN)
base::win::SetupCRT(command_line); base::win::SetupCRT(*base::CommandLine::ForCurrentProcess());
#endif #endif
MainDelegate::InitializeParams init_params; MainDelegate::InitializeParams init_params;
...@@ -355,11 +254,6 @@ int Main(const MainParams& params) { ...@@ -355,11 +254,6 @@ int Main(const MainParams& params) {
#endif #endif
mojo::core::Configuration mojo_config; mojo::core::Configuration mojo_config;
if (process_type == ProcessType::kDefault &&
command_line.GetSwitchValueASCII(switches::kProcessType) ==
switches::kProcessTypeServiceManager) {
mojo_config.is_broker_process = true;
}
mojo_config.max_message_num_bytes = kMaximumMojoMessageSize; mojo_config.max_message_num_bytes = kMaximumMojoMessageSize;
delegate->InitializeMojo(&mojo_config); delegate->InitializeMojo(&mojo_config);
...@@ -388,7 +282,8 @@ int Main(const MainParams& params) { ...@@ -388,7 +282,8 @@ int Main(const MainParams& params) {
// implementation of mojo::NodeController::CreateSharedBuffer(). // implementation of mojo::NodeController::CreateSharedBuffer().
#if !defined(OS_MAC) && !defined(OS_NACL_SFI) && !defined(OS_FUCHSIA) #if !defined(OS_MAC) && !defined(OS_NACL_SFI) && !defined(OS_FUCHSIA)
if (sandbox::policy::IsUnsandboxedSandboxType( if (sandbox::policy::IsUnsandboxedSandboxType(
sandbox::policy::SandboxTypeFromCommandLine(command_line))) { sandbox::policy::SandboxTypeFromCommandLine(
*base::CommandLine::ForCurrentProcess()))) {
// Unsandboxed processes don't need shared memory brokering... because // Unsandboxed processes don't need shared memory brokering... because
// they're not sandboxed. // they're not sandboxed.
} else if (mojo_config.force_direct_shared_memory_allocation) { } else if (mojo_config.force_direct_shared_memory_allocation) {
...@@ -421,38 +316,9 @@ int Main(const MainParams& params) { ...@@ -421,38 +316,9 @@ int Main(const MainParams& params) {
} }
} }
const auto& command_line = *base::CommandLine::ForCurrentProcess(); if (delegate->IsEmbedderSubprocess())
if (process_type == ProcessType::kDefault) { CommonSubprocessInit();
std::string type_switch = exit_code = delegate->RunEmbedderProcess();
command_line.GetSwitchValueASCII(switches::kProcessType);
if (type_switch == switches::kProcessTypeServiceManager) {
process_type = ProcessType::kServiceManager;
} else if (type_switch == switches::kProcessTypeService) {
process_type = ProcessType::kService;
} else {
process_type = ProcessType::kEmbedder;
}
}
switch (process_type) {
case ProcessType::kDefault:
NOTREACHED();
break;
case ProcessType::kServiceManager:
exit_code = RunServiceManager(delegate);
break;
case ProcessType::kService:
CommonSubprocessInit();
exit_code = RunService(delegate);
break;
case ProcessType::kEmbedder:
if (delegate->IsEmbedderSubprocess())
CommonSubprocessInit();
exit_code = delegate->RunEmbedderProcess();
break;
}
if (tracker) { if (tracker) {
if (exit_code == 0) { if (exit_code == 0) {
...@@ -469,8 +335,7 @@ int Main(const MainParams& params) { ...@@ -469,8 +335,7 @@ int Main(const MainParams& params) {
autorelease_pool.reset(); autorelease_pool.reset();
#endif #endif
if (process_type == ProcessType::kEmbedder) delegate->ShutDownEmbedderProcess();
delegate->ShutDownEmbedderProcess();
return exit_code; return exit_code;
} }
......
...@@ -20,31 +20,6 @@ int MainDelegate::RunEmbedderProcess() { ...@@ -20,31 +20,6 @@ int MainDelegate::RunEmbedderProcess() {
void MainDelegate::ShutDownEmbedderProcess() {} void MainDelegate::ShutDownEmbedderProcess() {}
ProcessType MainDelegate::OverrideProcessType() {
return ProcessType::kDefault;
}
void MainDelegate::InitializeMojo(mojo::core::Configuration* config) {} void MainDelegate::InitializeMojo(mojo::core::Configuration* config) {}
std::vector<Manifest> MainDelegate::GetServiceManifests() {
return std::vector<Manifest>();
}
bool MainDelegate::ShouldLaunchAsServiceProcess(const Identity& identity) {
return true;
}
void MainDelegate::AdjustServiceProcessCommandLine(
const Identity& identity,
base::CommandLine* command_line) {}
void MainDelegate::OnServiceManagerInitialized(
base::OnceClosure quit_closure,
BackgroundServiceManager* service_manager) {}
std::unique_ptr<Service> MainDelegate::CreateEmbeddedService(
const std::string& service_name) {
return nullptr;
}
} // namespace service_manager } // namespace service_manager
...@@ -5,23 +5,10 @@ ...@@ -5,23 +5,10 @@
#ifndef SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_ #ifndef SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_
#define SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_ #define SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_
#include <memory>
#include <vector>
#include "base/callback_forward.h"
#include "base/component_export.h" #include "base/component_export.h"
#include "base/memory/scoped_refptr.h"
#include "base/single_thread_task_runner.h"
#include "mojo/core/embedder/configuration.h" #include "mojo/core/embedder/configuration.h"
#include "services/service_manager/background_service_manager.h"
#include "services/service_manager/embedder/process_type.h"
#include "services/service_manager/public/cpp/identity.h"
#include "services/service_manager/public/cpp/manifest.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/mojom/service.mojom.h"
namespace base { namespace base {
class CommandLine;
namespace mac { namespace mac {
class ScopedNSAutoreleasePool; class ScopedNSAutoreleasePool;
} }
...@@ -67,43 +54,9 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER) MainDelegate { ...@@ -67,43 +54,9 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER) MainDelegate {
// Called just before process exit if RunEmbedderProcess() was called. // Called just before process exit if RunEmbedderProcess() was called.
virtual void ShutDownEmbedderProcess(); virtual void ShutDownEmbedderProcess();
// Force execution of the current process as a specific process type. May
// return |ProcessType::kDefault| to avoid overriding.
virtual ProcessType OverrideProcessType();
// Allows the embedder to override the process-wide Mojo configuration and // Allows the embedder to override the process-wide Mojo configuration and
// initialization. // initialization.
virtual void InitializeMojo(mojo::core::Configuration* config); virtual void InitializeMojo(mojo::core::Configuration* config);
// Gets the list of service manifests with which to initialize the Service
// Manager. This list must describe the complete set of usable services in
// the system and remains fixed for the lifetime of the Service Manager.
virtual std::vector<Manifest> GetServiceManifests();
// Indicates whether a process started by the service manager for a given
// target service identity should be run as a real service process (|true|)
// or if the service manager should delegate to the embedder to initialize the
// new process (|false|).
virtual bool ShouldLaunchAsServiceProcess(const Identity& identity);
// Allows the embedder to override command line switches for a service process
// to be launched.
virtual void AdjustServiceProcessCommandLine(const Identity& identity,
base::CommandLine* command_line);
// Allows the embedder to perform arbitrary initialization within the Service
// Manager process immediately before the Service Manager runs its main loop.
//
// |quit_closure| is a callback the embedder may retain and invoke at any time
// to cleanly terminate Service Manager execution.
virtual void OnServiceManagerInitialized(
base::OnceClosure quit_closure,
BackgroundServiceManager* service_manager);
// Runs an embedded service by name. If the embedder does not know how to
// create an instance of the named service, it should return null.
virtual std::unique_ptr<Service> CreateEmbeddedService(
const std::string& service_name);
}; };
} // namespace service_manager } // namespace service_manager
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_SERVICE_MANAGER_EMBEDDER_PROCESS_TYPE_H_
#define SERVICES_SERVICE_MANAGER_EMBEDDER_PROCESS_TYPE_H_
namespace service_manager {
enum class ProcessType {
// An unspecified process type. If this is given anywhere a ProcessType is
// expected, it must be interpreted as some reasonable default based on
// context.
kDefault,
// A standalone Service Manager process. There can be only one.
kServiceManager,
// A service process. A service process hosts one or more embedded service
// instances.
kService,
// An embedder process. The Service Manager implementation does not control
// any aspect of the process's logic beyond primitive process initialization
// and shutdown.
kEmbedder,
};
} // namespace service_manager
#endif // SERVICES_SERVICE_MANAGER_EMBEDDER_PROCESS_TYPE_H_
...@@ -35,14 +35,6 @@ const char kEnableLogging[] = "enable-logging"; ...@@ -35,14 +35,6 @@ const char kEnableLogging[] = "enable-logging";
// "service-runner", or any other arbitrary value supported by the embedder. // "service-runner", or any other arbitrary value supported by the embedder.
const char kProcessType[] = "type"; const char kProcessType[] = "type";
// The value of the |kProcessType| switch which tells the executable to assume
// the role of a standalone Service Manager instance.
const char kProcessTypeServiceManager[] = "service-manager";
// The value of the |kProcessType| switch which tells the executable to assume
// the role of a service instance.
const char kProcessTypeService[] = "service-runner";
// The token to use to construct the message pipe for a service in a child // The token to use to construct the message pipe for a service in a child
// process. // process.
const char kServiceRequestChannelToken[] = "service-request-channel-token"; const char kServiceRequestChannelToken[] = "service-request-channel-token";
......
...@@ -25,12 +25,6 @@ extern const char kEnableLogging[]; ...@@ -25,12 +25,6 @@ extern const char kEnableLogging[];
COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER_SWITCHES) COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER_SWITCHES)
extern const char kProcessType[]; extern const char kProcessType[];
COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER_SWITCHES)
extern const char kProcessTypeServiceManager[];
COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER_SWITCHES)
extern const char kProcessTypeService[];
COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER_SWITCHES) COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER_SWITCHES)
extern const char kServiceRequestChannelToken[]; extern const char kServiceRequestChannelToken[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment