From 35f7133120bbe69c2f68512d3d3d82c6a39ba35e Mon Sep 17 00:00:00 2001 From: Matt Giuca Date: Tue, 1 May 2018 05:28:23 +0000 Subject: [PATCH] Revert "Move zygote code to service_manager" This reverts commit dbe3973e8ff5eb249dd35474b69f9316c15ca1f0. Reason for revert: Broke compile on LKGR and local builds. See https://crbug.com/838498. Original change's description: > Move zygote code to service_manager > > This CL moves the zygote code from content/ to > services/service_manager/zygote. This involves moving some switches from > content_switches.h to services/service_manager/embedder/switches.h and > moving some codes from content/public/common/result_codes.h to the new > services/service_manager/embedder/result_codes.h. > > Bug: 831846 > Change-Id: I9776a30412ea43c2c7f511967d2b7d05f18aa841 > Reviewed-on: https://chromium-review.googlesource.com/1012194 > Reviewed-by: Avi Drissman > Reviewed-by: Scott Violet > Reviewed-by: Scott Graham > Reviewed-by: Ken Rockot > Reviewed-by: Stephen Lanham > Reviewed-by: Eric Seckler > Reviewed-by: Robert Sesek > Commit-Queue: Jay Civelli > Cr-Commit-Position: refs/heads/master@{#554902} TBR=avi@chromium.org,sky@chromium.org,dschuff@chromium.org,jcivelli@chromium.org,rockot@chromium.org,slan@chromium.org,scottmg@chromium.org,rsesek@chromium.org,eseckler@chromium.org Change-Id: I318b3d8d74520b1fa7eda3d6d612d54e9dc2f040 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 831846, 838498 Reviewed-on: https://chromium-review.googlesource.com/1036706 Commit-Queue: Matt Giuca Reviewed-by: Matt Giuca Cr-Commit-Position: refs/heads/master@{#555001} --- .../browser/aw_browser_main_parts.cc | 4 +- apps/DEPS | 1 - chrome/DEPS | 3 - chrome/android/java/DEPS | 1 + chrome/android/javatests/DEPS | 2 + chrome/app/DEPS | 1 + chrome/app/chrome_crash_reporter_client.cc | 3 +- chrome/app/chrome_main_delegate.cc | 13 ++- chrome/app/chrome_main_delegate.h | 5 +- chrome/browser/DEPS | 1 + chrome/browser/chrome_browser_main.cc | 30 +++--- chrome/browser/chrome_browser_main_posix.cc | 4 +- chrome/browser/chrome_browser_main_win.cc | 2 +- .../browser/chrome_content_browser_client.cc | 5 +- chrome/browser/memory_details.cc | 4 +- .../tab_manager_delegate_chromeos.cc | 2 +- chrome/browser/ui/uninstall_browser_prompt.h | 2 +- chrome/browser/ui/views/uninstall_view.cc | 4 +- .../browser/ui/webui/sandbox_internals_ui.cc | 4 +- chrome/common/DEPS | 2 + chrome/common/thread_profiler.cc | 3 +- chrome/gpu/DEPS | 1 + chrome/installer/setup/uninstall.cc | 2 +- chrome/renderer/DEPS | 1 + .../pepper/pepper_flash_font_file_host.cc | 2 +- chrome/service/DEPS | 1 + .../service/service_utility_process_host.cc | 9 +- chrome/utility/DEPS | 7 ++ .../firefox_importer_unittest_utils_mac.cc | 9 +- chromecast/app/DEPS | 1 - chromecast/app/android/DEPS | 1 - chromecast/app/android/crash_handler.cc | 3 +- chromecast/app/cast_main_delegate.cc | 3 +- .../app/linux/cast_crash_reporter_client.cc | 3 +- chromecast/browser/DEPS | 1 - .../browser/cast_content_browser_client.cc | 3 +- .../crash/content/app/breakpad_linux.cc | 3 +- .../crash/content/app/crashpad_linux.cc | 3 +- components/nacl/DEPS | 2 +- components/nacl/broker/BUILD.gn | 10 +- .../nacl/broker/nacl_broker_listener.cc | 5 +- components/nacl/browser/BUILD.gn | 3 +- .../nacl/browser/nacl_broker_host_win.cc | 1 + components/nacl/browser/nacl_process_host.cc | 9 +- components/nacl/common/BUILD.gn | 1 + components/nacl/common/nacl_service.cc | 11 +-- components/nacl/loader/BUILD.gn | 6 -- components/nacl/loader/nacl_helper_linux.cc | 30 +++--- components/nacl/loader/nacl_listener.cc | 5 +- .../nacl/loader/nonsfi/nonsfi_listener.cc | 1 + .../nacl/zygote/nacl_fork_delegate_linux.cc | 7 +- .../nacl/zygote/nacl_fork_delegate_linux.h | 17 ++-- content/BUILD.gn | 3 + content/DEPS | 1 - content/app/content_main_runner.cc | 65 ++++++------- .../content_service_manager_main_delegate.cc | 4 +- content/browser/BUILD.gn | 21 +++-- .../browser_child_process_host_impl.cc | 6 +- content/browser/browser_main_loop.cc | 8 +- content/browser/child_process_launcher.cc | 2 +- .../browser/child_process_launcher_helper.h | 6 +- .../child_process_launcher_helper_fuchsia.cc | 3 +- .../child_process_launcher_helper_linux.cc | 17 ++-- .../child_process_launcher_helper_mac.cc | 3 +- .../child_process_launcher_helper_posix.cc | 5 +- .../child_process_launcher_helper_win.cc | 3 +- content/browser/gpu/gpu_process_host.cc | 1 + content/browser/ppapi_plugin_process_host.cc | 9 +- .../pepper/pepper_truetype_font_linux.cc | 27 +++--- .../renderer_host/render_process_host_impl.cc | 14 +-- content/browser/utility_process_host.cc | 9 +- .../zygote_communication_linux.cc | 21 +++-- .../zygote_host}/zygote_communication_linux.h | 16 ++-- .../zygote_host}/zygote_handle_linux.cc | 8 +- .../zygote_host}/zygote_host_impl_linux.cc | 15 ++- .../zygote_host}/zygote_host_impl_linux.h | 19 ++-- content/child/BUILD.gn | 4 - ...hild_process_sandbox_support_impl_linux.cc | 11 +-- content/child/child_thread_impl.cc | 9 +- content/common/BUILD.gn | 4 +- .../common/common_sandbox_support_linux.cc | 28 +++++- .../common/send_zygote_child_ping_linux.cc | 11 ++- .../common/zygote_commands_linux.h | 10 +- content/gpu/BUILD.gn | 4 - content/gpu/gpu_main.cc | 5 +- content/public/android/BUILD.gn | 1 + content/public/app/content_main_delegate.cc | 3 +- content/public/app/content_main_delegate.h | 5 +- content/public/browser/BUILD.gn | 2 +- content/public/browser/browser_main_parts.cc | 4 +- .../browser/child_process_termination_info.h | 2 +- .../public/browser}/zygote_host_linux.h | 14 +-- content/public/common/BUILD.gn | 27 ++++-- .../common/common_sandbox_support_linux.h | 16 +++- content/public/common/content_descriptors.h | 9 +- content/public/common/content_switches.cc | 6 ++ content/public/common/content_switches.h | 2 + .../public/common/mojo_channel_switches.cc | 13 +++ content/public/common/mojo_channel_switches.h | 16 ++++ content/public/common/result_codes.h | 7 +- .../sandboxed_process_launcher_delegate.cc | 8 +- .../sandboxed_process_launcher_delegate.h | 6 +- .../common/send_zygote_child_ping_linux.h | 18 ++++ .../public}/common/zygote_features.gni | 0 .../common/zygote_fork_delegate_linux.h | 19 ++-- .../public}/common/zygote_handle.h | 20 ++-- content/renderer/BUILD.gn | 4 - content/renderer/renderer_main.cc | 5 +- content/shell/BUILD.gn | 1 - content/shell/DEPS | 3 - .../shell/app/shell_crash_reporter_client.cc | 3 +- content/shell/app/shell_main_delegate.cc | 3 +- .../shell/browser/shell_browser_main_parts.cc | 4 +- .../browser/shell_content_browser_client.cc | 2 +- content/zygote/OWNERS | 8 +- content/zygote/zygote_browsertest.cc | 1 - .../zygote/zygote_linux.cc | 91 ++++++++++--------- .../zygote/zygote_linux.h | 24 ++--- .../zygote/zygote_main.h | 13 +-- .../zygote/zygote_main_linux.cc | 33 ++++--- extensions/shell/app/DEPS | 1 - .../shell/app/shell_crash_reporter_client.cc | 3 +- extensions/shell/app/shell_main_delegate.cc | 9 +- extensions/shell/app/shell_main_delegate.h | 5 +- .../shell/browser/shell_browser_main_parts.cc | 4 +- headless/DEPS | 1 - .../headless_content_browser_client.cc | 2 +- .../lib/headless_content_main_delegate.cc | 3 +- .../lib/headless_crash_reporter_client.cc | 3 +- services/service_manager/embedder/BUILD.gn | 14 +-- .../service_manager/embedder/descriptors.h | 25 ----- .../service_manager/embedder/result_codes.h | 26 ------ services/service_manager/embedder/switches.cc | 12 +-- services/service_manager/embedder/switches.h | 4 - services/service_manager/zygote/BUILD.gn | 82 ----------------- services/service_manager/zygote/DEPS | 3 - services/service_manager/zygote/OWNERS | 7 -- .../common/common_sandbox_support_linux.cc | 37 -------- .../common/common_sandbox_support_linux.h | 33 ------- .../common/send_zygote_child_ping_linux.h | 18 ---- tools/ipc_fuzzer/message_replay/DEPS | 3 +- .../message_replay/replay_process.cc | 16 ++-- tools/metrics/histograms/enums.xml | 2 +- 143 files changed, 577 insertions(+), 758 deletions(-) rename {services/service_manager/zygote/host => content/browser/zygote_host}/zygote_communication_linux.cc (95%) rename {services/service_manager/zygote/host => content/browser/zygote_host}/zygote_communication_linux.h (88%) rename {services/service_manager/zygote/host => content/browser/zygote_host}/zygote_handle_linux.cc (75%) rename {services/service_manager/zygote/host => content/browser/zygote_host}/zygote_host_impl_linux.cc (96%) rename {services/service_manager/zygote/host => content/browser/zygote_host}/zygote_host_impl_linux.h (77%) rename {services/service_manager/zygote => content}/common/send_zygote_child_ping_linux.cc (58%) rename {services/service_manager/zygote => content}/common/zygote_commands_linux.h (84%) rename {services/service_manager/zygote => content/public/browser}/zygote_host_linux.h (74%) create mode 100644 content/public/common/mojo_channel_switches.cc create mode 100644 content/public/common/mojo_channel_switches.h create mode 100644 content/public/common/send_zygote_child_ping_linux.h rename {services/service_manager/zygote => content/public}/common/zygote_features.gni (100%) rename {services/service_manager/zygote => content/public}/common/zygote_fork_delegate_linux.h (85%) rename {services/service_manager/zygote => content/public}/common/zygote_handle.h (71%) rename {services/service_manager => content}/zygote/zygote_linux.cc (89%) rename {services/service_manager => content}/zygote/zygote_linux.h (90%) rename {services/service_manager => content}/zygote/zygote_main.h (51%) rename {services/service_manager => content}/zygote/zygote_main_linux.cc (89%) delete mode 100644 services/service_manager/embedder/descriptors.h delete mode 100644 services/service_manager/embedder/result_codes.h delete mode 100644 services/service_manager/zygote/BUILD.gn delete mode 100644 services/service_manager/zygote/DEPS delete mode 100644 services/service_manager/zygote/OWNERS delete mode 100644 services/service_manager/zygote/common/common_sandbox_support_linux.cc delete mode 100644 services/service_manager/zygote/common/common_sandbox_support_linux.h delete mode 100644 services/service_manager/zygote/common/send_zygote_child_ping_linux.h diff --git a/android_webview/browser/aw_browser_main_parts.cc b/android_webview/browser/aw_browser_main_parts.cc index a007de0ae9ea17..8fe6fc8f3bbcd2 100644 --- a/android_webview/browser/aw_browser_main_parts.cc +++ b/android_webview/browser/aw_browser_main_parts.cc @@ -74,7 +74,7 @@ int AwBrowserMainParts::PreEarlyInitialization() { DCHECK(!main_message_loop_.get()); main_message_loop_.reset(new base::MessageLoopForUI); base::MessageLoopCurrentForUI::Get()->Start(); - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } int AwBrowserMainParts::PreCreateThreads() { @@ -130,7 +130,7 @@ int AwBrowserMainParts::PreCreateThreads() { aw_field_trial_creator_.SetUpFieldTrials(); } - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } void AwBrowserMainParts::PreMainMessageLoopRun() { diff --git a/apps/DEPS b/apps/DEPS index 217584899945ba..6f3803c8c7f7b1 100644 --- a/apps/DEPS +++ b/apps/DEPS @@ -8,7 +8,6 @@ include_rules = [ # app_shell may depend on apps, but not vice versa. "-extensions/shell", "+net/base", - "+services/service_manager", ] specific_include_rules = { diff --git a/chrome/DEPS b/chrome/DEPS index df51072ddcbc5b..bc128f44262ad1 100644 --- a/chrome/DEPS +++ b/chrome/DEPS @@ -33,9 +33,6 @@ include_rules = [ "-webkit", "-tools", - # Required for process launching. - "+services/service_manager", - # Allow inclusion of WebKit API files. "+third_party/blink/public/common", "+third_party/blink/public/platform", diff --git a/chrome/android/java/DEPS b/chrome/android/java/DEPS index a18aeec00f3d22..60ebb60b842df0 100644 --- a/chrome/android/java/DEPS +++ b/chrome/android/java/DEPS @@ -36,6 +36,7 @@ include_rules = [ "+device/gamepad/android/java", "+device/geolocation/android/java", + "+services/service_manager/public/java", ] specific_include_rules = { diff --git a/chrome/android/javatests/DEPS b/chrome/android/javatests/DEPS index f41e9c5fb2cb14..aa7d0e14404151 100644 --- a/chrome/android/javatests/DEPS +++ b/chrome/android/javatests/DEPS @@ -33,6 +33,8 @@ include_rules = [ "+device/geolocation/android/java", "+device/geolocation/android/javatests", + + "+services/service_manager/public/java", ] specific_include_rules = { diff --git a/chrome/app/DEPS b/chrome/app/DEPS index 71272b2ce8af30..13633b330abfc3 100644 --- a/chrome/app/DEPS +++ b/chrome/app/DEPS @@ -34,6 +34,7 @@ include_rules = [ "+native_client/src/trusted/service_runtime/osx", "+remoting/client/plugin", "+sandbox", + "+services/service_manager", "+services/ui/public", "+third_party/breakpad/breakpad", "+third_party/crashpad/crashpad", diff --git a/chrome/app/chrome_crash_reporter_client.cc b/chrome/app/chrome_crash_reporter_client.cc index 64a768ab02e736..c8b924da3c7b27 100644 --- a/chrome/app/chrome_crash_reporter_client.cc +++ b/chrome/app/chrome_crash_reporter_client.cc @@ -19,7 +19,6 @@ #include "chrome/installer/util/google_update_settings.h" #include "components/crash/core/common/crash_keys.h" #include "content/public/common/content_switches.h" -#include "services/service_manager/embedder/switches.h" #if defined(OS_POSIX) && !defined(OS_MACOSX) #include "components/upload_list/crash_upload_list.h" @@ -134,7 +133,7 @@ bool ChromeCrashReporterClient::EnableBreakpadForProcess( const std::string& process_type) { return process_type == switches::kRendererProcess || process_type == switches::kPpapiPluginProcess || - process_type == service_manager::switches::kZygoteProcess || + process_type == switches::kZygoteProcess || process_type == switches::kGpuProcess || process_type == switches::kUtilityProcess; } diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index 54fe25fc312972..3efa97c5c16bf4 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -272,7 +272,7 @@ void AdjustLinuxOOMScore(const std::string& process_type) { process_type == switches::kNaClLoaderNonSfiProcess) { score = kPluginScore; #endif - } else if (process_type == service_manager::switches::kZygoteProcess || + } else if (process_type == switches::kZygoteProcess || process_type == service_manager::switches::kProcessTypeServiceManager || process_type.empty()) { @@ -303,7 +303,7 @@ bool SubprocessNeedsResourceBundle(const std::string& process_type) { return #if defined(OS_LINUX) // The zygote process opens the resources for the renderers. - process_type == service_manager::switches::kZygoteProcess || + process_type == switches::kZygoteProcess || #endif #if defined(OS_MACOSX) // Mac needs them too for scrollbar related images and for sandbox @@ -820,13 +820,13 @@ void ChromeMainDelegate::PreSandboxStartup() { // browser process as a command line flag. #if !BUILDFLAG(ENABLE_NACL) DCHECK(command_line.HasSwitch(switches::kLang) || - process_type == service_manager::switches::kZygoteProcess || + process_type == switches::kZygoteProcess || process_type == switches::kGpuProcess || process_type == switches::kPpapiBrokerProcess || process_type == switches::kPpapiPluginProcess); #else DCHECK(command_line.HasSwitch(switches::kLang) || - process_type == service_manager::switches::kZygoteProcess || + process_type == switches::kZygoteProcess || process_type == switches::kGpuProcess || process_type == switches::kNaClLoaderProcess || process_type == switches::kPpapiBrokerProcess || @@ -895,7 +895,7 @@ void ChromeMainDelegate::PreSandboxStartup() { #if defined(OS_POSIX) && !defined(OS_MACOSX) // Zygote needs to call InitCrashReporter() in RunZygote(). - if (process_type != service_manager::switches::kZygoteProcess) { + if (process_type != switches::kZygoteProcess) { #if defined(OS_ANDROID) if (process_type.empty()) { breakpad::InitCrashReporter(process_type); @@ -1018,8 +1018,7 @@ bool ChromeMainDelegate::DelaySandboxInitialization( } #elif defined(OS_LINUX) void ChromeMainDelegate::ZygoteStarting( - std::vector>* - delegates) { + std::vector>* delegates) { #if defined(OS_CHROMEOS) chromeos::ReloadElfTextInHugePages(); #endif diff --git a/chrome/app/chrome_main_delegate.h b/chrome/app/chrome_main_delegate.h index 9e3ab1b93627c9..b957cf7bb14d8e 100644 --- a/chrome/app/chrome_main_delegate.h +++ b/chrome/app/chrome_main_delegate.h @@ -46,9 +46,8 @@ class ChromeMainDelegate : public content::ContentMainDelegate { bool ShouldSendMachPort(const std::string& process_type) override; bool DelaySandboxInitialization(const std::string& process_type) override; #elif defined(OS_LINUX) - void ZygoteStarting( - std::vector>* - delegates) override; + void ZygoteStarting(std::vector>* + delegates) override; void ZygoteForked() override; #endif bool ShouldEnableProfilerRecording() override; diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 2e82da1fa6eee7..bfc694f723ddb2 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -73,6 +73,7 @@ include_rules = [ "+services/proxy_resolver/public/mojom", "+services/resource_coordinator/public/cpp", "+services/resource_coordinator/public/mojom", + "+services/service_manager", "+services/shape_detection/public/mojom", "+services/ui/common", "+services/ui/public", diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index f32124d01ad265..8384d0843a2ab5 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -845,7 +845,7 @@ ChromeBrowserMainParts::ChromeBrowserMainParts( const content::MainFunctionParams& parameters) : parameters_(parameters), parsed_command_line_(parameters.command_line), - result_code_(service_manager::RESULT_CODE_NORMAL_EXIT), + result_code_(content::RESULT_CODE_NORMAL_EXIT), startup_watcher_(new StartupTimeBomb()), shutdown_watcher_(new ShutdownWatcherHelper()), ui_thread_profiler_(ThreadProfiler::CreateAndStartOnMainThread()), @@ -1075,7 +1075,7 @@ int ChromeBrowserMainParts::PreEarlyInitialization() { } // Continue on and show error later (once UI has been initialized and main // message loop is running). - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } return load_local_state_result; } @@ -1128,7 +1128,7 @@ int ChromeBrowserMainParts::PreCreateThreads() { TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); result_code_ = PreCreateThreadsImpl(); - if (result_code_ == service_manager::RESULT_CODE_NORMAL_EXIT) { + if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) { #if !defined(OS_ANDROID) // These members must be initialized before exiting this function normally. DCHECK(master_prefs_.get()); @@ -1171,7 +1171,7 @@ int ChromeBrowserMainParts::LoadLocalState( } const int apply_first_run_result = ApplyFirstRunPrefs(); - if (apply_first_run_result != service_manager::RESULT_CODE_NORMAL_EXIT) + if (apply_first_run_result != content::RESULT_CODE_NORMAL_EXIT) return apply_first_run_result; browser_process_->SetApplicationLocale(locale); @@ -1186,7 +1186,7 @@ int ChromeBrowserMainParts::LoadLocalState( // tasks. SetupFieldTrials(); - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } int ChromeBrowserMainParts::ApplyFirstRunPrefs() { @@ -1197,7 +1197,7 @@ int ChromeBrowserMainParts::ApplyFirstRunPrefs() { // browser's profile_manager object is created, but after ResourceBundle // is initialized. if (!first_run::IsChromeFirstRun()) - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; first_run::ProcessMasterPreferencesResult pmp_result = first_run::ProcessMasterPreferences(user_data_dir_, master_prefs_.get()); @@ -1239,7 +1239,7 @@ int ChromeBrowserMainParts::ApplyFirstRunPrefs() { local_state->SetBoolean(prefs::kWelcomePageOnOSUpgradeEnabled, false); #endif #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } int ChromeBrowserMainParts::PreCreateThreadsImpl() { @@ -1418,7 +1418,7 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { // which is used in SetupMetrics(). SetupMetrics(); - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } void ChromeBrowserMainParts::PostCreateThreads() { @@ -1631,7 +1631,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { } return shell_integration::SetAsDefaultBrowser() - ? static_cast(service_manager::RESULT_CODE_NORMAL_EXIT) + ? static_cast(content::RESULT_CODE_NORMAL_EXIT) : static_cast(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); } @@ -1647,7 +1647,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { if (parsed_command_line().HasSwitch(switches::kPackExtension)) { extensions::StartupHelper extension_startup_helper; if (extension_startup_helper.PackExtension(parsed_command_line())) - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; } @@ -1678,7 +1678,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { // expected. if (parsed_command_line().HasSwitch(switches::kTestType)) return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED; - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; case ProcessSingleton::PROFILE_IN_USE: return chrome::RESULT_CODE_PROFILE_IN_USE; @@ -1738,7 +1738,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { } #else // We don't support retention experiments on Mac or Linux. - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; #endif // defined(OS_WIN) } #endif // !defined(OS_ANDROID) @@ -1746,7 +1746,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { #if defined(OS_WIN) // Do the tasks if chrome has been upgraded while it was last running. if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; // Check if there is any machine level Chrome installed on the current // machine. If yes and the current Chrome process is user level, we do not @@ -1776,7 +1776,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { user_data_dir_, parsed_command_line()); if (!profile_) - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; #if !defined(OS_ANDROID) const base::TimeTicks start_time_step2 = base::TimeTicks::Now(); @@ -1830,7 +1830,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { // The first run dialog is modal, and spins a RunLoop, which could receive // a SIGTERM, and call chrome::AttemptExit(). Exit cleanly in that case. if (browser_shutdown::IsTryingToQuit()) - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; if (!master_prefs_->suppress_first_run_default_browser_prompt) { browser_creator_->set_show_main_browser_window( diff --git a/chrome/browser/chrome_browser_main_posix.cc b/chrome/browser/chrome_browser_main_posix.cc index 2a5439db3fbc27..c9195fb478c3e1 100644 --- a/chrome/browser/chrome_browser_main_posix.cc +++ b/chrome/browser/chrome_browser_main_posix.cc @@ -114,7 +114,7 @@ ChromeBrowserMainPartsPosix::ChromeBrowserMainPartsPosix( int ChromeBrowserMainPartsPosix::PreEarlyInitialization() { const int result = ChromeBrowserMainParts::PreEarlyInitialization(); - if (result != service_manager::RESULT_CODE_NORMAL_EXIT) + if (result != content::RESULT_CODE_NORMAL_EXIT) return result; // We need to accept SIGCHLD, even though our handler is a no-op because @@ -124,7 +124,7 @@ int ChromeBrowserMainPartsPosix::PreEarlyInitialization() { action.sa_handler = SIGCHLDHandler; CHECK(sigaction(SIGCHLD, &action, NULL) == 0); - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } void ChromeBrowserMainPartsPosix::PostMainMessageLoopStart() { diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index a54d51114c7c68..73c416d6a59340 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -651,7 +651,7 @@ int ChromeBrowserMainPartsWin::HandleIconsCommands( ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL); // Exit as we are not launching the browser. - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } // We don't hide icons so we shouldn't do anything special to show them return chrome::RESULT_CODE_UNSUPPORTED_PARAM; diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 0a2a0165084f10..5c105b421e451a 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -251,7 +251,6 @@ #include "services/preferences/public/cpp/in_process_service_factory.h" #include "services/preferences/public/mojom/preferences.mojom.h" #include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/mojom/connector.mojom.h" #include "services/service_manager/sandbox/sandbox_type.h" @@ -2021,7 +2020,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, arraysize(kSwitchNames)); #endif - } else if (process_type == service_manager::switches::kZygoteProcess) { + } else if (process_type == switches::kZygoteProcess) { static const char* const kSwitchNames[] = { // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox. switches::kDisableBundledPpapiFlash, @@ -3122,7 +3121,7 @@ void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( #else int crash_signal_fd = GetCrashSignalFD(command_line); if (crash_signal_fd >= 0) { - mappings->Share(service_manager::kCrashDumpSignal, crash_signal_fd); + mappings->Share(kCrashDumpSignal, crash_signal_fd); } #endif // defined(OS_ANDROID) } diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index 509b62c7837571..4c0434b3c6ffcb 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -37,7 +37,7 @@ #include "ui/base/l10n/l10n_util.h" #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) -#include "services/service_manager/zygote/zygote_host_linux.h" +#include "content/public/browser/zygote_host_linux.h" #endif #if BUILDFLAG(ENABLE_EXTENSIONS) @@ -342,7 +342,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() { } #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) - if (service_manager::ZygoteHost::GetInstance()->IsZygotePid(process.pid)) { + if (content::ZygoteHost::GetInstance()->IsZygotePid(process.pid)) { process.process_type = content::PROCESS_TYPE_ZYGOTE; } #endif diff --git a/chrome/browser/resource_coordinator/tab_manager_delegate_chromeos.cc b/chrome/browser/resource_coordinator/tab_manager_delegate_chromeos.cc index 198ecd0754d57a..8cb738f7e2e95c 100644 --- a/chrome/browser/resource_coordinator/tab_manager_delegate_chromeos.cc +++ b/chrome/browser/resource_coordinator/tab_manager_delegate_chromeos.cc @@ -46,7 +46,7 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_widget_host.h" -#include "services/service_manager/zygote/zygote_host_linux.h" +#include "content/public/browser/zygote_host_linux.h" #include "ui/wm/public/activation_client.h" using base::ProcessHandle; diff --git a/chrome/browser/ui/uninstall_browser_prompt.h b/chrome/browser/ui/uninstall_browser_prompt.h index 535e2e1ec1ff58..15ce952cf2deb4 100644 --- a/chrome/browser/ui/uninstall_browser_prompt.h +++ b/chrome/browser/ui/uninstall_browser_prompt.h @@ -8,7 +8,7 @@ namespace chrome { // Asks user for uninstall confirmation and returns one of these values: -// service_manager::RESULT_CODE_NORMAL_EXIT, +// content::RESULT_CODE_NORMAL_EXIT, // chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE or // chrome::RESULT_CODE_UNINSTALL_USER_CANCEL. int ShowUninstallBrowserPrompt(); diff --git a/chrome/browser/ui/views/uninstall_view.cc b/chrome/browser/ui/views/uninstall_view.cc index 2914ec034ef922..c791b984f6f626 100644 --- a/chrome/browser/ui/views/uninstall_view.cc +++ b/chrome/browser/ui/views/uninstall_view.cc @@ -121,7 +121,7 @@ void UninstallView::SetupControls() { } bool UninstallView::Accept() { - user_selection_ = service_manager::RESULT_CODE_NORMAL_EXIT; + user_selection_ = content::RESULT_CODE_NORMAL_EXIT; if (delete_profile_->checked()) user_selection_ = chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE; if (change_default_browser_ && change_default_browser_->checked()) { @@ -176,7 +176,7 @@ namespace chrome { int ShowUninstallBrowserPrompt() { DCHECK(base::MessageLoopForUI::IsCurrent()); - int result = service_manager::RESULT_CODE_NORMAL_EXIT; + int result = content::RESULT_CODE_NORMAL_EXIT; // Register a KeepAlive while showing the dialog. This is done because the // dialog uses the views framework which may take and release a KeepAlive diff --git a/chrome/browser/ui/webui/sandbox_internals_ui.cc b/chrome/browser/ui/webui/sandbox_internals_ui.cc index ea2ef9b4a88944..0ba9fbd6acda9d 100644 --- a/chrome/browser/ui/webui/sandbox_internals_ui.cc +++ b/chrome/browser/ui/webui/sandbox_internals_ui.cc @@ -21,8 +21,8 @@ #endif #if defined(OS_LINUX) +#include "content/public/browser/zygote_host_linux.h" #include "services/service_manager/sandbox/sandbox.h" -#include "services/service_manager/zygote/zygote_host_linux.h" #endif namespace { @@ -31,7 +31,7 @@ namespace { static void SetSandboxStatusData(content::WebUIDataSource* source) { // Get expected sandboxing status of renderers. const int status = - service_manager::ZygoteHost::GetInstance()->GetRendererSandboxStatus(); + content::ZygoteHost::GetInstance()->GetRendererSandboxStatus(); source->AddBoolean("suid", status & service_manager::SandboxLinux::kSUID); source->AddBoolean("userNs", status & service_manager::SandboxLinux::kUserNS); diff --git a/chrome/common/DEPS b/chrome/common/DEPS index d8212f1a090174..d8bdd67368bc69 100644 --- a/chrome/common/DEPS +++ b/chrome/common/DEPS @@ -49,6 +49,8 @@ include_rules = [ "+rlz/buildflags/buildflags.h", "+sandbox/linux/services/credentials.h", "+services/network/public/cpp", + "+services/service_manager/public", + "+services/service_manager/sandbox", "+third_party/boringssl/src/include", "+third_party/blink/public/platform/web_client_hints_types.mojom.h", "+third_party/blink/public/platform/web_feature.mojom.h", diff --git a/chrome/common/thread_profiler.cc b/chrome/common/thread_profiler.cc index 28747662184679..7f1f860336bd2d 100644 --- a/chrome/common/thread_profiler.cc +++ b/chrome/common/thread_profiler.cc @@ -20,7 +20,6 @@ #include "components/metrics/child_call_stack_profile_collector.h" #include "content/public/common/content_switches.h" #include "content/public/common/service_names.mojom.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/public/cpp/connector.h" namespace { @@ -60,7 +59,7 @@ metrics::CallStackProfileParams::Process GetProcess() { return metrics::CallStackProfileParams::GPU_PROCESS; if (process_type == switches::kUtilityProcess) return metrics::CallStackProfileParams::UTILITY_PROCESS; - if (process_type == service_manager::switches::kZygoteProcess) + if (process_type == switches::kZygoteProcess) return metrics::CallStackProfileParams::ZYGOTE_PROCESS; if (process_type == switches::kPpapiPluginProcess) return metrics::CallStackProfileParams::PPAPI_PLUGIN_PROCESS; diff --git a/chrome/gpu/DEPS b/chrome/gpu/DEPS index 81c0aba2fea237..d3fa63e6df23c0 100644 --- a/chrome/gpu/DEPS +++ b/chrome/gpu/DEPS @@ -7,5 +7,6 @@ include_rules = [ "+content/public/gpu", "+media/cdm", "+media/gpu", + "+services/service_manager/public/cpp", "+third_party/widevine/cdm/widevine_cdm_common.h", ] diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 1d0a546146d384..50bbe89363ef3f 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -393,7 +393,7 @@ DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, InstallStatus IsChromeActiveOrUserCancelled( const InstallerState& installer_state, const Product& product) { - int32_t exit_code = service_manager::RESULT_CODE_NORMAL_EXIT; + int32_t exit_code = content::RESULT_CODE_NORMAL_EXIT; base::CommandLine options(base::CommandLine::NO_PROGRAM); options.AppendSwitch(installer::switches::kUninstall); diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS index b0ece31d87e5ed..fe4ecb788dcd98 100644 --- a/chrome/renderer/DEPS +++ b/chrome/renderer/DEPS @@ -56,6 +56,7 @@ include_rules = [ "+ppapi/c", "+ppapi/shared_impl", "+services/network/public/cpp", + "+services/service_manager/public/cpp", "+skia", "+storage/common", "+third_party/blink/public/mojom", diff --git a/chrome/renderer/pepper/pepper_flash_font_file_host.cc b/chrome/renderer/pepper/pepper_flash_font_file_host.cc index 07e5aeef173495..9add3c2526530b 100644 --- a/chrome/renderer/pepper/pepper_flash_font_file_host.cc +++ b/chrome/renderer/pepper/pepper_flash_font_file_host.cc @@ -68,7 +68,7 @@ bool PepperFlashFontFileHost::GetFontData(uint32_t table, int fd = fd_.get(); if (fd != -1) result = content::GetFontTable(fd, table, 0 /* offset */, - reinterpret_cast(buffer), length); + reinterpret_cast(buffer), length); #elif defined(OS_WIN) if (typeface_) { table = base::ByteSwap(table); diff --git a/chrome/service/DEPS b/chrome/service/DEPS index 7c923f5ad8bbfa..ff020e2c32727b 100644 --- a/chrome/service/DEPS +++ b/chrome/service/DEPS @@ -8,4 +8,5 @@ include_rules = [ "+components/version_info", "+mojo/edk/embedder", "+sandbox/win/src", + "+services/service_manager", ] diff --git a/chrome/service/service_utility_process_host.cc b/chrome/service/service_utility_process_host.cc index 06ba500ee043ac..4fc751c2cc4b1c 100644 --- a/chrome/service/service_utility_process_host.cc +++ b/chrome/service/service_utility_process_host.cc @@ -35,6 +35,7 @@ #include "content/public/common/connection_filter.h" #include "content/public/common/content_switches.h" #include "content/public/common/font_cache_dispatcher_win.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/result_codes.h" #include "content/public/common/sandbox_init.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" @@ -49,7 +50,6 @@ #include "printing/emf_win.h" #include "sandbox/win/src/sandbox_policy.h" #include "sandbox/win/src/sandbox_types.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/mojom/constants.mojom.h" @@ -312,7 +312,7 @@ ServiceUtilityProcessHost::ServiceUtilityProcessHost( ServiceUtilityProcessHost::~ServiceUtilityProcessHost() { // We need to kill the child process when the host dies. - process_.Terminate(service_manager::RESULT_CODE_NORMAL_EXIT, false); + process_.Terminate(content::RESULT_CODE_NORMAL_EXIT, false); } bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile( @@ -410,9 +410,8 @@ bool ServiceUtilityProcessHost::StartProcess(bool sandbox) { base::CommandLine cmd_line(exe_path); cmd_line.AppendSwitchASCII(switches::kProcessType, switches::kUtilityProcess); - cmd_line.AppendSwitchASCII( - service_manager::switches::kServiceRequestChannelToken, - mojo_bootstrap_token); + cmd_line.AppendSwitchASCII(switches::kServiceRequestChannelToken, + mojo_bootstrap_token); cmd_line.AppendSwitch(switches::kLang); cmd_line.AppendArg(switches::kPrefetchArgumentOther); diff --git a/chrome/utility/DEPS b/chrome/utility/DEPS index 531d552fb9e0de..1d9b056678e016 100644 --- a/chrome/utility/DEPS +++ b/chrome/utility/DEPS @@ -34,6 +34,8 @@ include_rules = [ "+services/network/public", "+services/network/url_request_context_builder_mojo.h", "+services/proxy_resolver", + "+services/service_manager/embedder", + "+services/service_manager/public/cpp", "+services/ui/public", "+services/ui/service.h", "+skia/ext", @@ -55,4 +57,9 @@ specific_include_rules = { "+services/ui/public", "+services/ui/service.h", ], + # Needed until utility process launching has been moved to the service + # manager. + "chrome_content_utility_client.cc": [ + "+services/service_manager/sandbox/switches.h", + ] } diff --git a/chrome/utility/importer/firefox_importer_unittest_utils_mac.cc b/chrome/utility/importer/firefox_importer_unittest_utils_mac.cc index 91729958dbe51f..e969cc5924f4af 100644 --- a/chrome/utility/importer/firefox_importer_unittest_utils_mac.cc +++ b/chrome/utility/importer/firefox_importer_unittest_utils_mac.cc @@ -23,13 +23,13 @@ #include "chrome/common/importer/firefox_importer_utils.h" #include "chrome/utility/importer/firefox_importer_unittest_utils_mac.mojom.h" #include "content/public/common/content_descriptors.h" +#include "content/public/common/mojo_channel_switches.h" #include "mojo/edk/embedder/embedder.h" #include "mojo/edk/embedder/incoming_broker_client_invitation.h" #include "mojo/edk/embedder/outgoing_broker_client_invitation.h" #include "mojo/edk/embedder/platform_channel_pair.h" #include "mojo/edk/embedder/scoped_platform_handle.h" #include "mojo/public/cpp/bindings/binding.h" -#include "services/service_manager/embedder/descriptors.h" #include "testing/multiprocess_func_list.h" namespace { @@ -54,8 +54,8 @@ base::Process LaunchNSSDecrypterChildProcess( base::LaunchOptions options; options.environ["DYLD_FALLBACK_LIBRARY_PATH"] = nss_path.value(); options.fds_to_remap.push_back(std::pair( - mojo_handle.get().handle, service_manager::kMojoIPCChannel + - base::GlobalDescriptors::kBaseDescriptor)); + mojo_handle.get().handle, + kMojoIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); return base::LaunchProcess(cl.argv(), options); } @@ -248,8 +248,7 @@ MULTIPROCESS_TEST_MAIN(NSSDecrypterChildProcess) { mojo::edk::ConnectionParams( mojo::edk::TransportProtocol::kLegacy, mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( - service_manager::kMojoIPCChannel + - base::GlobalDescriptors::kBaseDescriptor)))); + kMojoIPCChannel + base::GlobalDescriptors::kBaseDescriptor)))); mojo::ScopedMessagePipeHandle mojo_handle = invitation->ExtractMessagePipe( base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( kMojoChannelToken)); diff --git a/chromecast/app/DEPS b/chromecast/app/DEPS index 19d7005c1ca844..9ca074eeb1b457 100644 --- a/chromecast/app/DEPS +++ b/chromecast/app/DEPS @@ -8,7 +8,6 @@ include_rules = [ "+content/public/app", "+content/public/browser", "+content/public/common", - "+services/service_manager/sandbox", "+ui/base", ] diff --git a/chromecast/app/android/DEPS b/chromecast/app/android/DEPS index 8bb2b12f6d7bc9..78006b0c57e6f3 100644 --- a/chromecast/app/android/DEPS +++ b/chromecast/app/android/DEPS @@ -2,6 +2,5 @@ include_rules = [ "+chromecast/android", "+chromecast/browser/android", "+jni", - "+services/service_manager/embedder", "+third_party/breakpad", ] diff --git a/chromecast/app/android/crash_handler.cc b/chromecast/app/android/crash_handler.cc index ad9620251c04b4..365964d2e7ce2c 100644 --- a/chromecast/app/android/crash_handler.cc +++ b/chromecast/app/android/crash_handler.cc @@ -19,7 +19,6 @@ #include "components/crash/content/app/crash_reporter_client.h" #include "content/public/common/content_switches.h" #include "jni/CastCrashHandler_jni.h" -#include "services/service_manager/embedder/switches.h" #include "third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h" #include "third_party/breakpad/breakpad/src/client/linux/handler/minidump_descriptor.h" @@ -82,7 +81,7 @@ void CrashHandler::Initialize() { return; } - if (process_type_ != service_manager::switches::kZygoteProcess) { + if (process_type_ != switches::kZygoteProcess) { breakpad::InitNonBrowserCrashReporterForAndroid(process_type_); } } diff --git a/chromecast/app/cast_main_delegate.cc b/chromecast/app/cast_main_delegate.cc index 28a598b3d7b103..c77fc82568e09e 100644 --- a/chromecast/app/cast_main_delegate.cc +++ b/chromecast/app/cast_main_delegate.cc @@ -38,7 +38,6 @@ #include "ui/base/resource/resource_bundle_android.h" #elif defined(OS_LINUX) #include "chromecast/app/linux/cast_crash_reporter_client.h" -#include "services/service_manager/sandbox/switches.h" #endif // defined(OS_LINUX) namespace { @@ -148,7 +147,7 @@ void CastMainDelegate::PreSandboxStartup() { #elif defined(OS_LINUX) crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer()); - if (process_type != service_manager::switches::kZygoteProcess) { + if (process_type != switches::kZygoteProcess) { CastCrashReporterClient::InitCrashReporter(process_type); } #endif // defined(OS_LINUX) diff --git a/chromecast/app/linux/cast_crash_reporter_client.cc b/chromecast/app/linux/cast_crash_reporter_client.cc index 97663d6492c052..fc88ed3e6d6fee 100644 --- a/chromecast/app/linux/cast_crash_reporter_client.cc +++ b/chromecast/app/linux/cast_crash_reporter_client.cc @@ -9,7 +9,6 @@ #include "chromecast/crash/linux/crash_util.h" #include "components/crash/content/app/breakpad_linux.h" #include "content/public/common/content_switches.h" -#include "services/service_manager/sandbox/switches.h" namespace chromecast { @@ -52,7 +51,7 @@ CastCrashReporterClient::~CastCrashReporterClient() { bool CastCrashReporterClient::EnableBreakpadForProcess( const std::string& process_type) { return process_type == switches::kRendererProcess || - process_type == service_manager::switches::kZygoteProcess || + process_type == switches::kZygoteProcess || process_type == switches::kGpuProcess || process_type == switches::kUtilityProcess; } diff --git a/chromecast/browser/DEPS b/chromecast/browser/DEPS index 2a2651cd4204e6..fa570f3ab21d22 100644 --- a/chromecast/browser/DEPS +++ b/chromecast/browser/DEPS @@ -37,7 +37,6 @@ include_rules = [ "+net", "+services/network/public/cpp", "+services/service_manager/public", - "+services/service_manager/embedder", "+ui/accessibility", "+ui/aura", "+ui/base", diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc index 483c4b4bba90ab..437a0fb232a1fb 100644 --- a/chromecast/browser/cast_content_browser_client.cc +++ b/chromecast/browser/cast_content_browser_client.cc @@ -61,7 +61,6 @@ #include "media/mojo/buildflags.h" #include "net/ssl/ssl_cert_request_info.h" #include "net/url_request/url_request_context_getter.h" -#include "services/service_manager/embedder/descriptors.h" #include "ui/base/resource/resource_bundle.h" #include "ui/display/display.h" #include "ui/display/screen.h" @@ -685,7 +684,7 @@ void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( // TODO(crbug.com/753619): Enable crash reporting on Fuchsia. int crash_signal_fd = GetCrashSignalFD(command_line); if (crash_signal_fd >= 0) { - mappings->Share(service_manager::kCrashDumpSignal, crash_signal_fd); + mappings->Share(kCrashDumpSignal, crash_signal_fd); } #endif // !defined(OS_FUCHSIA) } diff --git a/components/crash/content/app/breakpad_linux.cc b/components/crash/content/app/breakpad_linux.cc index 87703f9a5276e5..1dde47fb6bba92 100644 --- a/components/crash/content/app/breakpad_linux.cc +++ b/components/crash/content/app/breakpad_linux.cc @@ -992,7 +992,8 @@ class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient { public: NonBrowserCrashHandler() : server_fd_(base::GlobalDescriptors::GetInstance()->Get( - service_manager::kCrashDumpSignal)) {} + kCrashDumpSignal)) { + } ~NonBrowserCrashHandler() override {} diff --git a/components/crash/content/app/crashpad_linux.cc b/components/crash/content/app/crashpad_linux.cc index b70f30d8dcf4e7..bb40fa17f2b1d3 100644 --- a/components/crash/content/app/crashpad_linux.cc +++ b/components/crash/content/app/crashpad_linux.cc @@ -41,8 +41,7 @@ class SandboxedHandler { } bool Initialize() { - server_fd_ = base::GlobalDescriptors::GetInstance()->Get( - service_manager::kCrashDumpSignal); + server_fd_ = base::GlobalDescriptors::GetInstance()->Get(kCrashDumpSignal); return Signals::InstallCrashHandlers(HandleCrash, 0, nullptr); } diff --git a/components/nacl/DEPS b/components/nacl/DEPS index b37894a21a537f..a5cd353982cf81 100644 --- a/components/nacl/DEPS +++ b/components/nacl/DEPS @@ -2,5 +2,5 @@ include_rules = [ "+content/public/common", "+ipc", "+mojo/public", - "+services/service_manager", + "+services/service_manager/public", ] diff --git a/components/nacl/broker/BUILD.gn b/components/nacl/broker/BUILD.gn index 14641bdd76b962..fe238f39d88742 100644 --- a/components/nacl/broker/BUILD.gn +++ b/components/nacl/broker/BUILD.gn @@ -31,7 +31,6 @@ source_set("broker") { "//mojo/edk", "//sandbox", "//services/service_manager/public/cpp", - "//services/service_manager/zygote:zygote_buildflags", ] if (current_cpu == target_cpu) { @@ -50,6 +49,13 @@ source_set("content_dummy") { "//content/public/common/sandbox_init.h", "//content/public/common/sandboxed_process_launcher_delegate.h", ] + + deps = [ + # sandboxed_process_launcher_delegate.h includes headers generated from + # //content/public/common:zygote_buildflags, so this target needs to have a + # dep on it as well. + "//content/public/common:zygote_buildflags", + ] } if (current_cpu == "x86") { @@ -145,9 +151,9 @@ if (current_cpu == "x86") { deps = [ "//base", "//content/public/common:static_switches", + "//content/public/common:zygote_buildflags", "//sandbox", "//services/service_manager/sandbox", - "//services/service_manager/zygote:zygote_buildflags", ] } diff --git a/components/nacl/broker/nacl_broker_listener.cc b/components/nacl/broker/nacl_broker_listener.cc index 35b92227dec675..8f92399f5b3d19 100644 --- a/components/nacl/broker/nacl_broker_listener.cc +++ b/components/nacl/broker/nacl_broker_listener.cc @@ -22,6 +22,7 @@ #include "components/nacl/common/nacl_service.h" #include "components/nacl/common/nacl_switches.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/sandbox_init.h" #include "ipc/ipc_channel.h" #include "mojo/edk/embedder/embedder.h" @@ -29,7 +30,6 @@ #include "mojo/edk/embedder/platform_channel_pair.h" #include "mojo/public/cpp/system/message_pipe.h" #include "sandbox/win/src/sandbox_policy.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/public/cpp/service_context.h" namespace { @@ -126,8 +126,7 @@ void NaClBrokerListener::OnLaunchLoaderThroughBroker( base::UintToString(base::win::HandleToUint32(handles[0]))); std::string token = mojo::edk::GenerateRandomToken(); - cmd_line->AppendSwitchASCII( - service_manager::switches::kServiceRequestChannelToken, token); + cmd_line->AppendSwitchASCII(switches::kServiceRequestChannelToken, token); mojo::edk::OutgoingBrokerClientInvitation invitation; MojoResult fuse_result = mojo::FuseMessagePipes( mojo::ScopedMessagePipeHandle(service_request_pipe), diff --git a/components/nacl/browser/BUILD.gn b/components/nacl/browser/BUILD.gn index 0f5426351f6099..43079fb0f114a5 100644 --- a/components/nacl/browser/BUILD.gn +++ b/components/nacl/browser/BUILD.gn @@ -39,13 +39,13 @@ static_library("browser") { "//components/url_formatter", "//content/public/browser", "//content/public/common", + "//content/public/common:zygote_buildflags", "//mojo/edk", "//native_client/src/trusted/service_runtime:sel_main_chrome", "//net", "//ppapi/host", "//ppapi/proxy:ipc", "//ppapi/shared_impl", - "//services/service_manager/zygote:zygote_buildflags", ] public_deps = [ @@ -65,7 +65,6 @@ static_library("browser") { "//components/nacl/loader:nacl_helper_integration", "//sandbox/linux:sandbox_services", "//sandbox/linux:suid_sandbox_client", - "//services/service_manager/zygote", ] if (enable_nacl_nonsfi) { diff --git a/components/nacl/browser/nacl_broker_host_win.cc b/components/nacl/browser/nacl_broker_host_win.cc index b5922b0b96722e..868baca333cce4 100644 --- a/components/nacl/browser/nacl_broker_host_win.cc +++ b/components/nacl/browser/nacl_broker_host_win.cc @@ -21,6 +21,7 @@ #include "content/public/browser/child_process_data.h" #include "content/public/common/child_process_host.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "mojo/edk/embedder/embedder.h" diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc index 7403923e6c7518..c34f94f7e63fd9 100644 --- a/components/nacl/browser/nacl_process_host.cc +++ b/components/nacl/browser/nacl_process_host.cc @@ -51,8 +51,10 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/child_process_host.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/process_type.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" +#include "content/public/common/zygote_buildflags.h" #include "ipc/ipc_channel.h" #include "mojo/edk/embedder/embedder.h" #include "net/socket/socket_descriptor.h" @@ -62,10 +64,9 @@ #include "ppapi/shared_impl/ppapi_constants.h" #include "ppapi/shared_impl/ppapi_nacl_plugin_args.h" #include "services/service_manager/sandbox/switches.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #if BUILDFLAG(USE_ZYGOTE_HANDLE) -#include "services/service_manager/zygote/common/zygote_handle.h" // nogncheck +#include "content/public/common/zygote_handle.h" #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) #if defined(OS_POSIX) @@ -184,8 +185,8 @@ class NaClSandboxedProcessLauncherDelegate #endif // OS_WIN #if BUILDFLAG(USE_ZYGOTE_HANDLE) - service_manager::ZygoteHandle GetZygote() override { - return service_manager::GetGenericZygote(); + content::ZygoteHandle GetZygote() override { + return content::GetGenericZygote(); } #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) diff --git a/components/nacl/common/BUILD.gn b/components/nacl/common/BUILD.gn index 8f9ef992673110..df8a120c317c62 100644 --- a/components/nacl/common/BUILD.gn +++ b/components/nacl/common/BUILD.gn @@ -51,6 +51,7 @@ if (enable_nacl) { sources = [ "//content/public/common/content_descriptors.h", "//content/public/common/content_switches.h", + "//content/public/common/mojo_channel_switches.h", "//content/public/common/process_type.h", ] diff --git a/components/nacl/common/nacl_service.cc b/components/nacl/common/nacl_service.cc index c10e532633e036..e1264793acfcaf 100644 --- a/components/nacl/common/nacl_service.cc +++ b/components/nacl/common/nacl_service.cc @@ -8,6 +8,7 @@ #include #include "base/command_line.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/service_names.mojom.h" #include "ipc/ipc.mojom.h" #include "mojo/edk/embedder/embedder.h" @@ -15,14 +16,13 @@ #include "mojo/edk/embedder/scoped_ipc_support.h" #include "mojo/edk/embedder/scoped_platform_handle.h" #include "mojo/public/cpp/bindings/interface_request.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/cpp/service.h" #include "services/service_manager/public/cpp/service_context.h" #if defined(OS_POSIX) #include "base/posix/global_descriptors.h" -#include "services/service_manager/embedder/descriptors.h" +#include "content/public/common/content_descriptors.h" #elif defined(OS_WIN) #include "mojo/edk/embedder/platform_channel_pair.h" #endif @@ -36,9 +36,8 @@ EstablishMojoConnection() { mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( *base::CommandLine::ForCurrentProcess())); #else - mojo::edk::ScopedPlatformHandle platform_channel( - mojo::edk::PlatformHandle(base::GlobalDescriptors::GetInstance()->Get( - service_manager::kMojoIPCChannel))); + mojo::edk::ScopedPlatformHandle platform_channel(mojo::edk::PlatformHandle( + base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel))); #endif DCHECK(platform_channel.is_valid()); return mojo::edk::IncomingBrokerClientInvitation::Accept( @@ -50,7 +49,7 @@ service_manager::mojom::ServiceRequest ConnectToServiceManager( mojo::edk::IncomingBrokerClientInvitation* invitation) { const std::string service_request_channel_token = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - service_manager::switches::kServiceRequestChannelToken); + switches::kServiceRequestChannelToken); DCHECK(!service_request_channel_token.empty()); mojo::ScopedMessagePipeHandle parent_handle = invitation->ExtractMessagePipe(service_request_channel_token); diff --git a/components/nacl/loader/BUILD.gn b/components/nacl/loader/BUILD.gn index c468773ce224d4..b125e1a663c107 100644 --- a/components/nacl/loader/BUILD.gn +++ b/components/nacl/loader/BUILD.gn @@ -43,10 +43,6 @@ source_set("minimal") { "//sandbox", "//services/service_manager/public/cpp", ] - - if (is_linux) { - deps += [ "//services/service_manager/zygote" ] - } } # This exists just to make 'gn check' happy with :minimal and @@ -133,7 +129,6 @@ if (is_linux) { "//mojo/edk", "//sandbox/linux:sandbox_services", "//services/service_manager/sandbox", - "//services/service_manager/zygote", "//url/ipc:url_ipc", ] @@ -254,7 +249,6 @@ if (is_nacl_nonsfi) { "//sandbox/linux:sandbox", "//services/service_manager/public/cpp", "//services/service_manager/sandbox", - "//services/service_manager/zygote:zygote_util", ] } diff --git a/components/nacl/loader/nacl_helper_linux.cc b/components/nacl/loader/nacl_helper_linux.cc index 50230ec6a8e3c4..82cbfc75f0a0a8 100644 --- a/components/nacl/loader/nacl_helper_linux.cc +++ b/components/nacl/loader/nacl_helper_linux.cc @@ -35,13 +35,13 @@ #include "build/build_config.h" #include "components/nacl/common/nacl_switches.h" #include "components/nacl/loader/sandbox_linux/nacl_sandbox_linux.h" +#include "content/public/common/content_descriptors.h" +#include "content/public/common/mojo_channel_switches.h" +#include "content/public/common/send_zygote_child_ping_linux.h" +#include "content/public/common/zygote_fork_delegate_linux.h" #include "mojo/edk/embedder/embedder.h" #include "sandbox/linux/services/credentials.h" #include "sandbox/linux/services/namespace_sandbox.h" -#include "services/service_manager/embedder/descriptors.h" -#include "services/service_manager/embedder/switches.h" -#include "services/service_manager/zygote/common/send_zygote_child_ping_linux.h" -#include "services/service_manager/zygote/common/zygote_fork_delegate_linux.h" #if defined(OS_NACL_NONSFI) #include "components/nacl/loader/nonsfi/nonsfi_listener.h" @@ -93,8 +93,8 @@ void BecomeNaClLoader(base::ScopedFD browser_fd, // This file descriptor is insidiously used by a number of APIs. Closing it // could lead to difficult to debug issues. Instead of closing it, replace // it with a dummy. - const int sandbox_ipc_channel = base::GlobalDescriptors::kBaseDescriptor + - service_manager::kSandboxIPCChannel; + const int sandbox_ipc_channel = + base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel; ReplaceFDWithDummy(sandbox_ipc_channel); @@ -115,7 +115,7 @@ void BecomeNaClLoader(base::ScopedFD browser_fd, nacl_sandbox->SealLayerOneSandbox(); nacl_sandbox->CheckSandboxingStateWithPolicy(); - base::GlobalDescriptors::GetInstance()->Set(service_manager::kMojoIPCChannel, + base::GlobalDescriptors::GetInstance()->Set(kMojoIPCChannel, browser_fd.release()); // The Mojo EDK must be initialized before using IPC. @@ -143,19 +143,19 @@ void ChildNaClLoaderInit(std::vector child_fds, nacl::NaClSandbox* nacl_sandbox, const std::string& channel_id) { DCHECK(child_fds.size() > - std::max(service_manager::ZygoteForkDelegate::kPIDOracleFDIndex, - service_manager::ZygoteForkDelegate::kBrowserFDIndex)); + std::max(content::ZygoteForkDelegate::kPIDOracleFDIndex, + content::ZygoteForkDelegate::kBrowserFDIndex)); // Ping the PID oracle socket. - CHECK(service_manager::SendZygoteChildPing( - child_fds[service_manager::ZygoteForkDelegate::kPIDOracleFDIndex].get())); + CHECK(content::SendZygoteChildPing( + child_fds[content::ZygoteForkDelegate::kPIDOracleFDIndex].get())); base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( - service_manager::switches::kServiceRequestChannelToken, channel_id); + switches::kServiceRequestChannelToken, channel_id); // Save the browser socket and close the rest. - base::ScopedFD browser_fd(std::move( - child_fds[service_manager::ZygoteForkDelegate::kBrowserFDIndex])); + base::ScopedFD browser_fd( + std::move(child_fds[content::ZygoteForkDelegate::kBrowserFDIndex])); child_fds.clear(); BecomeNaClLoader(std::move(browser_fd), system_info, uses_nonsfi_mode, @@ -183,7 +183,7 @@ bool HandleForkRequest(std::vector child_fds, return false; } - if (service_manager::ZygoteForkDelegate::kNumPassedFDs != child_fds.size()) { + if (content::ZygoteForkDelegate::kNumPassedFDs != child_fds.size()) { LOG(ERROR) << "nacl_helper: unexpected number of fds, got " << child_fds.size(); return false; diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc index 42cd832636a100..dd90b432499f39 100644 --- a/components/nacl/loader/nacl_listener.cc +++ b/components/nacl/loader/nacl_listener.cc @@ -31,6 +31,7 @@ #include "components/nacl/loader/nacl_ipc_adapter.h" #include "components/nacl/loader/nacl_validation_db.h" #include "components/nacl/loader/nacl_validation_query.h" +#include "content/public/common/mojo_channel_switches.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_sync_channel.h" #include "ipc/ipc_sync_message_filter.h" @@ -40,7 +41,7 @@ #include "services/service_manager/public/cpp/service_context.h" #if defined(OS_LINUX) -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" +#include "content/public/common/common_sandbox_support_linux.h" #endif #if defined(OS_POSIX) @@ -80,7 +81,7 @@ void LoadStatusCallback(int load_status) { #if defined(OS_LINUX) int CreateMemoryObject(size_t size, int executable) { - return service_manager::MakeSharedMemorySegmentViaIPC(size, executable); + return content::MakeSharedMemorySegmentViaIPC(size, executable); } #elif defined(OS_WIN) diff --git a/components/nacl/loader/nonsfi/nonsfi_listener.cc b/components/nacl/loader/nonsfi/nonsfi_listener.cc index 3caa27c86257b5..088ccf074b204f 100644 --- a/components/nacl/loader/nonsfi/nonsfi_listener.cc +++ b/components/nacl/loader/nonsfi/nonsfi_listener.cc @@ -21,6 +21,7 @@ #include "components/nacl/loader/nacl_trusted_listener.h" #include "components/nacl/loader/nonsfi/nonsfi_main.h" #include "content/public/common/content_descriptors.h" +#include "content/public/common/mojo_channel_switches.h" #include "ipc/ipc_channel.h" #include "ipc/ipc_channel_handle.h" #include "ipc/ipc_sync_channel.h" diff --git a/components/nacl/zygote/nacl_fork_delegate_linux.cc b/components/nacl/zygote/nacl_fork_delegate_linux.cc index 3d571e5bfdb8d1..2c5e7ae97aae36 100644 --- a/components/nacl/zygote/nacl_fork_delegate_linux.cc +++ b/components/nacl/zygote/nacl_fork_delegate_linux.cc @@ -130,8 +130,7 @@ bool SendIPCRequestAndReadReply(int ipc_channel, namespace nacl { void AddNaClZygoteForkDelegates( - std::vector>* - delegates) { + std::vector>* delegates) { delegates->push_back( std::make_unique(false /* nonsfi_mode */)); delegates->push_back( @@ -168,8 +167,8 @@ void NaClForkDelegate::Init(const int sandboxdesc, // For communications between the NaCl loader process and // the browser process. - int nacl_sandbox_descriptor = base::GlobalDescriptors::kBaseDescriptor + - service_manager::kSandboxIPCChannel; + int nacl_sandbox_descriptor = + base::GlobalDescriptors::kBaseDescriptor + kSandboxIPCChannel; // Confirm a hard-wired assumption. DCHECK_EQ(sandboxdesc, nacl_sandbox_descriptor); diff --git a/components/nacl/zygote/nacl_fork_delegate_linux.h b/components/nacl/zygote/nacl_fork_delegate_linux.h index 3beb83f8cbff1b..1b4695c0c1ba4b 100644 --- a/components/nacl/zygote/nacl_fork_delegate_linux.h +++ b/components/nacl/zygote/nacl_fork_delegate_linux.h @@ -12,7 +12,7 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "services/service_manager/zygote/common/zygote_fork_delegate_linux.h" +#include "content/public/common/zygote_fork_delegate_linux.h" namespace base { struct LaunchOptions; @@ -22,15 +22,14 @@ namespace nacl { // Appends any ZygoteForkDelegate instances needed by NaCl to |*delegates|. void AddNaClZygoteForkDelegates( - std::vector>* - delegates); + std::vector>* delegates); -// The NaClForkDelegate is created during Chrome linux zygote initialization, -// and provides "fork()" functionality with NaCl specific process -// characteristics (specifically address space layout) as an alternative to -// forking the zygote. A new delegate is passed in as an argument to -// ZygoteMain(). -class NaClForkDelegate : public service_manager::ZygoteForkDelegate { +// The NaClForkDelegate is created during Chrome linux zygote +// initialization, and provides "fork()" functionality with +// NaCl specific process characteristics (specifically address +// space layout) as an alternative to forking the zygote. +// A new delegate is passed in as an argument to ZygoteMain(). +class NaClForkDelegate : public content::ZygoteForkDelegate { public: explicit NaClForkDelegate(bool nonsfi_mode); ~NaClForkDelegate() override; diff --git a/content/BUILD.gn b/content/BUILD.gn index 063220b0161b4e..7c567481db6682 100644 --- a/content/BUILD.gn +++ b/content/BUILD.gn @@ -91,8 +91,11 @@ if (is_component_build) { sources = [ "//services/service_manager/sandbox/linux/sandbox_seccomp_bpf_linux.cc", "common/sandbox_init_linux.cc", + "common/send_zygote_child_ping_linux.cc", "public/common/content_switches.cc", "public/common/content_switches.h", + "public/common/mojo_channel_switches.cc", + "public/common/mojo_channel_switches.h", ] set_sources_assignment_filter(sources_assignment_filter) deps = [ diff --git a/content/DEPS b/content/DEPS index bd793f4f2478cc..e187ebec4b325e 100644 --- a/content/DEPS +++ b/content/DEPS @@ -46,7 +46,6 @@ include_rules = [ "+services/proxy_resolver/public/mojom", "+services/service_manager/embedder", "+services/service_manager/sandbox", - "+services/service_manager/zygote", "+skia", # In general, content/ should not rely on google_apis, since URLs diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index 0bd846da8a4eaf..7f0fc3d696e5d3 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -52,6 +52,7 @@ #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" #include "content/public/common/sandbox_init.h" +#include "content/public/common/zygote_buildflags.h" #include "gin/v8_initializer.h" #include "media/base/media.h" #include "media/media_buildflags.h" @@ -59,7 +60,6 @@ #include "services/service_manager/embedder/switches.h" #include "services/service_manager/sandbox/sandbox_type.h" #include "services/service_manager/sandbox/switches.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #include "third_party/blink/public/common/origin_trials/trial_token_validator.h" #include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_switches.h" @@ -87,11 +87,11 @@ #include "content/public/common/content_descriptors.h" #if !defined(OS_MACOSX) -#include "services/service_manager/zygote/common/zygote_fork_delegate_linux.h" +#include "content/public/common/zygote_fork_delegate_linux.h" #endif #if !defined(OS_MACOSX) && !defined(OS_ANDROID) +#include "content/zygote/zygote_main.h" #include "sandbox/linux/services/libc_interceptor.h" -#include "services/service_manager/zygote/zygote_main.h" #endif #endif // OS_POSIX @@ -100,7 +100,7 @@ #include "base/native_library.h" #include "base/rand_util.h" #include "content/common/font_config_ipc_linux.h" -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" +#include "content/public/common/common_sandbox_support_linux.h" #include "third_party/blink/public/platform/web_font_render_style.h" #include "third_party/boringssl/src/include/openssl/crypto.h" #include "third_party/boringssl/src/include/openssl/rand.h" @@ -145,11 +145,11 @@ #if BUILDFLAG(USE_ZYGOTE_HANDLE) #include "content/browser/sandbox_host_linux.h" +#include "content/browser/zygote_host/zygote_communication_linux.h" +#include "content/browser/zygote_host/zygote_host_impl_linux.h" +#include "content/public/common/common_sandbox_support_linux.h" +#include "content/public/common/zygote_handle.h" #include "media/base/media_switches.h" -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" -#include "services/service_manager/zygote/common/zygote_handle.h" -#include "services/service_manager/zygote/host/zygote_communication_linux.h" -#include "services/service_manager/zygote/host/zygote_host_impl_linux.h" #endif namespace content { @@ -197,8 +197,7 @@ void InitializeFieldTrialAndFeatureList( // On POSIX systems that use the zygote, we get the trials from a shared // memory segment backed by an fd instead of the command line. base::FieldTrialList::CreateTrialsFromCommandLine( - command_line, switches::kFieldTrialHandle, - service_manager::kFieldTrialDescriptor); + command_line, switches::kFieldTrialHandle, kFieldTrialDescriptor); #else base::FieldTrialList::CreateTrialsFromCommandLine( command_line, switches::kFieldTrialHandle, -1); @@ -300,10 +299,9 @@ pid_t LaunchZygoteHelper(base::CommandLine* cmd_line, // sandboxed processes to talk to it. base::FileHandleMappingVector additional_remapped_fds; additional_remapped_fds.emplace_back( - SandboxHostLinux::GetInstance()->GetChildSocket(), - service_manager::GetSandboxFD()); + SandboxHostLinux::GetInstance()->GetChildSocket(), GetSandboxFD()); - return service_manager::ZygoteHostImpl::GetInstance()->LaunchZygote( + return ZygoteHostImpl::GetInstance()->LaunchZygote( cmd_line, control_fd, std::move(additional_remapped_fds)); } @@ -323,14 +321,14 @@ void InitializeZygoteSandboxForBrowserProcess( } // Tickle the zygote host so it forks now. - service_manager::ZygoteHostImpl::GetInstance()->Init(parsed_command_line); - service_manager::ZygoteHandle generic_zygote = - service_manager::CreateGenericZygote(base::BindOnce(LaunchZygoteHelper)); + ZygoteHostImpl::GetInstance()->Init(parsed_command_line); + ZygoteHandle generic_zygote = + CreateGenericZygote(base::BindOnce(LaunchZygoteHelper)); // TODO(kerrnel): Investigate doing this without the ZygoteHostImpl as a // proxy. It is currently done this way due to concerns about race // conditions. - service_manager::ZygoteHostImpl::GetInstance()->SetRendererSandboxStatus( + ZygoteHostImpl::GetInstance()->SetRendererSandboxStatus( generic_zygote->GetSandboxStatus()); } #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) @@ -398,9 +396,7 @@ void PreSandboxInit() { InitializeWebRtcModule(); #endif - SkFontConfigInterface::SetGlobal( - new FontConfigIPC(service_manager::GetSandboxFD())) - ->unref(); + SkFontConfigInterface::SetGlobal(new FontConfigIPC(GetSandboxFD()))->unref(); // Set the android SkFontMgr for blink. We need to ensure this is done // before the sandbox is initialized to allow the font manager to access @@ -522,8 +518,7 @@ int RunZygote(ContentMainDelegate* delegate) { #endif }; - std::vector> - zygote_fork_delegates; + std::vector> zygote_fork_delegates; if (delegate) { delegate->ZygoteStarting(&zygote_fork_delegates); media::InitializeMediaLibrary(); @@ -534,9 +529,8 @@ int RunZygote(ContentMainDelegate* delegate) { #endif // This function call can return multiple times, once per fork(). - if (!service_manager::ZygoteMain(std::move(zygote_fork_delegates))) { + if (!ZygoteMain(std::move(zygote_fork_delegates))) return 1; - } if (delegate) delegate->ZygoteForked(); @@ -644,7 +638,7 @@ int RunNamedProcessTypeMain( #if BUILDFLAG(USE_ZYGOTE_HANDLE) // Zygote startup is special -- see RunZygote comments above // for why we don't use ZygoteMain directly. - if (process_type == service_manager::switches::kZygoteProcess) + if (process_type == switches::kZygoteProcess) return RunZygote(delegate); #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) @@ -701,19 +695,17 @@ class ContentMainRunnerImpl : public ContentMainRunner { // On Android, the ipc_fd is passed through the Java service. #if !defined(OS_ANDROID) - g_fds->Set(service_manager::kMojoIPCChannel, - service_manager::kMojoIPCChannel + - base::GlobalDescriptors::kBaseDescriptor); + g_fds->Set(kMojoIPCChannel, + kMojoIPCChannel + base::GlobalDescriptors::kBaseDescriptor); - g_fds->Set(service_manager::kFieldTrialDescriptor, - service_manager::kFieldTrialDescriptor + - base::GlobalDescriptors::kBaseDescriptor); + g_fds->Set( + kFieldTrialDescriptor, + kFieldTrialDescriptor + base::GlobalDescriptors::kBaseDescriptor); #endif // !OS_ANDROID #if defined(OS_LINUX) || defined(OS_OPENBSD) - g_fds->Set(service_manager::kCrashDumpSignal, - service_manager::kCrashDumpSignal + - base::GlobalDescriptors::kBaseDescriptor); + g_fds->Set(kCrashDumpSignal, + kCrashDumpSignal + base::GlobalDescriptors::kBaseDescriptor); #endif // OS_LINUX || OS_OPENBSD #endif // !OS_WIN @@ -766,7 +758,7 @@ class ContentMainRunnerImpl : public ContentMainRunner { // // Startup tracing flags are not (and should not) passed to Zygote // processes. We will enable tracing when forked, if needed. - if (process_type != service_manager::switches::kZygoteProcess) + if (process_type != switches::kZygoteProcess) tracing::EnableStartupTracingIfNeeded(); #endif // !OS_ANDROID @@ -923,8 +915,7 @@ class ContentMainRunnerImpl : public ContentMainRunner { // Run this logic on all child processes. Zygotes will run this at a later // point in time when the command line has been updated. std::unique_ptr field_trial_list; - if (!process_type.empty() && - process_type != service_manager::switches::kZygoteProcess) + if (!process_type.empty() && process_type != switches::kZygoteProcess) InitializeFieldTrialAndFeatureList(&field_trial_list); MainFunctionParams main_params(command_line); diff --git a/content/app/content_service_manager_main_delegate.cc b/content/app/content_service_manager_main_delegate.cc index 90e3b577bb75e1..62dceb57886c87 100644 --- a/content/app/content_service_manager_main_delegate.cc +++ b/content/app/content_service_manager_main_delegate.cc @@ -9,7 +9,6 @@ #include "content/public/app/content_main_runner.h" #include "content/public/common/content_switches.h" #include "content/public/common/service_names.mojom.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/runner/common/client_util.h" namespace content { @@ -45,8 +44,7 @@ bool ContentServiceManagerMainDelegate::IsEmbedderSubprocess() { type == switches::kPpapiBrokerProcess || type == switches::kPpapiPluginProcess || type == switches::kRendererProcess || - type == switches::kUtilityProcess || - type == service_manager::switches::kZygoteProcess; + type == switches::kUtilityProcess || type == switches::kZygoteProcess; } int ContentServiceManagerMainDelegate::RunEmbedderProcess() { diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index 39ea9e913453ec..8850d32c99a7c1 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn @@ -7,6 +7,7 @@ import("//build/config/features.gni") import("//build/config/jumbo.gni") import("//build/config/linux/pangocairo/pangocairo.gni") import("//build/config/ui.gni") +import("//content/public/common/zygote_features.gni") import("//gpu/vulkan/features.gni") import("//media/media_options.gni") import("//net/features.gni") @@ -81,6 +82,7 @@ jumbo_source_set("browser") { "//content/common:buildflags", "//content/common:mojo_bindings", "//content/public/common:common_sources", + "//content/public/common:zygote_buildflags", "//crypto", "//device/bluetooth", "//device/fido", @@ -135,12 +137,11 @@ jumbo_source_set("browser") { "//services/resource_coordinator:lib", "//services/resource_coordinator/public/cpp:resource_coordinator_cpp", "//services/service_manager", - "//services/service_manager/embedder:embedder_result_codes", + "//services/service_manager/embedder", "//services/service_manager/public/cpp", "//services/service_manager/public/mojom", "//services/service_manager/runner/common", "//services/service_manager/runner/host:lib", - "//services/service_manager/zygote:zygote_buildflags", "//services/shape_detection:lib", "//services/shape_detection/public/mojom", "//services/tracing:lib", @@ -250,6 +251,10 @@ jumbo_source_set("browser") { "$target_gen_dir/devtools/protocol/tracing.h", "../common/service_manager/child_connection.cc", "../common/service_manager/child_connection.h", + "../zygote/zygote_linux.cc", + "../zygote/zygote_linux.h", + "../zygote/zygote_main.h", + "../zygote/zygote_main_linux.cc", "accessibility/accessibility_tree_formatter.cc", "accessibility/accessibility_tree_formatter.h", "accessibility/accessibility_tree_formatter_blink.cc", @@ -1711,16 +1716,16 @@ jumbo_source_set("browser") { "webui/web_ui_message_handler.cc", "webui/web_ui_url_loader_factory.cc", "webui/web_ui_url_loader_factory_internal.h", + "zygote_host/zygote_communication_linux.cc", + "zygote_host/zygote_communication_linux.h", + "zygote_host/zygote_host_impl_linux.cc", + "zygote_host/zygote_host_impl_linux.h", ] if (toolkit_views) { deps += [ "//ui/events" ] } - if (is_linux) { - deps += [ "//services/service_manager/zygote" ] - } - # ChromeOS also defines linux but their memory-monitors conflict. if (is_chromeos) { sources += [ @@ -2351,6 +2356,10 @@ jumbo_source_set("browser") { ] } + if (use_zygote_handle) { + sources += [ "zygote_host/zygote_handle_linux.cc" ] + } + if (enable_reporting) { sources += [ "net/reporting_service_proxy.cc", diff --git a/content/browser/browser_child_process_host_impl.cc b/content/browser/browser_child_process_host_impl.cc index 1686c7a9f2b252..154f50116f419d 100644 --- a/content/browser/browser_child_process_host_impl.cc +++ b/content/browser/browser_child_process_host_impl.cc @@ -43,6 +43,7 @@ #include "content/public/common/connection_filter.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/process_type.h" #include "content/public/common/result_codes.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" @@ -262,9 +263,8 @@ void BrowserChildProcessHostImpl::Launch( arraysize(kForwardSwitches)); if (child_connection_) { - cmd_line->AppendSwitchASCII( - service_manager::switches::kServiceRequestChannelToken, - child_connection_->service_token()); + cmd_line->AppendSwitchASCII(switches::kServiceRequestChannelToken, + child_connection_->service_token()); } DCHECK(broker_client_invitation_); diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index ffa6e252aa7fc5..736cc346c54ec8 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -106,6 +106,7 @@ #include "content/public/common/main_function_params.h" #include "content/public/common/result_codes.h" #include "content/public/common/service_names.mojom.h" +#include "content/public/common/zygote_buildflags.h" #include "device/gamepad/gamepad_service.h" #include "gpu/vulkan/buildflags.h" #include "media/audio/audio_manager.h" @@ -127,7 +128,6 @@ #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" #include "services/resource_coordinator/public/mojom/service_constants.mojom.h" #include "services/service_manager/runner/common/client_util.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #include "skia/ext/event_tracer_impl.h" #include "skia/ext/skia_memory_dump_provider.h" #include "sql/sql_memory_dump_provider.h" @@ -506,7 +506,7 @@ BrowserMainLoop* BrowserMainLoop::GetInstance() { BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters) : parameters_(parameters), parsed_command_line_(parameters.command_line), - result_code_(service_manager::RESULT_CODE_NORMAL_EXIT), + result_code_(RESULT_CODE_NORMAL_EXIT), created_threads_(false) { DCHECK(!g_current_browser_main_loop); g_current_browser_main_loop = this; @@ -579,7 +579,7 @@ int BrowserMainLoop::EarlyInitialization() { } #endif const int pre_early_init_error_code = parts_->PreEarlyInitialization(); - if (pre_early_init_error_code != service_manager::RESULT_CODE_NORMAL_EXIT) + if (pre_early_init_error_code != content::RESULT_CODE_NORMAL_EXIT) return pre_early_init_error_code; } @@ -629,7 +629,7 @@ int BrowserMainLoop::EarlyInitialization() { if (parts_) parts_->PostEarlyInitialization(); - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } void BrowserMainLoop::PreMainMessageLoopStart() { diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index 8fe3e91b647022..947e364fd5fb16 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc @@ -12,8 +12,8 @@ #include "base/process/launch.h" #include "build/build_config.h" #include "content/public/browser/child_process_launcher_utils.h" +#include "content/public/common/result_codes.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" -#include "services/service_manager/embedder/result_codes.h" namespace content { diff --git a/content/browser/child_process_launcher_helper.h b/content/browser/child_process_launcher_helper.h index 775a7dab77c955..f7a66fffae6562 100644 --- a/content/browser/child_process_launcher_helper.h +++ b/content/browser/child_process_launcher_helper.h @@ -14,11 +14,11 @@ #include "build/build_config.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/result_codes.h" +#include "content/public/common/zygote_buildflags.h" #include "mojo/edk/embedder/embedder.h" #include "mojo/edk/embedder/outgoing_broker_client_invitation.h" #include "mojo/edk/embedder/scoped_platform_handle.h" #include "services/catalog/public/cpp/manifest_parsing_util.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #if defined(OS_ANDROID) #include "base/android/scoped_java_ref.h" @@ -35,7 +35,7 @@ #endif #if BUILDFLAG(USE_ZYGOTE_HANDLE) -#include "services/service_manager/zygote/common/zygote_handle.h" // nogncheck +#include "content/public/common/zygote_handle.h" #endif namespace base { @@ -79,7 +79,7 @@ class ChildProcessLauncherHelper : base::Process process; #if BUILDFLAG(USE_ZYGOTE_HANDLE) - service_manager::ZygoteHandle zygote = nullptr; + ZygoteHandle zygote = nullptr; #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) }; diff --git a/content/browser/child_process_launcher_helper_fuchsia.cc b/content/browser/child_process_launcher_helper_fuchsia.cc index 499346401bec84..94a09a396cb1fd 100644 --- a/content/browser/child_process_launcher_helper_fuchsia.cc +++ b/content/browser/child_process_launcher_helper_fuchsia.cc @@ -11,7 +11,6 @@ #include "content/public/browser/child_process_launcher_utils.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "mojo/edk/embedder/platform_channel_pair.h" -#include "services/service_manager/embedder/result_codes.h" namespace content { namespace internal { @@ -117,7 +116,7 @@ void ChildProcessLauncherHelper::AfterLaunchOnLauncherThread( void ChildProcessLauncherHelper::ForceNormalProcessTerminationSync( ChildProcessLauncherHelper::Process process) { DCHECK(CurrentlyOnProcessLauncherTaskRunner()); - process.process.Terminate(service_manager::RESULT_CODE_NORMAL_EXIT, true); + process.process.Terminate(RESULT_CODE_NORMAL_EXIT, true); } } // namespace internal diff --git a/content/browser/child_process_launcher_helper_linux.cc b/content/browser/child_process_launcher_helper_linux.cc index 86c6152bdaf730..8e6ee5c6e80fab 100644 --- a/content/browser/child_process_launcher_helper_linux.cc +++ b/content/browser/child_process_launcher_helper_linux.cc @@ -9,18 +9,18 @@ #include "content/browser/child_process_launcher_helper.h" #include "content/browser/child_process_launcher_helper_posix.h" #include "content/browser/sandbox_host_linux.h" +#include "content/browser/zygote_host/zygote_communication_linux.h" +#include "content/browser/zygote_host/zygote_host_impl_linux.h" #include "content/public/browser/child_process_launcher_utils.h" #include "content/public/browser/content_browser_client.h" +#include "content/public/common/common_sandbox_support_linux.h" #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" #include "content/public/common/result_codes.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" +#include "content/public/common/zygote_handle.h" #include "gpu/config/gpu_switches.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h" -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" -#include "services/service_manager/zygote/common/zygote_handle.h" -#include "services/service_manager/zygote/host/zygote_communication_linux.h" -#include "services/service_manager/zygote/host/zygote_host_impl_linux.h" namespace content { namespace internal { @@ -55,8 +55,7 @@ bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableOOPRasterization))) { const int sandbox_fd = SandboxHostLinux::GetInstance()->GetChildSocket(); - options->fds_to_remap.push_back( - std::make_pair(sandbox_fd, service_manager::GetSandboxFD())); + options->fds_to_remap.push_back(std::make_pair(sandbox_fd, GetSandboxFD())); } options->environ = delegate_->GetEnvironment(); @@ -72,7 +71,7 @@ ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( int* launch_result) { *is_synchronous_launch = true; - service_manager::ZygoteHandle zygote_handle = + ZygoteHandle zygote_handle = base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoZygote) ? nullptr : delegate_->GetZygote(); @@ -93,7 +92,7 @@ ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( // chrome::kLowestRendererOomScore in chrome/chrome_constants.h, but // that's not something we can include here.) const int kLowestRendererOomScore = 300; - service_manager::ZygoteHostImpl::GetInstance()->AdjustRendererOOMScore( + ZygoteHostImpl::GetInstance()->AdjustRendererOOMScore( handle, kLowestRendererOomScore); } #endif @@ -145,7 +144,7 @@ bool ChildProcessLauncherHelper::TerminateProcess(const base::Process& process, void ChildProcessLauncherHelper::ForceNormalProcessTerminationSync( ChildProcessLauncherHelper::Process process) { DCHECK(CurrentlyOnProcessLauncherTaskRunner()); - process.process.Terminate(service_manager::RESULT_CODE_NORMAL_EXIT, false); + process.process.Terminate(RESULT_CODE_NORMAL_EXIT, false); // On POSIX, we must additionally reap the child. if (process.zygote) { // If the renderer was created via a zygote, we have to proxy the reaping diff --git a/content/browser/child_process_launcher_helper_mac.cc b/content/browser/child_process_launcher_helper_mac.cc index 2ecaf6f2e1388d..e5eedefccc2099 100644 --- a/content/browser/child_process_launcher_helper_mac.cc +++ b/content/browser/child_process_launcher_helper_mac.cc @@ -21,7 +21,6 @@ #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "mojo/edk/embedder/scoped_platform_handle.h" #include "sandbox/mac/seatbelt_exec.h" -#include "services/service_manager/embedder/result_codes.h" #include "services/service_manager/sandbox/mac/cdm.sb.h" #include "services/service_manager/sandbox/mac/common_v2.sb.h" #include "services/service_manager/sandbox/mac/gpu_v2.sb.h" @@ -249,7 +248,7 @@ void ChildProcessLauncherHelper::ForceNormalProcessTerminationSync( DCHECK(CurrentlyOnProcessLauncherTaskRunner()); // Client has gone away, so just kill the process. Using exit code 0 means // that UMA won't treat this as a crash. - process.process.Terminate(service_manager::RESULT_CODE_NORMAL_EXIT, false); + process.process.Terminate(RESULT_CODE_NORMAL_EXIT, false); base::EnsureProcessTerminated(std::move(process.process)); } diff --git a/content/browser/child_process_launcher_helper_posix.cc b/content/browser/child_process_launcher_helper_posix.cc index d07886daf0834c..42e1c9e4cf18db 100644 --- a/content/browser/child_process_launcher_helper_posix.cc +++ b/content/browser/child_process_launcher_helper_posix.cc @@ -83,13 +83,12 @@ std::unique_ptr CreateDefaultPosixFilesToMap( base::SharedMemoryHandle shm = base::FieldTrialList::GetFieldTrialHandle(); if (shm.IsValid()) { files_to_register->Share( - service_manager::kFieldTrialDescriptor, + kFieldTrialDescriptor, base::SharedMemory::GetFdFromSharedMemoryHandle(shm)); } DCHECK(mojo_client_handle.is_valid()); - files_to_register->Share(service_manager::kMojoIPCChannel, - mojo_client_handle.handle); + files_to_register->Share(kMojoIPCChannel, mojo_client_handle.handle); // TODO(jcivelli): remove this "if defined" by making // GetAdditionalMappedFilesForChildProcess a no op on Mac. diff --git a/content/browser/child_process_launcher_helper_win.cc b/content/browser/child_process_launcher_helper_win.cc index b94069b906f4d9..45fb3384497542 100644 --- a/content/browser/child_process_launcher_helper_win.cc +++ b/content/browser/child_process_launcher_helper_win.cc @@ -18,7 +18,6 @@ #include "mojo/edk/embedder/platform_channel_pair.h" #include "mojo/edk/embedder/scoped_platform_handle.h" #include "sandbox/win/src/sandbox_types.h" -#include "services/service_manager/embedder/result_codes.h" #include "services/service_manager/sandbox/win/sandbox_win.h" namespace content { @@ -110,7 +109,7 @@ void ChildProcessLauncherHelper::ForceNormalProcessTerminationSync( DCHECK(CurrentlyOnProcessLauncherTaskRunner()); // Client has gone away, so just kill the process. Using exit code 0 means // that UMA won't treat this as a crash. - process.process.Terminate(service_manager::RESULT_CODE_NORMAL_EXIT, false); + process.process.Terminate(RESULT_CODE_NORMAL_EXIT, false); } void ChildProcessLauncherHelper::SetProcessPriorityOnLauncherThread( diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index bdd92f697a4dcb..274bc728bfedab 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -51,6 +51,7 @@ #include "content/public/common/connection_filter.h" #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/result_codes.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "content/public/common/service_manager_connection.h" diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc index f2de22ce7fe75a..fbfc64825e0307 100644 --- a/content/browser/ppapi_plugin_process_host.cc +++ b/content/browser/ppapi_plugin_process_host.cc @@ -25,16 +25,17 @@ #include "content/public/browser/content_browser_client.h" #include "content/public/common/content_constants.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/pepper_plugin_info.h" #include "content/public/common/process_type.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "content/public/common/service_names.mojom.h" +#include "content/public/common/zygote_buildflags.h" #include "mojo/edk/embedder/embedder.h" #include "net/base/network_change_notifier.h" #include "ppapi/proxy/ppapi_messages.h" #include "services/service_manager/sandbox/sandbox_type.h" #include "services/service_manager/sandbox/switches.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #include "ui/base/ui_base_switches.h" #if defined(OS_WIN) @@ -47,7 +48,7 @@ #endif #if BUILDFLAG(USE_ZYGOTE_HANDLE) -#include "services/service_manager/zygote/common/zygote_handle.h" // nogncheck +#include "content/public/common/zygote_handle.h" #endif namespace content { @@ -102,14 +103,14 @@ class PpapiPluginSandboxedProcessLauncherDelegate #endif // OS_WIN #if BUILDFLAG(USE_ZYGOTE_HANDLE) - service_manager::ZygoteHandle GetZygote() override { + ZygoteHandle GetZygote() override { const base::CommandLine& browser_command_line = *base::CommandLine::ForCurrentProcess(); base::CommandLine::StringType plugin_launcher = browser_command_line .GetSwitchValueNative(switches::kPpapiPluginLauncher); if (is_broker_ || !plugin_launcher.empty()) return nullptr; - return service_manager::GetGenericZygote(); + return GetGenericZygote(); } #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc index c9a8d3fd8c684e..464dcbd476729c 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc @@ -91,9 +91,11 @@ int32_t PepperTrueTypeFontLinux::GetTableTags(std::vector* tags) { // Get the 2 byte numTables field at an offset of 4 in the font. uint8_t num_tables_buf[2]; size_t output_length = sizeof(num_tables_buf); - if (!content::GetFontTable(fd_.get(), 0 /* tag */, 4 /* offset */, - reinterpret_cast(&num_tables_buf), - &output_length)) + if (!GetFontTable(fd_.get(), + 0 /* tag */, + 4 /* offset */, + reinterpret_cast(&num_tables_buf), + &output_length)) return PP_ERROR_FAILED; DCHECK(output_length == sizeof(num_tables_buf)); // Font data is stored in big-endian order. @@ -105,9 +107,11 @@ int32_t PepperTrueTypeFontLinux::GetTableTags(std::vector* tags) { output_length = num_tables * kTableEntrySize; std::unique_ptr table_entries(new uint8_t[output_length]); // Get the table directory entries, which follow the font header. - if (!content::GetFontTable(fd_.get(), 0 /* tag */, - kFontHeaderSize /* offset */, table_entries.get(), - &output_length)) + if (!GetFontTable(fd_.get(), + 0 /* tag */, + kFontHeaderSize /* offset */, + table_entries.get(), + &output_length)) return PP_ERROR_FAILED; DCHECK(output_length == num_tables * kTableEntrySize); @@ -134,15 +138,16 @@ int32_t PepperTrueTypeFontLinux::GetTable(uint32_t table_tag, size_t table_size = 0; // Tags are byte swapped on Linux. table_tag = base::ByteSwap(table_tag); - if (!content::GetFontTable(fd_.get(), table_tag, offset, nullptr, - &table_size)) + if (!GetFontTable(fd_.get(), table_tag, offset, nullptr, &table_size)) return PP_ERROR_FAILED; // Only retrieve as much as the caller requested. table_size = std::min(table_size, static_cast(max_data_length)); data->resize(table_size); - if (!content::GetFontTable(fd_.get(), table_tag, offset, - reinterpret_cast(&(*data)[0]), - &table_size)) + if (!GetFontTable(fd_.get(), + table_tag, + offset, + reinterpret_cast(&(*data)[0]), + &table_size)) return PP_ERROR_FAILED; return base::checked_cast(table_size); diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 20994fc0a49c32..4fa84757b37216 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -159,12 +159,14 @@ #include "content/public/common/content_constants.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/process_type.h" #include "content/public/common/resource_type.h" #include "content/public/common/result_codes.h" #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "content/public/common/service_names.mojom.h" #include "content/public/common/url_constants.h" +#include "content/public/common/zygote_buildflags.h" #include "device/gamepad/gamepad_haptics_manager.h" #include "device/gamepad/gamepad_monitor.h" #include "gpu/GLES2/gl2extchromium.h" @@ -200,7 +202,6 @@ #include "services/service_manager/runner/common/client_util.h" #include "services/service_manager/runner/common/switches.h" #include "services/service_manager/sandbox/switches.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #include "storage/browser/fileapi/sandbox_file_system_backend.h" #include "third_party/blink/public/common/page/launching_process_state.h" #include "third_party/blink/public/public_buildflags.h" @@ -261,7 +262,7 @@ #endif #if BUILDFLAG(USE_ZYGOTE_HANDLE) -#include "services/service_manager/zygote/common/zygote_handle.h" // nogncheck +#include "content/public/common/zygote_handle.h" #endif #if defined(OS_WIN) @@ -482,14 +483,14 @@ class RendererSandboxedProcessLauncherDelegate #endif // OS_WIN #if BUILDFLAG(USE_ZYGOTE_HANDLE) - service_manager::ZygoteHandle GetZygote() override { + ZygoteHandle GetZygote() override { const base::CommandLine& browser_command_line = *base::CommandLine::ForCurrentProcess(); base::CommandLine::StringType renderer_prefix = browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); if (!renderer_prefix.empty()) return nullptr; - return service_manager::GetGenericZygote(); + return GetGenericZygote(); } #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) @@ -2628,9 +2629,8 @@ void RenderProcessHostImpl::AppendRendererCommandLine( AppendCompositorCommandLineFlags(command_line); - command_line->AppendSwitchASCII( - service_manager::switches::kServiceRequestChannelToken, - child_connection_->service_token()); + command_line->AppendSwitchASCII(switches::kServiceRequestChannelToken, + child_connection_->service_token()); command_line->AppendSwitchASCII(switches::kRendererClientId, std::to_string(GetID())); } diff --git a/content/browser/utility_process_host.cc b/content/browser/utility_process_host.cc index 740cba29af4fe1..a4ffea5886f030 100644 --- a/content/browser/utility_process_host.cc +++ b/content/browser/utility_process_host.cc @@ -28,13 +28,12 @@ #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "content/public/common/service_manager_connection.h" #include "content/public/common/service_names.mojom.h" +#include "content/public/common/zygote_buildflags.h" #include "media/base/media_switches.h" #include "services/network/public/cpp/network_switches.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/sandbox/sandbox_type.h" #include "services/service_manager/sandbox/switches.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #include "ui/base/ui_base_switches.h" #include "ui/gl/gl_switches.h" @@ -44,7 +43,7 @@ #endif #if BUILDFLAG(USE_ZYGOTE_HANDLE) -#include "services/service_manager/zygote/common/zygote_handle.h" // nogncheck +#include "content/public/common/zygote_handle.h" #endif namespace content { @@ -90,12 +89,12 @@ class UtilitySandboxedProcessLauncherDelegate #endif // OS_WIN #if BUILDFLAG(USE_ZYGOTE_HANDLE) - service_manager::ZygoteHandle GetZygote() override { + ZygoteHandle GetZygote() override { if (service_manager::IsUnsandboxedSandboxType(sandbox_type_) || sandbox_type_ == service_manager::SANDBOX_TYPE_NETWORK) { return nullptr; } - return service_manager::GetGenericZygote(); + return GetGenericZygote(); } #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) diff --git a/services/service_manager/zygote/host/zygote_communication_linux.cc b/content/browser/zygote_host/zygote_communication_linux.cc similarity index 95% rename from services/service_manager/zygote/host/zygote_communication_linux.cc rename to content/browser/zygote_host/zygote_communication_linux.cc index 99fc9d74522018..f389abaf2fc388 100644 --- a/services/service_manager/zygote/host/zygote_communication_linux.cc +++ b/content/browser/zygote_host/zygote_communication_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "services/service_manager/zygote/host/zygote_communication_linux.h" +#include "content/browser/zygote_host/zygote_communication_linux.h" #include #include @@ -16,13 +16,14 @@ #include "base/pickle.h" #include "base/posix/eintr_wrapper.h" #include "base/posix/unix_domain_socket.h" -#include "services/service_manager/embedder/result_codes.h" +#include "content/common/zygote_commands_linux.h" +#include "content/public/common/content_switches.h" +#include "content/public/common/result_codes.h" #include "services/service_manager/embedder/switches.h" #include "services/service_manager/sandbox/switches.h" -#include "services/service_manager/zygote/common/zygote_commands_linux.h" #include "third_party/icu/source/i18n/unicode/timezone.h" -namespace service_manager { +namespace content { ZygoteCommunication::ZygoteCommunication() : control_fd_(), @@ -97,10 +98,12 @@ pid_t ZygoteCommunication::ForkRequest( for (std::vector::const_iterator i = argv.begin(); i != argv.end(); ++i) pickle.WriteString(*i); - std::unique_ptr timezone(icu::TimeZone::createDefault()); - icu::UnicodeString timezone_id; - pickle.WriteString16( - base::i18n::UnicodeStringToString16(timezone->getID(timezone_id))); + if (process_type == switches::kRendererProcess) { + std::unique_ptr timezone(icu::TimeZone::createDefault()); + icu::UnicodeString timezone_id; + pickle.WriteString16( + base::i18n::UnicodeStringToString16(timezone->getID(timezone_id))); + } // Fork requests contain one file descriptor for the PID oracle, and one // more for each file descriptor mapping for the child process. @@ -317,4 +320,4 @@ int ZygoteCommunication::GetSandboxStatus() { return sandbox_status_; } -} // namespace service_manager +} // namespace content diff --git a/services/service_manager/zygote/host/zygote_communication_linux.h b/content/browser/zygote_host/zygote_communication_linux.h similarity index 88% rename from services/service_manager/zygote/host/zygote_communication_linux.h rename to content/browser/zygote_host/zygote_communication_linux.h index a1b0ab06e01eb7..13185255fdcaeb 100644 --- a/services/service_manager/zygote/host/zygote_communication_linux.h +++ b/content/browser/zygote_host/zygote_communication_linux.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SERVICES_SERVICE_MANAGER_ZYGOTE_HOST_ZYGOTE_COMMUNICATION_LINUX_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_HOST_ZYGOTE_COMMUNICATION_LINUX_H_ +#ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_COMMUNICATION_LINUX_H_ +#define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_COMMUNICATION_LINUX_H_ #include #include @@ -13,23 +13,23 @@ #include #include "base/callback.h" -#include "base/component_export.h" #include "base/files/scoped_file.h" #include "base/process/kill.h" #include "base/process/launch.h" #include "base/process/process_handle.h" #include "base/synchronization/lock.h" +#include "content/common/content_export.h" namespace base { class Pickle; } // namespace base -namespace service_manager { +namespace content { // Handles interprocess communication with the Linux zygote process. The zygote // does not use standard Chrome IPC or mojo, see: // https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sandbox_ipc.md -class COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) ZygoteCommunication { +class CONTENT_EXPORT ZygoteCommunication { public: ZygoteCommunication(); ~ZygoteCommunication(); @@ -58,7 +58,7 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) ZygoteCommunication { // still running, even when they're not. When |known_dead| is true, the // process will be SIGKILL-ed first (which should have no effect if it was // really dead). This is to prevent a waiting waitpid() from blocking in - // a single-threaded Zygote. See https://crbug.com/157458. + // a single-threaded Zygote. See crbug.com/157458. base::TerminationStatus GetTerminationStatus(base::ProcessHandle handle, bool known_dead, int* exit_code); @@ -98,6 +98,6 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) ZygoteCommunication { bool init_; }; -} // namespace service_manager +} // namespace content -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_HOST_ZYGOTE_COMMUNICATION_LINUX_H_ +#endif // CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_COMMUNICATION_LINUX_H_ diff --git a/services/service_manager/zygote/host/zygote_handle_linux.cc b/content/browser/zygote_host/zygote_handle_linux.cc similarity index 75% rename from services/service_manager/zygote/host/zygote_handle_linux.cc rename to content/browser/zygote_host/zygote_handle_linux.cc index eebe241a87a481..14eabaec1d0776 100644 --- a/services/service_manager/zygote/host/zygote_handle_linux.cc +++ b/content/browser/zygote_host/zygote_handle_linux.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "services/service_manager/zygote/common/zygote_handle.h" +#include "content/public/common/zygote_handle.h" -#include "services/service_manager/zygote/host/zygote_communication_linux.h" +#include "content/browser/zygote_host/zygote_communication_linux.h" -namespace service_manager { +namespace content { namespace { // Intentionally leaked. @@ -27,4 +27,4 @@ ZygoteHandle GetGenericZygote() { return g_generic_zygote; } -} // namespace service_manager +} // namespace content diff --git a/services/service_manager/zygote/host/zygote_host_impl_linux.cc b/content/browser/zygote_host/zygote_host_impl_linux.cc similarity index 96% rename from services/service_manager/zygote/host/zygote_host_impl_linux.cc rename to content/browser/zygote_host/zygote_host_impl_linux.cc index 3bd1f728c7ca34..919128b7655231 100644 --- a/services/service_manager/zygote/host/zygote_host_impl_linux.cc +++ b/content/browser/zygote_host/zygote_host_impl_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "services/service_manager/zygote/host/zygote_host_impl_linux.h" +#include "content/browser/zygote_host/zygote_host_impl_linux.h" #include #include @@ -14,16 +14,16 @@ #include "base/process/kill.h" #include "base/process/memory.h" #include "base/strings/string_number_conversions.h" -#include "build/build_config.h" +#include "content/common/zygote_commands_linux.h" +#include "content/public/common/content_switches.h" #include "sandbox/linux/services/credentials.h" #include "sandbox/linux/services/namespace_sandbox.h" #include "sandbox/linux/suid/client/setuid_sandbox_host.h" #include "sandbox/linux/suid/common/sandbox.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h" #include "services/service_manager/sandbox/switches.h" -#include "services/service_manager/zygote/common/zygote_commands_linux.h" -namespace service_manager { +namespace content { namespace { @@ -76,8 +76,7 @@ void ZygoteHostImpl::Init(const base::CommandLine& command_line) { return; } - // Exit early if running as root without --no-sandbox. See - // https://crbug.com/638180. + // Exit early if running as root without --no-sandbox. See crbug.com/638180. // When running as root with the sandbox enabled, the browser process // crashes on zygote initialization. Running as root with the sandbox // is not supported, and if Chrome were able to display UI it would be showing @@ -105,7 +104,7 @@ void ZygoteHostImpl::Init(const base::CommandLine& command_line) { #if defined(OS_CHROMEOS) // Chrome OS has a kernel patch that restricts oom_score_adj. See - // https://crbug.com/576409 for details. + // crbug.com/576409 for details. if (!sandbox_binary_.empty()) { use_suid_sandbox_for_adj_oom_score_ = true; } else { @@ -297,4 +296,4 @@ void ZygoteHostImpl::AdjustRendererOOMScore(base::ProcessHandle pid, } #endif -} // namespace service_manager +} // namespace content diff --git a/services/service_manager/zygote/host/zygote_host_impl_linux.h b/content/browser/zygote_host/zygote_host_impl_linux.h similarity index 77% rename from services/service_manager/zygote/host/zygote_host_impl_linux.h rename to content/browser/zygote_host/zygote_host_impl_linux.h index 7f4f822fdcf24d..c527996ad37737 100644 --- a/services/service_manager/zygote/host/zygote_host_impl_linux.h +++ b/content/browser/zygote_host/zygote_host_impl_linux.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SERVICES_SERVICE_MANAGER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ +#ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ +#define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ #include @@ -11,23 +11,20 @@ #include #include "base/command_line.h" -#include "base/component_export.h" #include "base/files/scoped_file.h" #include "base/process/launch.h" #include "base/process/process_handle.h" #include "base/synchronization/lock.h" - -#include "services/service_manager/zygote/zygote_host_linux.h" +#include "content/public/browser/zygote_host_linux.h" namespace base { -template +template struct DefaultSingletonTraits; } // namespace base -namespace service_manager { +namespace content { -class COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) ZygoteHostImpl - : public ZygoteHost { +class CONTENT_EXPORT ZygoteHostImpl : public ZygoteHost { public: // Returns the singleton instance. static ZygoteHostImpl* GetInstance(); @@ -69,6 +66,6 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) ZygoteHostImpl std::set zygote_pids_; }; -} // namespace service_manager +} // namespace content -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ +#endif // CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ diff --git a/content/child/BUILD.gn b/content/child/BUILD.gn index 2c8c40f87008d5..e7d229097bd8fc 100644 --- a/content/child/BUILD.gn +++ b/content/child/BUILD.gn @@ -147,10 +147,6 @@ target(link_target_type, "child") { deps += [ "//third_party/android_tools:cpu_features" ] } - if (is_linux) { - deps += [ "//services/service_manager/zygote" ] - } - if (is_win) { libs = [ "dwrite.lib" ] } diff --git a/content/child/child_process_sandbox_support_impl_linux.cc b/content/child/child_process_sandbox_support_impl_linux.cc index 7899935f659e40..587ddeab58ec65 100644 --- a/content/child/child_process_sandbox_support_impl_linux.cc +++ b/content/child/child_process_sandbox_support_impl_linux.cc @@ -15,8 +15,8 @@ #include "base/posix/unix_domain_socket.h" #include "base/sys_byteorder.h" #include "base/trace_event/trace_event.h" +#include "content/public/common/common_sandbox_support_linux.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h" -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" #include "third_party/blink/public/platform/linux/web_fallback_font.h" #include "third_party/blink/public/platform/web_font_render_style.h" #include "third_party/blink/public/platform/web_string.h" @@ -37,7 +37,7 @@ void GetFallbackFontForCharacter(int32_t character, uint8_t buf[512]; const ssize_t n = base::UnixDomainSocket::SendRecvMsg( - service_manager::GetSandboxFD(), buf, sizeof(buf), nullptr, request); + GetSandboxFD(), buf, sizeof(buf), nullptr, request); std::string family_name; std::string filename; @@ -88,7 +88,7 @@ void GetRenderStyleForStrike(const char* family, uint8_t buf[512]; const ssize_t n = base::UnixDomainSocket::SendRecvMsg( - service_manager::GetSandboxFD(), buf, sizeof(buf), nullptr, request); + GetSandboxFD(), buf, sizeof(buf), nullptr, request); if (n == -1) return; @@ -127,9 +127,8 @@ int MatchFontWithFallback(const std::string& face, request.WriteUInt32(fallback_family); uint8_t reply_buf[64]; int fd = -1; - base::UnixDomainSocket::SendRecvMsg(service_manager::GetSandboxFD(), - reply_buf, sizeof(reply_buf), &fd, - request); + base::UnixDomainSocket::SendRecvMsg(GetSandboxFD(), reply_buf, + sizeof(reply_buf), &fd, request); return fd; } diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc index b50ca6932731cc..1325ce03a71239 100644 --- a/content/child/child_thread_impl.cc +++ b/content/child/child_thread_impl.cc @@ -44,6 +44,7 @@ #include "content/public/common/connection_filter.h" #include "content/public/common/content_client.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/service_manager_connection.h" #include "content/public/common/service_names.mojom.h" #include "content/public/common/simple_connection_filter.h" @@ -63,7 +64,6 @@ #include "services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" #include "services/resource_coordinator/public/mojom/service_constants.mojom.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/runner/common/client_util.h" @@ -247,9 +247,8 @@ InitializeMojoIPCChannel() { mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( *base::CommandLine::ForCurrentProcess()); #elif defined(OS_POSIX) - platform_channel.reset( - mojo::edk::PlatformHandle(base::GlobalDescriptors::GetInstance()->Get( - service_manager::kMojoIPCChannel))); + platform_channel.reset(mojo::edk::PlatformHandle( + base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel))); #endif // Mojo isn't supported on all child process types. // TODO(crbug.com/604282): Support Mojo in the remaining processes. @@ -455,7 +454,7 @@ void ChildThreadImpl::Init(const Options& options) { std::string service_request_token = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - service_manager::switches::kServiceRequestChannelToken); + switches::kServiceRequestChannelToken); if (!service_request_token.empty() && invitation) { service_request_pipe = invitation->ExtractMessagePipe(service_request_token); diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index 8723a506df5a0e..78a1061d0fa1bc 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn @@ -259,6 +259,7 @@ source_set("common") { "sandbox_init_mac.cc", "sandbox_init_win.cc", "savable_subframe.h", + "send_zygote_child_ping_linux.cc", "service_manager/service_manager_connection_impl.cc", "service_manager/service_manager_connection_impl.h", "service_worker/service_worker_loader_helpers.cc", @@ -297,6 +298,7 @@ source_set("common") { "visual_properties.h", "wrapper_shared_url_loader_factory.cc", "wrapper_shared_url_loader_factory.h", + "zygote_commands_linux.h", ] configs += [ @@ -330,6 +332,7 @@ source_set("common") { "//content/app/resources", "//content/public/common:interfaces", "//content/public/common:service_names", + "//content/public/common:zygote_buildflags", "//device/base/synchronization", "//device/bluetooth", "//gpu", @@ -365,7 +368,6 @@ source_set("common") { "//services/service_manager/public/cpp", "//services/service_manager/public/mojom", "//services/service_manager/runner/common", - "//services/service_manager/zygote:zygote_buildflags", "//services/ui/public/interfaces", "//services/video_capture/public/mojom", "//services/viz/public/interfaces", diff --git a/content/common/common_sandbox_support_linux.cc b/content/common/common_sandbox_support_linux.cc index c80e44a6d2bd05..ed806b7f998fd8 100644 --- a/content/common/common_sandbox_support_linux.cc +++ b/content/common/common_sandbox_support_linux.cc @@ -4,14 +4,21 @@ #include "content/public/common/common_sandbox_support_linux.h" +#include #include #include #include #include "base/numerics/safe_conversions.h" +#include "base/pickle.h" #include "base/posix/eintr_wrapper.h" +#include "base/posix/global_descriptors.h" +#include "base/posix/unix_domain_socket.h" #include "base/sys_byteorder.h" +#include "base/trace_event/trace_event.h" +#include "content/public/common/content_descriptors.h" +#include "services/service_manager/sandbox/linux/sandbox_linux.h" namespace content { @@ -90,4 +97,23 @@ bool GetFontTable(int fd, return true; } -} // namespace content \ No newline at end of file +int MakeSharedMemorySegmentViaIPC(size_t length, bool executable) { + base::Pickle request; + request.WriteInt( + service_manager::SandboxLinux::METHOD_MAKE_SHARED_MEMORY_SEGMENT); + request.WriteUInt32(length); + request.WriteBool(executable); + uint8_t reply_buf[10]; + int result_fd; + ssize_t result = base::UnixDomainSocket::SendRecvMsg( + GetSandboxFD(), reply_buf, sizeof(reply_buf), &result_fd, request); + if (result == -1) + return -1; + return result_fd; +} + +int GetSandboxFD() { + return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor; +} + +} // namespace content diff --git a/services/service_manager/zygote/common/send_zygote_child_ping_linux.cc b/content/common/send_zygote_child_ping_linux.cc similarity index 58% rename from services/service_manager/zygote/common/send_zygote_child_ping_linux.cc rename to content/common/send_zygote_child_ping_linux.cc index 1245398f52c92b..f7f1685834b732 100644 --- a/services/service_manager/zygote/common/send_zygote_child_ping_linux.cc +++ b/content/common/send_zygote_child_ping_linux.cc @@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "services/service_manager/zygote/common/send_zygote_child_ping_linux.h" +#include "content/public/common/send_zygote_child_ping_linux.h" #include #include "base/posix/unix_domain_socket.h" -#include "services/service_manager/zygote/common/zygote_commands_linux.h" +#include "content/common/zygote_commands_linux.h" -namespace service_manager { +namespace content { bool SendZygoteChildPing(int fd) { - return base::UnixDomainSocket::SendMsg(fd, kZygoteChildPingMessage, + return base::UnixDomainSocket::SendMsg(fd, + kZygoteChildPingMessage, sizeof(kZygoteChildPingMessage), std::vector()); } -} // namespace service_manager +} // namespace content diff --git a/services/service_manager/zygote/common/zygote_commands_linux.h b/content/common/zygote_commands_linux.h similarity index 84% rename from services/service_manager/zygote/common/zygote_commands_linux.h rename to content/common/zygote_commands_linux.h index 12b72128fd6cbd..24f3bf6517e9af 100644 --- a/services/service_manager/zygote/common/zygote_commands_linux.h +++ b/content/common/zygote_commands_linux.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_COMMANDS_LINUX_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_COMMANDS_LINUX_H_ +#ifndef CONTENT_COMMON_ZYGOTE_COMMANDS_LINUX_H_ +#define CONTENT_COMMON_ZYGOTE_COMMANDS_LINUX_H_ #include #include "base/posix/global_descriptors.h" -namespace service_manager { +namespace content { // Contents of the initial message sent from the zygote to the browser right // after it starts. @@ -49,6 +49,6 @@ enum { kZygoteCommandForkRealPID = 4 }; -} // namespace service_manager +} // namespace content -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_COMMANDS_LINUX_H_ +#endif // CONTENT_COMMON_ZYGOTE_COMMANDS_LINUX_H_ diff --git a/content/gpu/BUILD.gn b/content/gpu/BUILD.gn index 9a8b1ca6b4f4ec..3e858724af3bd1 100644 --- a/content/gpu/BUILD.gn +++ b/content/gpu/BUILD.gn @@ -93,10 +93,6 @@ target(link_target_type, "gpu_sources") { deps += [ "//media" ] } - if (is_linux) { - deps += [ "//services/service_manager/zygote" ] - } - if (mojo_media_host == "gpu") { deps += [ "//media/mojo/services" ] } diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc index d9bf4b47b91389..d9c8b6d8c61873 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc @@ -80,9 +80,9 @@ #if defined(OS_LINUX) #include "content/common/font_config_ipc_linux.h" #include "content/gpu/gpu_sandbox_hook_linux.h" +#include "content/public/common/common_sandbox_support_linux.h" #include "content/public/common/sandbox_init.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h" -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" #include "third_party/skia/include/ports/SkFontConfigInterface.h" #endif @@ -343,8 +343,7 @@ int GpuMain(const MainFunctionParams& parameters) { SkGraphics::Init(); #if defined(OS_LINUX) // Set up the font IPC so that the GPU process can create typefaces. - SkFontConfigInterface::SetGlobal( - new FontConfigIPC(service_manager::GetSandboxFD())) + SkFontConfigInterface::SetGlobal(new FontConfigIPC(GetSandboxFD())) ->unref(); #endif } diff --git a/content/public/android/BUILD.gn b/content/public/android/BUILD.gn index 8e9030498f4309..d24588c2106f3e 100644 --- a/content/public/android/BUILD.gn +++ b/content/public/android/BUILD.gn @@ -330,6 +330,7 @@ java_cpp_enum("content_public_android_java_enums_srcjar") { "//content/public/browser/navigation_controller.h", "//content/public/common/browser_controls_state.h", "//content/public/common/console_message_level.h", + "//content/public/common/result_codes.h", "//content/public/common/screen_orientation_values.h", "//content/public/common/speech_recognition_error.h", ] diff --git a/content/public/app/content_main_delegate.cc b/content/public/app/content_main_delegate.cc index f15a137486ec1b..5f2631cd6a765d 100644 --- a/content/public/app/content_main_delegate.cc +++ b/content/public/app/content_main_delegate.cc @@ -45,8 +45,7 @@ bool ContentMainDelegate::DelaySandboxInitialization( #elif defined(OS_LINUX) void ContentMainDelegate::ZygoteStarting( - std::vector>* - delegates) {} + std::vector>* delegates) {} #endif // defined(OS_LINUX) diff --git a/content/public/app/content_main_delegate.h b/content/public/app/content_main_delegate.h index 94d61757146fe3..a53d40b4efde26 100644 --- a/content/public/app/content_main_delegate.h +++ b/content/public/app/content_main_delegate.h @@ -21,7 +21,6 @@ class CommandLine; namespace service_manager { class BackgroundServiceManager; class Identity; -class ZygoteForkDelegate; } // namespace service_manager namespace content { @@ -30,6 +29,7 @@ class ContentBrowserClient; class ContentGpuClient; class ContentRendererClient; class ContentUtilityClient; +class ZygoteForkDelegate; struct MainFunctionParams; class CONTENT_EXPORT ContentMainDelegate { @@ -81,8 +81,7 @@ class CONTENT_EXPORT ContentMainDelegate { // specify one or more zygote delegates if it wishes by storing them in // |*delegates|. virtual void ZygoteStarting( - std::vector>* - delegates); + std::vector>* delegates); // Called every time the zygote process forks. virtual void ZygoteForked() {} diff --git a/content/public/browser/BUILD.gn b/content/public/browser/BUILD.gn index 6143c79596e06d..1f8e63ffa7939e 100644 --- a/content/public/browser/BUILD.gn +++ b/content/public/browser/BUILD.gn @@ -302,6 +302,7 @@ jumbo_source_set("browser_sources") { "websocket_handshake_request_info.h", "webvr_service_provider.cc", "webvr_service_provider.h", + "zygote_host_linux.h", ] configs += [ "//build/config:precompiled_headers", @@ -338,7 +339,6 @@ jumbo_source_set("browser_sources") { "//media/capture", "//net", "//ppapi/c", - "//services/service_manager/embedder:embedder_result_codes", "//ui/accessibility", "//ui/base", "//ui/events", diff --git a/content/public/browser/browser_main_parts.cc b/content/public/browser/browser_main_parts.cc index 130ad375fea492..108bf6b42359e5 100644 --- a/content/public/browser/browser_main_parts.cc +++ b/content/public/browser/browser_main_parts.cc @@ -4,7 +4,7 @@ #include "content/public/browser/browser_main_parts.h" -#include "services/service_manager/embedder/result_codes.h" +#include "content/public/common/result_codes.h" namespace content { @@ -13,7 +13,7 @@ bool BrowserMainParts::ShouldContentCreateFeatureList() { } int BrowserMainParts::PreEarlyInitialization() { - return service_manager::RESULT_CODE_NORMAL_EXIT; + return RESULT_CODE_NORMAL_EXIT; } int BrowserMainParts::PreCreateThreads() { diff --git a/content/public/browser/child_process_termination_info.h b/content/public/browser/child_process_termination_info.h index 0b65f52ae47a0f..01c67b534d949a 100644 --- a/content/public/browser/child_process_termination_info.h +++ b/content/public/browser/child_process_termination_info.h @@ -18,7 +18,7 @@ struct ChildProcessTerminationInfo { // contain a platform specific launch failure error code. Otherwise, it will // contain the exit code for the process (e.g. status from waitpid if on // posix, from GetExitCodeProcess on Windows). - int exit_code = service_manager::RESULT_CODE_NORMAL_EXIT; + int exit_code = RESULT_CODE_NORMAL_EXIT; #if defined(OS_ANDROID) // True if child service has strong or moderate binding at time of death. diff --git a/services/service_manager/zygote/zygote_host_linux.h b/content/public/browser/zygote_host_linux.h similarity index 74% rename from services/service_manager/zygote/zygote_host_linux.h rename to content/public/browser/zygote_host_linux.h index 2426b60a6f9dc4..537d6d3f7638c9 100644 --- a/services/service_manager/zygote/zygote_host_linux.h +++ b/content/public/browser/zygote_host_linux.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_HOST_LINUX_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_HOST_LINUX_H_ +#ifndef CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_LINUX_H_ +#define CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_LINUX_H_ #include -#include "base/component_export.h" #include "base/process/process.h" +#include "content/common/content_export.h" -namespace service_manager { +namespace content { // https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote.md @@ -19,7 +19,7 @@ namespace service_manager { class ZygoteHost { public: // Returns the singleton instance. - static COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) ZygoteHost* GetInstance(); + CONTENT_EXPORT static ZygoteHost* GetInstance(); virtual ~ZygoteHost() {} @@ -37,6 +37,6 @@ class ZygoteHost { int score) = 0; }; -} // namespace service_manager +} // namespace content -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_HOST_LINUX_H_ +#endif // CONTENT_PUBLIC_BROWSER_ZYGOTE_HOST_LINUX_H_ diff --git a/content/public/common/BUILD.gn b/content/public/common/BUILD.gn index 2082e82632d6af..ebb4d5efdacfaa 100644 --- a/content/public/common/BUILD.gn +++ b/content/public/common/BUILD.gn @@ -7,6 +7,7 @@ import("//build/config/chromecast_build.gni") import("//build/config/features.gni") import("//build/config/jumbo.gni") import("//build/config/ui.gni") +import("//content/public/common/zygote_features.gni") import("//media/media_options.gni") import("//mojo/public/tools/bindings/mojom.gni") import("//ppapi/buildflags/buildflags.gni") @@ -31,10 +32,6 @@ source_set("result_codes") { sources = [ "result_codes.h", ] - - deps = [ - "//services/service_manager/embedder:embedder_result_codes", - ] } # This target allows other targets to depend on content_descriptors.h which is @@ -73,10 +70,12 @@ config("static_switches_defines") { source_set("static_switches") { public = [ "content_switches.h", + "mojo_channel_switches.h", ] sources = [ "//content/common/content_export.h", "content_switches.cc", + "mojo_channel_switches.cc", ] public_configs = [ ":static_switches_defines" ] @@ -171,6 +170,8 @@ jumbo_source_set("common_sources") { "menu_item.h", "mhtml_generation_params.cc", "mhtml_generation_params.h", + "mojo_channel_switches.cc", + "mojo_channel_switches.h", "network_connection_tracker.cc", "network_connection_tracker.h", "notification_resources.cc", @@ -212,6 +213,7 @@ jumbo_source_set("common_sources") { "screen_info.cc", "screen_info.h", "screen_orientation_values.h", + "send_zygote_child_ping_linux.h", "service_manager_connection.h", "simple_connection_filter.cc", "simple_connection_filter.h", @@ -240,6 +242,7 @@ jumbo_source_set("common_sources") { "webplugininfo.cc", "webplugininfo.h", "webplugininfo_param_traits.h", + "zygote_fork_delegate_linux.h", ] configs += [ @@ -252,6 +255,7 @@ jumbo_source_set("common_sources") { public_deps = [ ":interfaces", ":service_names", + ":zygote_buildflags", "//content/common", "//ipc", "//media/capture:capture_base", @@ -279,9 +283,7 @@ jumbo_source_set("common_sources") { "//ppapi/buildflags", "//ppapi/c", "//services/network/public/cpp", - "//services/service_manager/embedder:embedder_result_codes", "//services/service_manager/public/cpp", - "//services/service_manager/zygote:zygote_buildflags", "//skia", "//storage/common", "//third_party/blink/public/common", @@ -303,10 +305,6 @@ jumbo_source_set("common_sources") { deps += [ "//content/public/android:jni" ] } - if (is_linux) { - deps += [ "//services/service_manager/zygote" ] - } - # //content/common needs to include public headers. allow_circular_includes_from = [ ":interfaces", @@ -327,6 +325,10 @@ jumbo_source_set("common_sources") { "webrtc_ip_handling_policy.h", ] } + + if (use_zygote_handle) { + sources += [ "zygote_handle.h" ] + } } buildflag_header("buildflags") { @@ -346,6 +348,11 @@ source_set("feature_h264_with_openh264_ffmpeg") { ] } +buildflag_header("zygote_buildflags") { + header = "zygote_buildflags.h" + flags = [ "USE_ZYGOTE_HANDLE=$use_zygote_handle" ] +} + mojom("interfaces") { # Must depend on //content/public/common/ instead, for component build. visibility = [ diff --git a/content/public/common/common_sandbox_support_linux.h b/content/public/common/common_sandbox_support_linux.h index e9e8b5e1df574e..dc63dd29deb15b 100644 --- a/content/public/common/common_sandbox_support_linux.h +++ b/content/public/common/common_sandbox_support_linux.h @@ -29,6 +29,20 @@ CONTENT_EXPORT bool GetFontTable(int fd, uint8_t* output, size_t* output_length); -} // namespace content +// Returns a file descriptor for a shared memory segment. The +// executable flag indicates that the caller intends to use mprotect +// with PROT_EXEC after making a mapping, but not that it intends to +// mmap with PROT_EXEC in the first place. (Some systems, such as +// ChromeOS, disallow PROT_EXEC in mmap on /dev/shm files but do allow +// PROT_EXEC in mprotect on mappings from such files. This function +// can yield an object that has that constraint.) +CONTENT_EXPORT int MakeSharedMemorySegmentViaIPC(size_t length, + bool executable); + +// Gets the well-known file descriptor on which we expect to find the +// sandbox IPC channel. +CONTENT_EXPORT int GetSandboxFD(); + +}; // namespace content #endif // CONTENT_PUBLIC_COMMON_COMMON_SANDBOX_SUPPORT_LINUX_H_ diff --git a/content/public/common/content_descriptors.h b/content/public/common/content_descriptors.h index bccbe8904110bd..35bf7abd24a336 100644 --- a/content/public/common/content_descriptors.h +++ b/content/public/common/content_descriptors.h @@ -7,13 +7,16 @@ #include "build/build_config.h" -#include "services/service_manager/embedder/descriptors.h" - // This is a list of global descriptor keys to be used with the // base::GlobalDescriptors object (see base/posix/global_descriptors.h) enum { + kCrashDumpSignal = 0, + kSandboxIPCChannel, // https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sandbox_ipc.md + kMojoIPCChannel, + kFieldTrialDescriptor, + #if defined(OS_ANDROID) - kAndroidPropertyDescriptor = service_manager::kFirstEmbedderDescriptor, + kAndroidPropertyDescriptor, kAndroidICUDataDescriptor, #endif diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 2bd7b3b5a2dd53..0ec46962d6dde9 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -847,6 +847,12 @@ const char kValidateInputEventStream[] = "validate-input-event-stream"; // kWaitForDebugger flag passed on or not. const char kWaitForDebuggerChildren[] = "wait-for-debugger-children"; +// The prefix used when starting the zygote process. (i.e. 'gdb --args') +const char kZygoteCmdPrefix[] = "zygote-cmd-prefix"; + +// Causes the process to run as a renderer zygote. +const char kZygoteProcess[] = "zygote"; + #if BUILDFLAG(ENABLE_WEBRTC) // Disables encryption of RTP Media for WebRTC. When Chrome embeds Content, it // ignores this switch on its stable and beta channels. diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 61fd08c20fbabe..9a64c0d96e6a55 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -234,6 +234,8 @@ CONTENT_EXPORT extern const char kUtilityStartupDialog[]; CONTENT_EXPORT extern const char kV8CacheOptions[]; CONTENT_EXPORT extern const char kValidateInputEventStream[]; CONTENT_EXPORT extern const char kWaitForDebuggerChildren[]; +CONTENT_EXPORT extern const char kZygoteCmdPrefix[]; +CONTENT_EXPORT extern const char kZygoteProcess[]; #if BUILDFLAG(ENABLE_WEBRTC) CONTENT_EXPORT extern const char kDisableWebRtcEncryption[]; diff --git a/content/public/common/mojo_channel_switches.cc b/content/public/common/mojo_channel_switches.cc new file mode 100644 index 00000000000000..9cd2c3c1bb5fcb --- /dev/null +++ b/content/public/common/mojo_channel_switches.cc @@ -0,0 +1,13 @@ +// Copyright 2015 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. + +#include "content/public/common/mojo_channel_switches.h" + +namespace switches { + +// The token to use to construct the message pipe for a service in a child +// process. +const char kServiceRequestChannelToken[] = "service-request-channel-token"; + +} // namespace switches diff --git a/content/public/common/mojo_channel_switches.h b/content/public/common/mojo_channel_switches.h new file mode 100644 index 00000000000000..954a86f691c023 --- /dev/null +++ b/content/public/common/mojo_channel_switches.h @@ -0,0 +1,16 @@ +// Copyright 2015 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 CONTENT_PUBLIC_COMMON_MOJO_CHANNEL_SWITCHES_H_ +#define CONTENT_PUBLIC_COMMON_MOJO_CHANNEL_SWITCHES_H_ + +#include "content/common/content_export.h" + +namespace switches { + +CONTENT_EXPORT extern const char kServiceRequestChannelToken[]; + +} // namespace switches + +#endif // CONTENT_PUBLIC_COMMON_MOJO_CHANNEL_SWITCHES_H_ diff --git a/content/public/common/result_codes.h b/content/public/common/result_codes.h index a0b0b7482e96e6..cd66a5bdc422fa 100644 --- a/content/public/common/result_codes.h +++ b/content/public/common/result_codes.h @@ -5,8 +5,6 @@ #ifndef CONTENT_PUBLIC_COMMON_RESULT_CODES_H_ #define CONTENT_PUBLIC_COMMON_RESULT_CODES_H_ -#include "services/service_manager/embedder/result_codes.h" - namespace content { // This file consolidates all the return codes for the browser and renderer @@ -30,10 +28,11 @@ namespace content { // TODO(wfh): Break the dependency so it is possible to add more values. enum ResultCode { - RESULT_CODE_CONTENT_START = service_manager::RESULT_CODE_LAST_CODE, + // Process terminated normally. + RESULT_CODE_NORMAL_EXIT, // Process was killed by user or system. - RESULT_CODE_KILLED = RESULT_CODE_CONTENT_START, + RESULT_CODE_KILLED, // Process hung. RESULT_CODE_HUNG, diff --git a/content/public/common/sandboxed_process_launcher_delegate.cc b/content/public/common/sandboxed_process_launcher_delegate.cc index 1b3d27134ee0e3..2574f49e44bbba 100644 --- a/content/public/common/sandboxed_process_launcher_delegate.cc +++ b/content/public/common/sandboxed_process_launcher_delegate.cc @@ -5,7 +5,11 @@ #include "content/public/common/sandboxed_process_launcher_delegate.h" #include "build/build_config.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" +#include "content/public/common/zygote_buildflags.h" + +#if BUILDFLAG(USE_ZYGOTE_HANDLE) +#include "content/public/common/zygote_handle.h" +#endif namespace content { @@ -33,7 +37,7 @@ bool SandboxedProcessLauncherDelegate::ShouldLaunchElevated() { #endif // defined(OS_WIN) #if BUILDFLAG(USE_ZYGOTE_HANDLE) -service_manager::ZygoteHandle SandboxedProcessLauncherDelegate::GetZygote() { +ZygoteHandle SandboxedProcessLauncherDelegate::GetZygote() { return nullptr; } #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) diff --git a/content/public/common/sandboxed_process_launcher_delegate.h b/content/public/common/sandboxed_process_launcher_delegate.h index 644e461607c225..80043c88767517 100644 --- a/content/public/common/sandboxed_process_launcher_delegate.h +++ b/content/public/common/sandboxed_process_launcher_delegate.h @@ -10,12 +10,12 @@ #include "base/process/process.h" #include "build/build_config.h" #include "content/common/content_export.h" +#include "content/public/common/zygote_buildflags.h" #include "services/service_manager/sandbox/sandbox_delegate.h" #include "services/service_manager/sandbox/sandbox_type.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" #if BUILDFLAG(USE_ZYGOTE_HANDLE) -#include "services/service_manager/zygote/common/zygote_handle.h" // nogncheck +#include "content/public/common/zygote_handle.h" #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) namespace content { @@ -45,7 +45,7 @@ class CONTENT_EXPORT SandboxedProcessLauncherDelegate // Returns the zygote used to launch the process. // NOTE: For now Chrome always uses the same zygote for performance reasons. // http://crbug.com/569191 - virtual service_manager::ZygoteHandle GetZygote(); + virtual ZygoteHandle GetZygote(); #endif // BUILDFLAG(USE_ZYGOTE_HANDLE) #if defined(OS_POSIX) diff --git a/content/public/common/send_zygote_child_ping_linux.h b/content/public/common/send_zygote_child_ping_linux.h new file mode 100644 index 00000000000000..ae971a1b290289 --- /dev/null +++ b/content/public/common/send_zygote_child_ping_linux.h @@ -0,0 +1,18 @@ +// Copyright 2014 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 CONTENT_PUBLIC_COMMON_SEND_ZYGOTE_CHILD_PING_LINUX_H_ +#define CONTENT_PUBLIC_COMMON_SEND_ZYGOTE_CHILD_PING_LINUX_H_ + +#include "content/common/content_export.h" + +namespace content { + +// Sends a zygote child "ping" message to browser process via socket |fd|. +// Returns true on success. +CONTENT_EXPORT bool SendZygoteChildPing(int fd); + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_SEND_ZYGOTE_CHILD_PING_LINUX_H_ diff --git a/services/service_manager/zygote/common/zygote_features.gni b/content/public/common/zygote_features.gni similarity index 100% rename from services/service_manager/zygote/common/zygote_features.gni rename to content/public/common/zygote_features.gni diff --git a/services/service_manager/zygote/common/zygote_fork_delegate_linux.h b/content/public/common/zygote_fork_delegate_linux.h similarity index 85% rename from services/service_manager/zygote/common/zygote_fork_delegate_linux.h rename to content/public/common/zygote_fork_delegate_linux.h index aec457b8750b86..8a15434ecc2ec6 100644 --- a/services/service_manager/zygote/common/zygote_fork_delegate_linux.h +++ b/content/public/common/zygote_fork_delegate_linux.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ +#ifndef CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ +#define CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ #include @@ -14,7 +14,7 @@ // to C++11. #include "base/process/kill.h" -namespace service_manager { +namespace content { // The ZygoteForkDelegate allows the Chrome Linux zygote to delegate // fork operations to another class that knows how to do some @@ -44,10 +44,8 @@ class ZygoteForkDelegate { // Returns 'true' if the delegate would like to handle a given fork // request. Otherwise returns false. Optionally, fills in uma_name et al // with a report the helper wants to make via UMA_HISTOGRAM_ENUMERATION. - virtual bool CanHelp(const std::string& process_type, - std::string* uma_name, - int* uma_sample, - int* uma_boundary_value) = 0; + virtual bool CanHelp(const std::string& process_type, std::string* uma_name, + int* uma_sample, int* uma_boundary_value) = 0; // Indexes of FDs in the vector passed to Fork(). enum { @@ -79,12 +77,11 @@ class ZygoteForkDelegate { // |known_dead| indicates that the process is already dead and that a // blocking wait() should be performed. In this case, GetTerminationStatus() // will send a SIGKILL to the target process first. - virtual bool GetTerminationStatus(pid_t pid, - bool known_dead, + virtual bool GetTerminationStatus(pid_t pid, bool known_dead, base::TerminationStatus* status, int* exit_code) = 0; }; -} // namespace service_manager +} // namespace content -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ +#endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ diff --git a/services/service_manager/zygote/common/zygote_handle.h b/content/public/common/zygote_handle.h similarity index 71% rename from services/service_manager/zygote/common/zygote_handle.h rename to content/public/common/zygote_handle.h index 1b1da575db8e65..5c21c883072b54 100644 --- a/services/service_manager/zygote/common/zygote_handle.h +++ b/content/public/common/zygote_handle.h @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_HANDLE_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_HANDLE_H_ +#ifndef CONTENT_PUBLIC_COMMON_ZYGOTE_HANDLE_H_ +#define CONTENT_PUBLIC_COMMON_ZYGOTE_HANDLE_H_ #include "base/callback.h" #include "base/command_line.h" -#include "base/component_export.h" #include "base/files/scoped_file.h" #include "build/build_config.h" -#include "services/service_manager/zygote/common/zygote_buildflags.h" +#include "content/common/content_export.h" +#include "content/public/common/zygote_buildflags.h" #if !BUILDFLAG(USE_ZYGOTE_HANDLE) #error "Can not use zygote handles without USE_ZYGOTE_HANDLE" #endif -namespace service_manager { +namespace content { #if defined(OS_POSIX) class ZygoteCommunication; @@ -31,17 +31,15 @@ using ZygoteHandle = ZygoteCommunication*; // should actually launch the process, after adding additional command line // switches to the ones composed by this function. It returns the pid created, // and provides a control fd for it. - -COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) -ZygoteHandle CreateGenericZygote( +CONTENT_EXPORT ZygoteHandle CreateGenericZygote( base::OnceCallback launcher); // Returns a handle to a global generic zygote object. This function allows the // browser to launch and use a single zygote process until the performance // issues around launching multiple zygotes are resolved. // http://crbug.com/569191 -COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) ZygoteHandle GetGenericZygote(); +CONTENT_EXPORT ZygoteHandle GetGenericZygote(); -} // namespace service_manager +} // namespace content -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_ZYGOTE_HANDLE_H_ +#endif // CONTENT_PUBLIC_COMMON_ZYGOTE_HANDLE_H_ diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn index 18bbaa17db44d6..261a8928863464 100644 --- a/content/renderer/BUILD.gn +++ b/content/renderer/BUILD.gn @@ -614,10 +614,6 @@ target(link_target_type, "renderer") { ] } - if (is_linux) { - deps += [ "//services/service_manager/zygote" ] - } - if (is_fuchsia) { sources += [ "render_view_fuchsia.cc", diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc index e6df9c7b1125f9..035a0f9c271038 100644 --- a/content/renderer/renderer_main.cc +++ b/content/renderer/renderer_main.cc @@ -45,8 +45,8 @@ #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ !defined(OS_FUCHSIA) #include "content/common/font_config_ipc_linux.h" +#include "content/public/common/common_sandbox_support_linux.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h" -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" #include "third_party/skia/include/ports/SkFontConfigInterface.h" #endif @@ -132,8 +132,7 @@ int RendererMain(const MainFunctionParams& parameters) { // This call could already have been made from zygote_main_linux.cc. However // we need to do it here if Zygote is disabled. if (process_command_line.HasSwitch(switches::kNoZygote)) { - SkFontConfigInterface::SetGlobal( - new FontConfigIPC(service_manager::GetSandboxFD())) + SkFontConfigInterface::SetGlobal(new FontConfigIPC(GetSandboxFD())) ->unref(); } #endif diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn index bd604be447c3af..c76bc16d8ae305 100644 --- a/content/shell/BUILD.gn +++ b/content/shell/BUILD.gn @@ -282,7 +282,6 @@ static_library("content_shell_lib") { "//sandbox", "//services/device/public/mojom", "//services/network/public/cpp", - "//services/service_manager/embedder:embedder_result_codes", "//services/service_manager/public/cpp", "//services/test/echo:lib", "//services/test/echo/public/mojom", diff --git a/content/shell/DEPS b/content/shell/DEPS index 05b041eac81ff6..818f73869ec6c5 100644 --- a/content/shell/DEPS +++ b/content/shell/DEPS @@ -39,9 +39,6 @@ include_rules = [ "+components/viz/common/resources", "+components/viz/common/switches.h", "+services/test/echo", - - # Access to the process specific switches. - "+services/service_manager/embedder", ] specific_include_rules = { diff --git a/content/shell/app/shell_crash_reporter_client.cc b/content/shell/app/shell_crash_reporter_client.cc index 8405518bcb33ee..0c0d9068ecfee1 100644 --- a/content/shell/app/shell_crash_reporter_client.cc +++ b/content/shell/app/shell_crash_reporter_client.cc @@ -13,7 +13,6 @@ #include "build/build_config.h" #include "content/public/common/content_switches.h" #include "content/shell/common/shell_switches.h" -#include "services/service_manager/embedder/switches.h" #if defined(OS_ANDROID) #include "content/shell/android/shell_descriptors.h" @@ -80,7 +79,7 @@ bool ShellCrashReporterClient::EnableBreakpadForProcess( const std::string& process_type) { return process_type == switches::kRendererProcess || process_type == switches::kPpapiPluginProcess || - process_type == service_manager::switches::kZygoteProcess || + process_type == switches::kZygoteProcess || process_type == switches::kGpuProcess; } diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc index b67785461a0dbd..ce7dd221ab1da0 100644 --- a/content/shell/app/shell_main_delegate.cc +++ b/content/shell/app/shell_main_delegate.cc @@ -43,7 +43,6 @@ #include "net/cookies/cookie_monster.h" #include "ppapi/buildflags/buildflags.h" #include "services/network/public/cpp/network_switches.h" -#include "services/service_manager/embedder/switches.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_switches.h" @@ -294,7 +293,7 @@ void ShellMainDelegate::PreSandboxStartup() { crash_reporter::InitializeCrashpad(process_type.empty(), process_type); #elif defined(OS_LINUX) // Reporting for sub-processes will be initialized in ZygoteForked. - if (process_type != service_manager::switches::kZygoteProcess) + if (process_type != switches::kZygoteProcess) breakpad::InitCrashReporter(process_type); #elif defined(OS_ANDROID) if (process_type.empty()) diff --git a/content/shell/browser/shell_browser_main_parts.cc b/content/shell/browser/shell_browser_main_parts.cc index 2735c001a26ec0..aea04f3a8b6909 100644 --- a/content/shell/browser/shell_browser_main_parts.cc +++ b/content/shell/browser/shell_browser_main_parts.cc @@ -19,6 +19,7 @@ #include "content/public/browser/storage_partition.h" #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" +#include "content/public/common/result_codes.h" #include "content/public/common/url_constants.h" #include "content/shell/android/shell_descriptors.h" #include "content/shell/browser/shell.h" @@ -30,7 +31,6 @@ #include "net/base/filename_util.h" #include "net/base/net_module.h" #include "net/grit/net_resources.h" -#include "services/service_manager/embedder/result_codes.h" #include "ui/base/material_design/material_design_controller.h" #include "ui/base/resource/resource_bundle.h" #include "url/gurl.h" @@ -140,7 +140,7 @@ int ShellBrowserMainParts::PreEarlyInitialization() { new net::NetworkChangeNotifierFactoryAndroid()); #endif SetupFieldTrials(); - return service_manager::RESULT_CODE_NORMAL_EXIT; + return RESULT_CODE_NORMAL_EXIT; } void ShellBrowserMainParts::InitializeBrowserContexts() { diff --git a/content/shell/browser/shell_content_browser_client.cc b/content/shell/browser/shell_content_browser_client.cc index a797cb5544a681..cc398842ed1146 100644 --- a/content/shell/browser/shell_content_browser_client.cc +++ b/content/shell/browser/shell_content_browser_client.cc @@ -387,7 +387,7 @@ void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( #else int crash_signal_fd = GetCrashSignalFD(command_line); if (crash_signal_fd >= 0) { - mappings->Share(service_manager::kCrashDumpSignal, crash_signal_fd); + mappings->Share(kCrashDumpSignal, crash_signal_fd); } #endif // !defined(OS_ANDROID) } diff --git a/content/zygote/OWNERS b/content/zygote/OWNERS index c8300293c2c805..d38314f3fddb6c 100644 --- a/content/zygote/OWNERS +++ b/content/zygote/OWNERS @@ -1 +1,7 @@ -file://services/service_manager/zygote/OWNERS \ No newline at end of file +jln@chromium.org +palmer@chromium.org +rsesek@chromium.org +tsepez@chromium.org + +# TEAM: security-dev@chromium.org +# COMPONENT: Internals>Sandbox diff --git a/content/zygote/zygote_browsertest.cc b/content/zygote/zygote_browsertest.cc index 48ffdd2f0846df..2ad8052923cf95 100644 --- a/content/zygote/zygote_browsertest.cc +++ b/content/zygote/zygote_browsertest.cc @@ -12,7 +12,6 @@ #include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test_utils.h" #include "content/shell/browser/shell.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/sandbox/switches.h" namespace content { diff --git a/services/service_manager/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc similarity index 89% rename from services/service_manager/zygote/zygote_linux.cc rename to content/zygote/zygote_linux.cc index 44706e85ff9cff..0f6710226f74d9 100644 --- a/services/service_manager/zygote/zygote_linux.cc +++ b/content/zygote/zygote_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "services/service_manager/zygote/zygote_linux.h" +#include "content/zygote/zygote_linux.h" #include #include @@ -32,29 +32,30 @@ #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h" +#include "content/common/zygote_commands_linux.h" +#include "content/public/common/content_descriptors.h" +#include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" +#include "content/public/common/result_codes.h" +#include "content/public/common/send_zygote_child_ping_linux.h" +#include "content/public/common/zygote_fork_delegate_linux.h" #include "ipc/ipc_channel.h" #include "sandbox/linux/services/credentials.h" #include "sandbox/linux/services/namespace_sandbox.h" -#include "services/service_manager/embedder/descriptors.h" -#include "services/service_manager/embedder/result_codes.h" #include "services/service_manager/embedder/set_process_title.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h" #include "services/service_manager/sandbox/sandbox.h" -#include "services/service_manager/zygote/common/send_zygote_child_ping_linux.h" -#include "services/service_manager/zygote/common/zygote_commands_linux.h" -#include "services/service_manager/zygote/common/zygote_fork_delegate_linux.h" #include "third_party/icu/source/i18n/unicode/timezone.h" -// See -// https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote.md +// See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_zygote.md -namespace service_manager { +namespace content { namespace { // NOP function. See below where this handler is installed. -void SIGCHLDHandler(int signal) {} +void SIGCHLDHandler(int signal) { +} int LookUpFd(const base::GlobalDescriptors::Mapping& fd_mapping, uint32_t key) { for (size_t index = 0; index < fd_mapping.size(); ++index) { @@ -105,8 +106,7 @@ bool Zygote::ProcessRequests() { // A SOCK_SEQPACKET socket is installed in fd 3. We get commands from the // browser on it. // A SOCK_DGRAM is installed in fd 5. This is the sandbox IPC channel. - // See - // https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sandbox_ipc.md + // See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sandbox_ipc.md // We need to accept SIGCHLD, even though our handler is a no-op because // otherwise we cannot wait on children. (According to POSIX 2001.) @@ -126,16 +126,17 @@ bool Zygote::ProcessRequests() { // Let the ZygoteHost know we are ready to go. // The receiving code is in // content/browser/zygote_host/zygote_host_impl_linux.cc. - bool r = base::UnixDomainSocket::SendMsg( - kZygoteSocketPairFd, kZygoteHelloMessage, sizeof(kZygoteHelloMessage), - std::vector()); + bool r = base::UnixDomainSocket::SendMsg(kZygoteSocketPairFd, + kZygoteHelloMessage, + sizeof(kZygoteHelloMessage), + std::vector()); #if defined(OS_CHROMEOS) LOG_IF(WARNING, !r) << "Sending zygote magic failed"; // Exit normally on chromeos because session manager may send SIGTERM // right after the process starts and it may fail to send zygote magic // number to browser process. if (!r) - _exit(service_manager::RESULT_CODE_NORMAL_EXIT); + _exit(RESULT_CODE_NORMAL_EXIT); #else CHECK(r) << "Sending zygote magic failed"; #endif @@ -177,9 +178,8 @@ bool Zygote::ReapChild(const base::TimeTicks& now, ZygoteProcessInfo* child) { pid_t r = HANDLE_EINTR(waitpid(pid, nullptr, WNOHANG)); if (r > 0) { if (r != pid) { - DLOG(ERROR) << "While waiting for " << pid - << " to terminate, " - "waitpid returned " + DLOG(ERROR) << "While waiting for " << pid << " to terminate, " + "waitpid returned " << r; } return r == pid; @@ -231,8 +231,8 @@ bool Zygote::UsingNSSandbox() const { bool Zygote::HandleRequestFromBrowser(int fd) { std::vector fds; char buf[kZygoteMaxMessageLength]; - const ssize_t len = - base::UnixDomainSocket::RecvMsg(fd, buf, sizeof(buf), &fds); + const ssize_t len = base::UnixDomainSocket::RecvMsg( + fd, buf, sizeof(buf), &fds); if (len == 0 || (len == -1 && errno == ECONNRESET)) { // EOF from the browser. We should die. @@ -324,9 +324,11 @@ bool Zygote::GetTerminationStatus(base::ProcessHandle real_pid, bool known_dead, base::TerminationStatus* status, int* exit_code) { + ZygoteProcessInfo child_info; if (!GetProcessInfo(real_pid, &child_info)) { - LOG(ERROR) << "Zygote::GetTerminationStatus for unknown PID " << real_pid; + LOG(ERROR) << "Zygote::GetTerminationStatus for unknown PID " + << real_pid; NOTREACHED(); return false; } @@ -384,7 +386,7 @@ void Zygote::HandleGetTerminationStatus(int fd, base::PickleIterator iter) { // it terminated normally. NOTREACHED(); status = base::TERMINATION_STATUS_NORMAL_TERMINATION; - exit_code = service_manager::RESULT_CODE_NORMAL_EXIT; + exit_code = RESULT_CODE_NORMAL_EXIT; } base::Pickle write_pickle; @@ -420,7 +422,7 @@ int Zygote::ForkWithRealPid(const std::string& process_type, return -1; } std::vector fds; - fds.push_back(mojo_channel_fd); // kBrowserFDIndex + fds.push_back(mojo_channel_fd); // kBrowserFDIndex fds.push_back(pid_oracle.get()); // kPIDOracleFDIndex pid = helper->Fork(process_type, fds, channel_id); @@ -457,7 +459,8 @@ int Zygote::ForkWithRealPid(const std::string& process_type, // Now read back our real PID from the zygote. base::ProcessId real_pid; - if (!base::ReadFromFD(read_pipe.get(), reinterpret_cast(&real_pid), + if (!base::ReadFromFD(read_pipe.get(), + reinterpret_cast(&real_pid), sizeof(real_pid))) { LOG(FATAL) << "Failed to synchronise with parent zygote process"; } @@ -543,9 +546,9 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter, base::GlobalDescriptors::Mapping mapping; std::string process_type; std::string channel_id; - const std::string channel_id_prefix = - std::string("--") + - service_manager::switches::kServiceRequestChannelToken + std::string("="); + const std::string channel_id_prefix = std::string("--") + + switches::kServiceRequestChannelToken + + std::string("="); if (!iter.ReadString(&process_type)) return -1; @@ -561,14 +564,16 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter, channel_id = arg.substr(channel_id_prefix.length()); } - // timezone_id is obtained from ICU in zygote host so that it can't be - // invalid. For an unknown reason, if an invalid ID is passed down here, the - // worst result would be that timezone would be set to Etc/Unknown. - base::string16 timezone_id; - if (!iter.ReadString16(&timezone_id)) - return -1; - icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone( - icu::UnicodeString(FALSE, timezone_id.data(), timezone_id.length()))); + if (process_type == switches::kRendererProcess) { + // timezone_id is obtained from ICU in zygote host so that it can't be + // invalid. For an unknown reason, if an invalid ID is passed down here, + // the worst result would be that timezone would be set to Etc/Unknown. + base::string16 timezone_id; + if (!iter.ReadString16(&timezone_id)) + return -1; + icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone( + icu::UnicodeString(FALSE, timezone_id.data(), timezone_id.length()))); + } if (!iter.ReadInt(&numfds)) return -1; @@ -616,7 +621,7 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter, service_manager::SetProcessTitleFromCommandLine(nullptr); } else if (child_pid < 0) { LOG(ERROR) << "Zygote could not fork: process_type " << process_type - << " numfds " << numfds << " child_pid " << child_pid; + << " numfds " << numfds << " child_pid " << child_pid; } return child_pid; } @@ -634,8 +639,8 @@ bool Zygote::HandleForkRequest(int fd, // If there's no UMA report for this particular fork, then check if any // helpers have an initial UMA report for us to send instead. while (uma_name.empty() && initial_uma_index_ < helpers_.size()) { - helpers_[initial_uma_index_++]->InitialUMA(&uma_name, &uma_sample, - &uma_boundary_value); + helpers_[initial_uma_index_++]->InitialUMA( + &uma_name, &uma_sample, &uma_boundary_value); } // Must always send reply, as ZygoteHost blocks while waiting for it. base::Pickle reply_pickle; @@ -646,18 +651,18 @@ bool Zygote::HandleForkRequest(int fd, reply_pickle.WriteInt(uma_boundary_value); } if (HANDLE_EINTR(write(fd, reply_pickle.data(), reply_pickle.size())) != - static_cast(reply_pickle.size())) + static_cast (reply_pickle.size())) PLOG(ERROR) << "write"; return false; } bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != - sizeof(sandbox_flags_)) { + sizeof(sandbox_flags_)) { PLOG(ERROR) << "write"; } return false; } -} // namespace service_manager +} // namespace content diff --git a/services/service_manager/zygote/zygote_linux.h b/content/zygote/zygote_linux.h similarity index 90% rename from services/service_manager/zygote/zygote_linux.h rename to content/zygote/zygote_linux.h index 9f85db71efea53..c86fed2a5db5a8 100644 --- a/services/service_manager/zygote/zygote_linux.h +++ b/content/zygote/zygote_linux.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_LINUX_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_LINUX_H_ +#ifndef CONTENT_ZYGOTE_ZYGOTE_LINUX_H_ +#define CONTENT_ZYGOTE_ZYGOTE_LINUX_H_ #include @@ -23,7 +23,7 @@ namespace base { class PickleIterator; } -namespace service_manager { +namespace content { class ZygoteForkDelegate; @@ -76,19 +76,18 @@ class Zygote { // appears outside of the sandbox. // Return true if it managed to get the termination status and return the // status in |status| and the exit code in |exit_code|. - bool GetTerminationStatus(base::ProcessHandle real_pid, - bool known_dead, + bool GetTerminationStatus(base::ProcessHandle real_pid, bool known_dead, base::TerminationStatus* status, int* exit_code); - void HandleGetTerminationStatus(int fd, base::PickleIterator iter); + void HandleGetTerminationStatus(int fd, + base::PickleIterator iter); // This is equivalent to fork(), except that, when using the SUID sandbox, it // returns the real PID of the child process as it appears outside the // sandbox, rather than returning the PID inside the sandbox. The child's - // real PID is determined by having it call - // service_manager::SendZygoteChildPing(int) using the |pid_oracle| - // descriptor. + // real PID is determined by having it call content::SendZygoteChildPing(int) + // using the |pid_oracle| descriptor. // Finally, when using a ZygoteForkDelegate helper, |uma_name|, |uma_sample|, // and |uma_boundary_value| may be set if the helper wants to make a UMA // report via UMA_HISTOGRAM_ENUMERATION. @@ -117,7 +116,8 @@ class Zygote { base::PickleIterator iter, std::vector fds); - bool HandleGetSandboxStatus(int fd, base::PickleIterator iter); + bool HandleGetSandboxStatus(int fd, + base::PickleIterator iter); // Attempt to reap the child process by calling waitpid, and return // whether successful. If the process has not terminated within @@ -147,6 +147,6 @@ class Zygote { base::GlobalDescriptors::Descriptor ipc_backchannel_; }; -} // namespace service_manager +} // namespace content -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_LINUX_H_ +#endif // CONTENT_ZYGOTE_ZYGOTE_LINUX_H_ diff --git a/services/service_manager/zygote/zygote_main.h b/content/zygote/zygote_main.h similarity index 51% rename from services/service_manager/zygote/zygote_main.h rename to content/zygote/zygote_main.h index 8de1e6abc322e0..dc0aa17d8058aa 100644 --- a/services/service_manager/zygote/zygote_main.h +++ b/content/zygote/zygote_main.h @@ -2,24 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_MAIN_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_MAIN_H_ +#ifndef CONTENT_ZYGOTE_ZYGOTE_MAIN_H_ +#define CONTENT_ZYGOTE_ZYGOTE_MAIN_H_ #include #include -#include "base/component_export.h" #include "build/build_config.h" -namespace service_manager { +namespace content { class ZygoteForkDelegate; -// |delegate| must outlive this call. -COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) bool ZygoteMain( std::vector> fork_delegates); -} // namespace service_manager +} // namespace content -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_ZYGOTE_MAIN_H_ +#endif // CONTENT_ZYGOTE_ZYGOTE_MAIN_H_ diff --git a/services/service_manager/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc similarity index 89% rename from services/service_manager/zygote/zygote_main_linux.cc rename to content/zygote/zygote_main_linux.cc index a00717066a1e45..4ce475f640f2ab 100644 --- a/services/service_manager/zygote/zygote_main_linux.cc +++ b/content/zygote/zygote_main_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "services/service_manager/zygote/zygote_main.h" +#include "content/zygote/zygote_main.h" #include #include @@ -19,6 +19,7 @@ #include #include "base/bind.h" +#include "base/command_line.h" #include "base/compiler_specific.h" #include "base/memory/protected_memory.h" #include "base/memory/protected_memory_cfi.h" @@ -29,25 +30,24 @@ #include "base/strings/string_number_conversions.h" #include "base/sys_info.h" #include "build/build_config.h" +#include "content/common/zygote_commands_linux.h" +#include "content/public/common/common_sandbox_support_linux.h" +#include "content/public/common/content_descriptors.h" +#include "content/public/common/zygote_fork_delegate_linux.h" +#include "content/zygote/zygote_linux.h" #include "sandbox/linux/services/credentials.h" #include "sandbox/linux/services/init_process_reaper.h" #include "sandbox/linux/services/libc_interceptor.h" #include "sandbox/linux/services/namespace_sandbox.h" #include "sandbox/linux/services/thread_helpers.h" #include "sandbox/linux/suid/client/setuid_sandbox_client.h" -#include "services/service_manager/embedder/descriptors.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/sandbox/linux/sandbox_debug_handling_linux.h" #include "services/service_manager/sandbox/linux/sandbox_linux.h" #include "services/service_manager/sandbox/sandbox.h" #include "services/service_manager/sandbox/switches.h" -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" -#include "services/service_manager/zygote/common/zygote_commands_linux.h" -#include "services/service_manager/zygote/common/zygote_fork_delegate_linux.h" -#include "services/service_manager/zygote/zygote_linux.h" #include "third_party/icu/source/i18n/unicode/timezone.h" -namespace service_manager { +namespace content { namespace { @@ -108,11 +108,11 @@ static bool EnterSuidSandbox(sandbox::SetuidSandboxClient* setuid_sandbox, // be enabled by the process later. if (!setuid_sandbox->IsSuidSandboxUpToDate()) { - LOG(WARNING) << "You are using a wrong version of the setuid binary!\n" - "Please read " - "https://chromium.googlesource.com/chromium/src/+/master/" - "docs/linux_suid_sandbox_development.md." - "\n\n"; + LOG(WARNING) << + "You are using a wrong version of the setuid binary!\n" + "Please read " + "https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md." + "\n\n"; } if (!setuid_sandbox->ChrootMe()) @@ -182,8 +182,7 @@ bool ZygoteMain( auto* linux_sandbox = service_manager::SandboxLinux::GetInstance(); - // Skip pre-initializing sandbox when sandbox is disabled for - // https://crbug.com/444900. + // Skip pre-initializing sandbox under --no-sandbox for crbug.com/444900. if (!base::CommandLine::ForCurrentProcess()->HasSwitch( service_manager::switches::kNoSandbox)) { // This will pre-initialize the various sandboxes that need it. @@ -208,7 +207,7 @@ bool ZygoteMain( std::vector())) { // This is not a CHECK failure because the browser process could either // crash or quickly exit while the zygote is starting. In either case a - // zygote crash is not useful. https://crbug.com/692227 + // zygote crash is not useful. http://crbug.com/692227 PLOG(ERROR) << "Failed sending zygote boot message"; _exit(1); } @@ -242,4 +241,4 @@ bool ZygoteMain( return zygote.ProcessRequests(); } -} // namespace service_manager +} // namespace content diff --git a/extensions/shell/app/DEPS b/extensions/shell/app/DEPS index 000187016ec6f9..f0db3f3fe147e7 100644 --- a/extensions/shell/app/DEPS +++ b/extensions/shell/app/DEPS @@ -8,5 +8,4 @@ include_rules = [ "+content/public/browser", "+content/public/utility", "+sandbox", - "+services/service_manager/embedder", ] diff --git a/extensions/shell/app/shell_crash_reporter_client.cc b/extensions/shell/app/shell_crash_reporter_client.cc index d50e7e36e52bef..f0483446a17e38 100644 --- a/extensions/shell/app/shell_crash_reporter_client.cc +++ b/extensions/shell/app/shell_crash_reporter_client.cc @@ -14,7 +14,6 @@ #include "components/version_info/version_info_values.h" #include "content/public/common/content_switches.h" #include "extensions/shell/common/switches.h" -#include "services/service_manager/embedder/switches.h" namespace extensions { @@ -78,7 +77,7 @@ bool ShellCrashReporterClient::EnableBreakpadForProcess( const std::string& process_type) { return process_type == ::switches::kRendererProcess || process_type == ::switches::kPpapiPluginProcess || - process_type == service_manager::switches::kZygoteProcess || + process_type == ::switches::kZygoteProcess || process_type == ::switches::kGpuProcess || process_type == ::switches::kUtilityProcess; } diff --git a/extensions/shell/app/shell_main_delegate.cc b/extensions/shell/app/shell_main_delegate.cc index 9bacdda59494e3..af2b7379bbca25 100644 --- a/extensions/shell/app/shell_main_delegate.cc +++ b/extensions/shell/app/shell_main_delegate.cc @@ -20,7 +20,6 @@ #include "extensions/shell/browser/shell_content_browser_client.h" #include "extensions/shell/common/shell_content_client.h" #include "extensions/shell/renderer/shell_content_renderer_client.h" -#include "services/service_manager/embedder/switches.h" #include "ui/base/resource/resource_bundle.h" #if defined(OS_CHROMEOS) @@ -171,7 +170,7 @@ void ShellMainDelegate::PreSandboxStartup() { #if defined(OS_LINUX) && !defined(OS_CHROMEOS) crash_reporter::SetCrashReporterClient(GetCrashReporterClient()); // Reporting for sub-processes will be initialized in ZygoteForked. - if (process_type != service_manager::switches::kZygoteProcess) + if (process_type != switches::kZygoteProcess) breakpad::InitCrashReporter(process_type); #endif @@ -196,8 +195,7 @@ void ShellMainDelegate::ProcessExiting(const std::string& process_type) { #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) void ShellMainDelegate::ZygoteStarting( - std::vector>* - delegates) { + std::vector>* delegates) { #if BUILDFLAG(ENABLE_NACL) nacl::AddNaClZygoteForkDelegates(delegates); #endif // BUILDFLAG(ENABLE_NACL) @@ -242,8 +240,7 @@ bool ShellMainDelegate::ProcessNeedsResourceBundle( const std::string& process_type) { // The browser process has no process type flag, but needs resources. // On Linux the zygote process opens the resources for the renderers. - return process_type.empty() || - process_type == service_manager::switches::kZygoteProcess || + return process_type.empty() || process_type == switches::kZygoteProcess || process_type == switches::kRendererProcess || #if BUILDFLAG(ENABLE_NACL) process_type == switches::kNaClLoaderProcess || diff --git a/extensions/shell/app/shell_main_delegate.h b/extensions/shell/app/shell_main_delegate.h index e14e0be94b79fa..c92b63df193a79 100644 --- a/extensions/shell/app/shell_main_delegate.h +++ b/extensions/shell/app/shell_main_delegate.h @@ -33,9 +33,8 @@ class ShellMainDelegate : public content::ContentMainDelegate { content::ContentRendererClient* CreateContentRendererClient() override; void ProcessExiting(const std::string& process_type) override; #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) - void ZygoteStarting( - std::vector>* - delegates) override; + void ZygoteStarting(std::vector>* + delegates) override; #endif #if defined(OS_LINUX) && !defined(OS_CHROMEOS) void ZygoteForked() override; diff --git a/extensions/shell/browser/shell_browser_main_parts.cc b/extensions/shell/browser/shell_browser_main_parts.cc index 9c5e1c3a83e947..ebc46cb66f7270 100644 --- a/extensions/shell/browser/shell_browser_main_parts.cc +++ b/extensions/shell/browser/shell_browser_main_parts.cc @@ -157,7 +157,7 @@ void ShellBrowserMainParts::PostMainMessageLoopStart() { } int ShellBrowserMainParts::PreEarlyInitialization() { - return service_manager::RESULT_CODE_NORMAL_EXIT; + return content::RESULT_CODE_NORMAL_EXIT; } int ShellBrowserMainParts::PreCreateThreads() { @@ -265,7 +265,7 @@ bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { if (!run_message_loop_) return true; desktop_controller_->Run(); - *result_code = service_manager::RESULT_CODE_NORMAL_EXIT; + *result_code = content::RESULT_CODE_NORMAL_EXIT; return true; } diff --git a/headless/DEPS b/headless/DEPS index 3e30eb34c7d70a..cfc4ee02aab87f 100644 --- a/headless/DEPS +++ b/headless/DEPS @@ -25,7 +25,6 @@ include_rules = [ "+ui/gl", "+ui/ozone/public", "+sandbox/win/src", - "+services/service_manager/embedder", "+services/service_manager/public", "+services/service_manager/sandbox", ] diff --git a/headless/lib/browser/headless_content_browser_client.cc b/headless/lib/browser/headless_content_browser_client.cc index d93b08a099a5c6..200a1d0a562671 100644 --- a/headless/lib/browser/headless_content_browser_client.cc +++ b/headless/lib/browser/headless_content_browser_client.cc @@ -228,7 +228,7 @@ void HeadlessContentBrowserClient::GetAdditionalMappedFilesForChildProcess( #if defined(HEADLESS_USE_BREAKPAD) int crash_signal_fd = GetCrashSignalFD(command_line, *browser_->options()); if (crash_signal_fd >= 0) - mappings->Share(service_manager::kCrashDumpSignal, crash_signal_fd); + mappings->Share(kCrashDumpSignal, crash_signal_fd); #endif // defined(HEADLESS_USE_BREAKPAD) } #endif // defined(OS_POSIX) && !defined(OS_MACOSX) diff --git a/headless/lib/headless_content_main_delegate.cc b/headless/lib/headless_content_main_delegate.cc index 05f88c9871d2c0..dae39919f94902 100644 --- a/headless/lib/headless_content_main_delegate.cc +++ b/headless/lib/headless_content_main_delegate.cc @@ -27,7 +27,6 @@ #include "headless/lib/headless_crash_reporter_client.h" #include "headless/lib/headless_macros.h" #include "headless/lib/utility/headless_content_utility_client.h" -#include "services/service_manager/embedder/switches.h" #include "services/service_manager/sandbox/switches.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_switches.h" @@ -217,7 +216,7 @@ void HeadlessContentMainDelegate::InitCrashReporter( DCHECK(!breakpad::IsCrashReporterEnabled()); return; } - if (process_type != service_manager::switches::kZygoteProcess) + if (process_type != switches::kZygoteProcess) breakpad::InitCrashReporter(process_type); #elif defined(OS_MACOSX) crash_reporter::InitializeCrashpad(process_type.empty(), process_type); diff --git a/headless/lib/headless_crash_reporter_client.cc b/headless/lib/headless_crash_reporter_client.cc index 16246b22a25bfd..a319161dbd1337 100644 --- a/headless/lib/headless_crash_reporter_client.cc +++ b/headless/lib/headless_crash_reporter_client.cc @@ -13,7 +13,6 @@ #include "build/build_config.h" #include "content/public/common/content_switches.h" #include "headless/public/version.h" -#include "services/service_manager/embedder/switches.h" namespace headless { @@ -57,7 +56,7 @@ bool HeadlessCrashReporterClient::EnableBreakpadForProcess( const std::string& process_type) { return process_type == switches::kRendererProcess || process_type == switches::kPpapiPluginProcess || - process_type == service_manager::switches::kZygoteProcess || + process_type == switches::kZygoteProcess || process_type == switches::kGpuProcess; } diff --git a/services/service_manager/embedder/BUILD.gn b/services/service_manager/embedder/BUILD.gn index 9114686f121eb5..f13471b1ad248a 100644 --- a/services/service_manager/embedder/BUILD.gn +++ b/services/service_manager/embedder/BUILD.gn @@ -53,7 +53,6 @@ component("embedder") { ] public_deps = [ - ":embedder_result_codes", "//base", "//services/service_manager/public/cpp", ] @@ -63,14 +62,9 @@ component("embedder") { deps += [ "//base/allocator:buildflags", "//components/tracing:startup_tracing", + "//ui/base", ] - if (!is_nacl) { - # NaCl stuff should not depend on skia as it would require platform and - # cpu properties set. - deps += [ "//ui/base" ] - } - public_deps += [ ":embedder_switches", "//mojo/edk", @@ -93,12 +87,6 @@ component("embedder_switches") { defines = [ "SERVICE_MANAGER_EMBEDDER_SWITCHES_IMPL" ] } -source_set("embedder_result_codes") { - sources = [ - "result_codes.h", - ] -} - source_set("unittests") { testonly = true diff --git a/services/service_manager/embedder/descriptors.h b/services/service_manager/embedder/descriptors.h deleted file mode 100644 index 33648226316c77..00000000000000 --- a/services/service_manager/embedder/descriptors.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 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_DESCRIPTORS_H_ -#define SERVICES_SERVICE_MANAGER_EMBEDDER_DESCRIPTORS_H_ - -namespace service_manager { - -// This is a list of global descriptor keys to be used with the -// base::GlobalDescriptors object (see base/posix/global_descriptors.h) -enum { - kCrashDumpSignal = 0, - kSandboxIPCChannel, // https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sandbox_ipc.md - kMojoIPCChannel, - kFieldTrialDescriptor, - - // The first key that embedders can use to register descriptors (see - // base/posix/global_descriptors.h). - kFirstEmbedderDescriptor, -}; - -} // namespace service_manager - -#endif // SERVICES_SERVICE_MANAGER_EMBEDDER_DESCRIPTORS_H_ \ No newline at end of file diff --git a/services/service_manager/embedder/result_codes.h b/services/service_manager/embedder/result_codes.h deleted file mode 100644 index c153a496e49ed4..00000000000000 --- a/services/service_manager/embedder/result_codes.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 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_RESULT_CODES_H_ -#define SERVICES_SERVICE_MANAGER_EMBEDDER_RESULT_CODES_H_ - -namespace service_manager { - -// The return code returned by the main method. -// Extended by embedders. - -enum ResultCode { - // Process terminated normally. - RESULT_CODE_NORMAL_EXIT, - - // Last return code (keep this last). - RESULT_CODE_LAST_CODE -}; - -// Embedders may rely on these result codes not changing. -static_assert(RESULT_CODE_LAST_CODE == 1, "This enum is frozen."); - -} // namespace service_manager - -#endif // SERVICES_SERVICE_MANAGER_EMBEDDER_RESULT_CODES_H_ diff --git a/services/service_manager/embedder/switches.cc b/services/service_manager/embedder/switches.cc index 8337a14af77e88..4e42a51ecae87b 100644 --- a/services/service_manager/embedder/switches.cc +++ b/services/service_manager/embedder/switches.cc @@ -24,7 +24,7 @@ const char kDefaultServicePrefetchArgument[] = "/prefetch:8"; #endif // defined(OS_WIN) -// Disables the in-process stack traces. +// Disable the in-process stack traces. const char kDisableInProcessStackTraces[] = "disable-in-process-stack-traces"; // Controls whether console logging is enabled and optionally configures where @@ -43,10 +43,6 @@ const char kProcessTypeServiceManager[] = "service-manager"; // 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 -// process. -const char kServiceRequestChannelToken[] = "service-request-channel-token"; - // Describes the file descriptors passed to a child process in the following // list format: // @@ -58,11 +54,5 @@ const char kServiceRequestChannelToken[] = "service-request-channel-token"; // global descriptor table. const char kSharedFiles[] = "shared-files"; -// The prefix used when starting the zygote process. (i.e. 'gdb --args') -const char kZygoteCmdPrefix[] = "zygote-cmd-prefix"; - -// Causes the process to run as a zygote. -const char kZygoteProcess[] = "zygote"; - } // namespace switches } // namespace service_manager diff --git a/services/service_manager/embedder/switches.h b/services/service_manager/embedder/switches.h index 25d4ca989b04e8..976fb58aa4fb01 100644 --- a/services/service_manager/embedder/switches.h +++ b/services/service_manager/embedder/switches.h @@ -24,11 +24,7 @@ SERVICE_MANAGER_EMBEDDER_SWITCHES_EXPORT extern const char kProcessTypeServiceManager[]; SERVICE_MANAGER_EMBEDDER_SWITCHES_EXPORT extern const char kProcessTypeService[]; -SERVICE_MANAGER_EMBEDDER_SWITCHES_EXPORT extern const char - kServiceRequestChannelToken[]; SERVICE_MANAGER_EMBEDDER_SWITCHES_EXPORT extern const char kSharedFiles[]; -SERVICE_MANAGER_EMBEDDER_SWITCHES_EXPORT extern const char kZygoteCmdPrefix[]; -SERVICE_MANAGER_EMBEDDER_SWITCHES_EXPORT extern const char kZygoteProcess[]; } // namespace switches } // namespace service_manager diff --git a/services/service_manager/zygote/BUILD.gn b/services/service_manager/zygote/BUILD.gn deleted file mode 100644 index da276ffcc78045..00000000000000 --- a/services/service_manager/zygote/BUILD.gn +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 2018 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. - -import("//build/buildflag_header.gni") -import("//build/config/nacl/config.gni") -import("//services/service_manager/zygote/common/zygote_features.gni") - -if (is_linux) { - component("zygote") { - if (is_nacl_nonsfi) { - # When running the nacl toolchain is_linux is false so *_linux.cc files are - # excluded. Reset the filter so they are included. - set_sources_assignment_filter([]) - } - - sources = [ - "common/common_sandbox_support_linux.cc", - "common/common_sandbox_support_linux.h", - "common/zygote_fork_delegate_linux.h", - "common/zygote_handle.h", - "host/zygote_communication_linux.cc", - "host/zygote_communication_linux.h", - "host/zygote_host_impl_linux.cc", - "host/zygote_host_impl_linux.h", - "zygote_linux.cc", - "zygote_linux.h", - "zygote_main.h", - "zygote_main_linux.cc", - ] - - if (use_zygote_handle) { - sources += [ - "common/zygote_handle.h", - "host/zygote_handle_linux.cc", - ] - } - - public_deps = [ - ":zygote_buildflags", - ":zygote_util", - ] - - deps = [ - "//base", - "//base:i18n", - "//ipc", - "//sandbox", - "//services/service_manager/embedder", - "//services/service_manager/sandbox", - "//third_party/icu", - ] - - defines = [ "IS_SERVICE_MANAGER_ZYGOTE_IMPL" ] - } -} - -source_set("zygote_util") { - if (is_nacl_nonsfi) { - # When running the nacl toolchain is_linux is false so *_linux.cc files are - # excluded. Reset the filter so they are included. - set_sources_assignment_filter([]) - } - - sources = [ - "common/send_zygote_child_ping_linux.cc", - "common/send_zygote_child_ping_linux.h", - "common/zygote_commands_linux.h", - ] - - deps = [ - "//base", - "//services/service_manager/sandbox:sanitizer_buildflags", - ] - - defines = [ "IS_SERVICE_MANAGER_ZYGOTE_IMPL" ] -} - -buildflag_header("zygote_buildflags") { - header = "common/zygote_buildflags.h" - flags = [ "USE_ZYGOTE_HANDLE=$use_zygote_handle" ] -} diff --git a/services/service_manager/zygote/DEPS b/services/service_manager/zygote/DEPS deleted file mode 100644 index ec69c8f59a84fc..00000000000000 --- a/services/service_manager/zygote/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+sandbox", -] diff --git a/services/service_manager/zygote/OWNERS b/services/service_manager/zygote/OWNERS deleted file mode 100644 index d38314f3fddb6c..00000000000000 --- a/services/service_manager/zygote/OWNERS +++ /dev/null @@ -1,7 +0,0 @@ -jln@chromium.org -palmer@chromium.org -rsesek@chromium.org -tsepez@chromium.org - -# TEAM: security-dev@chromium.org -# COMPONENT: Internals>Sandbox diff --git a/services/service_manager/zygote/common/common_sandbox_support_linux.cc b/services/service_manager/zygote/common/common_sandbox_support_linux.cc deleted file mode 100644 index df75a7a28e83d5..00000000000000 --- a/services/service_manager/zygote/common/common_sandbox_support_linux.cc +++ /dev/null @@ -1,37 +0,0 @@ -// 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. - -#include "services/service_manager/zygote/common/common_sandbox_support_linux.h" - -#include "base/pickle.h" -#include "base/posix/global_descriptors.h" -#include "base/posix/unix_domain_socket.h" -#include "services/service_manager/embedder/descriptors.h" -#include "services/service_manager/sandbox/linux/sandbox_linux.h" - -namespace service_manager { - -#if !defined(OS_NACL_NONSFI) -int MakeSharedMemorySegmentViaIPC(size_t length, bool executable) { - base::Pickle request; - request.WriteInt( - service_manager::SandboxLinux::METHOD_MAKE_SHARED_MEMORY_SEGMENT); - request.WriteUInt32(length); - request.WriteBool(executable); - uint8_t reply_buf[10]; - int result_fd; - ssize_t result = base::UnixDomainSocket::SendRecvMsg( - GetSandboxFD(), reply_buf, sizeof(reply_buf), &result_fd, request); - if (result == -1) - return -1; - return result_fd; -} -#endif - -int GetSandboxFD() { - return service_manager::kSandboxIPCChannel + - base::GlobalDescriptors::kBaseDescriptor; -} - -} // namespace service_manager diff --git a/services/service_manager/zygote/common/common_sandbox_support_linux.h b/services/service_manager/zygote/common/common_sandbox_support_linux.h deleted file mode 100644 index 0555dcde7dd584..00000000000000 --- a/services/service_manager/zygote/common/common_sandbox_support_linux.h +++ /dev/null @@ -1,33 +0,0 @@ -// 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_ZYGOTE_COMMON_COMMON_SANDBOX_SUPPORT_LINUX_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_COMMON_SANDBOX_SUPPORT_LINUX_H_ - -#include - -#include "base/component_export.h" -#include "build/build_config.h" - -namespace service_manager { - -#if !defined(OS_NACL_NONSFI) -// Returns a file descriptor for a shared memory segment. The -// executable flag indicates that the caller intends to use mprotect -// with PROT_EXEC after making a mapping, but not that it intends to -// mmap with PROT_EXEC in the first place. (Some systems, such as -// ChromeOS, disallow PROT_EXEC in mmap on /dev/shm files but do allow -// PROT_EXEC in mprotect on mappings from such files. This function -// can yield an object that has that constraint.) -COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) -int MakeSharedMemorySegmentViaIPC(size_t length, bool executable); -#endif - -// Gets the well-known file descriptor on which we expect to find the -// sandbox IPC channel. -COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) int GetSandboxFD(); - -} // namespace service_manager - -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_COMMON_SANDBOX_SUPPORT_LINUX_H_ diff --git a/services/service_manager/zygote/common/send_zygote_child_ping_linux.h b/services/service_manager/zygote/common/send_zygote_child_ping_linux.h deleted file mode 100644 index 66aff241a9508e..00000000000000 --- a/services/service_manager/zygote/common/send_zygote_child_ping_linux.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 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_ZYGOTE_COMMON_SEND_ZYGOTE_CHILD_PING_LINUX_H_ -#define SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_SEND_ZYGOTE_CHILD_PING_LINUX_H_ - -#include "base/component_export.h" - -namespace service_manager { - -// Sends a zygote child "ping" message to browser process via socket |fd|. -// Returns true on success. -COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) bool SendZygoteChildPing(int fd); - -} // namespace service_manager - -#endif // SERVICES_SERVICE_MANAGER_ZYGOTE_COMMON_SEND_ZYGOTE_CHILD_PING_LINUX_H_ diff --git a/tools/ipc_fuzzer/message_replay/DEPS b/tools/ipc_fuzzer/message_replay/DEPS index e3f83dc0e832bb..7826d21ef9c315 100644 --- a/tools/ipc_fuzzer/message_replay/DEPS +++ b/tools/ipc_fuzzer/message_replay/DEPS @@ -1,6 +1,5 @@ include_rules = [ "+chrome/common", "+content/public/common", - "+mojo/edk/embedder", - "+services/service_manager/embedder", + "+mojo/edk/embedder" ] diff --git a/tools/ipc_fuzzer/message_replay/replay_process.cc b/tools/ipc_fuzzer/message_replay/replay_process.cc index 5fa2a31163adc1..439d0bf2e61dda 100644 --- a/tools/ipc_fuzzer/message_replay/replay_process.cc +++ b/tools/ipc_fuzzer/message_replay/replay_process.cc @@ -18,6 +18,7 @@ #include "chrome/common/chrome_switches.h" #include "content/public/common/connection_filter.h" #include "content/public/common/content_switches.h" +#include "content/public/common/mojo_channel_switches.h" #include "content/public/common/service_manager_connection.h" #include "ipc/ipc.mojom.h" #include "ipc/ipc_channel_mojo.h" @@ -26,11 +27,10 @@ #include "mojo/edk/embedder/incoming_broker_client_invitation.h" #include "mojo/edk/embedder/platform_channel_pair.h" #include "mojo/edk/embedder/scoped_ipc_support.h" -#include "services/service_manager/embedder/switches.h" #if defined(OS_POSIX) #include "base/posix/global_descriptors.h" -#include "services/service_manager/embedder/descriptors.h" +#include "content/public/common/content_descriptors.h" #endif namespace ipc_fuzzer { @@ -76,9 +76,8 @@ InitializeMojoIPCChannel() { mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( *base::CommandLine::ForCurrentProcess()); #elif defined(OS_POSIX) - platform_channel.reset( - mojo::edk::PlatformHandle(base::GlobalDescriptors::GetInstance()->Get( - service_manager::kMojoIPCChannel))); + platform_channel.reset(mojo::edk::PlatformHandle( + base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel))); #endif CHECK(platform_channel.is_valid()); return mojo::edk::IncomingBrokerClientInvitation::Accept( @@ -126,9 +125,8 @@ bool ReplayProcess::Initialize(int argc, const char** argv) { #if defined(OS_POSIX) base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); - g_fds->Set(service_manager::kMojoIPCChannel, - service_manager::kMojoIPCChannel + - base::GlobalDescriptors::kBaseDescriptor); + g_fds->Set(kMojoIPCChannel, + kMojoIPCChannel + base::GlobalDescriptors::kBaseDescriptor); #endif mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( @@ -145,7 +143,7 @@ void ReplayProcess::OpenChannel() { service_manager::mojom::ServiceRequest( broker_client_invitation_->ExtractMessagePipe( base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - service_manager::switches::kServiceRequestChannelToken))), + switches::kServiceRequestChannelToken))), io_thread_.task_runner()); mojo::MessagePipe ipc_pipe; service_manager_connection_->AddConnectionFilter( diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 5c1c82f6a3b930..4f7d4bdde8c3ec 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -47864,7 +47864,7 @@ Full version information for the fingerprint enum values: - +