Skip to content

Commit

Permalink
Move zygote from //services/service_manager back to //content
Browse files Browse the repository at this point in the history
This effectively reverts 668c097.

Bug: 1097376
Change-Id: I6dfe3300315bbee65bcc0d18fb26a0afa46a61f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2252466
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Greg Kerr <kerrnel@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782545}
  • Loading branch information
rsesek authored and Commit Bot committed Jun 25, 2020
1 parent 645ca14 commit 8621aef
Show file tree
Hide file tree
Showing 76 changed files with 387 additions and 401 deletions.
3 changes: 1 addition & 2 deletions chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,7 @@ void ChromeMainDelegate::ProcessExiting(const std::string& process_type) {

#if defined(OS_LINUX)
void ChromeMainDelegate::ZygoteStarting(
std::vector<std::unique_ptr<service_manager::ZygoteForkDelegate>>*
delegates) {
std::vector<std::unique_ptr<content::ZygoteForkDelegate>>* delegates) {
#if defined(OS_CHROMEOS)
chromeos::InitHugepagesAndMlockSelf();
#endif
Expand Down
5 changes: 2 additions & 3 deletions chrome/app/chrome_main_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
const content::MainFunctionParams& main_function_params) override;
void ProcessExiting(const std::string& process_type) override;
#if defined(OS_LINUX)
void ZygoteStarting(
std::vector<std::unique_ptr<service_manager::ZygoteForkDelegate>>*
delegates) override;
void ZygoteStarting(std::vector<std::unique_ptr<content::ZygoteForkDelegate>>*
delegates) override;
void ZygoteForked() override;
#endif
service_manager::ProcessType OverrideProcessType() override;
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4339,7 +4339,6 @@ static_library("browser") {
if (use_x11) {
deps += [ "//ui/gfx/x" ]
}
deps += [ "//services/service_manager/zygote" ]
}

if (is_chromeos) {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/memory_details.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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/zygote_host_linux.h"
#endif

#if BUILDFLAG(ENABLE_EXTENSIONS)
Expand Down Expand Up @@ -340,7 +340,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/common/content_constants.h"
#include "services/service_manager/zygote/zygote_host_linux.h"
#include "ui/wm/public/activation_client.h"

using base::ProcessHandle;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/webui/sandbox/sandbox_internals_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#endif

#if defined(OS_LINUX)
#include "content/public/browser/zygote_host/zygote_host_linux.h"
#include "services/service_manager/sandbox/sandbox.h"
#include "services/service_manager/zygote/zygote_host_linux.h"
#endif

namespace {
Expand All @@ -35,7 +35,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);
Expand Down
4 changes: 2 additions & 2 deletions components/nacl/broker/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ source_set("broker") {
"//components/nacl/common:minimal",
"//components/nacl/common:switches",
"//content/public/common:static_switches",
"//content/public/common/zygote:buildflags",
"//ipc",
"//mojo/public/cpp/platform",
"//mojo/public/cpp/system",
"//sandbox",
"//services/service_manager/public/cpp",
"//services/service_manager/zygote:zygote_buildflags",
]

if (current_cpu == target_cpu) {
Expand Down Expand Up @@ -137,9 +137,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",
]
}

Expand Down
2 changes: 0 additions & 2 deletions components/nacl/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ static_library("browser") {
"//ppapi/host",
"//ppapi/proxy:ipc",
"//ppapi/shared_impl",
"//services/service_manager/zygote:zygote_buildflags",
]

public_deps = [
Expand All @@ -64,7 +63,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) {
Expand Down
8 changes: 4 additions & 4 deletions components/nacl/browser/nacl_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/process_type.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/zygote/zygote_buildflags.h"
#include "ipc/ipc_channel.h"
#include "mojo/public/cpp/system/invitation.h"
#include "net/socket/socket_descriptor.h"
Expand All @@ -63,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/zygote_handle.h" // nogncheck
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)

#if defined(OS_POSIX)
Expand Down Expand Up @@ -185,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)

Expand Down
8 changes: 1 addition & 7 deletions components/nacl/loader/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -56,9 +52,9 @@ source_set("minimal") {
source_set("minimal_content_dummy") {
check_includes = false
sources = [
"//content/public/common/common_sandbox_support_linux.h",
"//content/public/common/main_function_params.h",
"//content/public/common/sandbox_init.h",
"//content/public/common/zygote/sandbox_support_linux.h",
]

# Deps required by the above headers.
Expand Down Expand Up @@ -128,7 +124,6 @@ if (is_linux) {
"//mojo/core/embedder",
"//sandbox/linux:sandbox_services",
"//services/service_manager/sandbox",
"//services/service_manager/zygote",
"//url/ipc:url_ipc",
]

Expand Down Expand Up @@ -241,7 +236,6 @@ if (is_nacl_nonsfi) {
"//sandbox/linux:sandbox",
"//services/service_manager/public/cpp",
"//services/service_manager/sandbox",
"//services/service_manager/zygote:zygote_util",
]
}

Expand Down
18 changes: 9 additions & 9 deletions components/nacl/loader/nacl_helper_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,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/zygote/send_zygote_child_ping_linux.h"
#include "content/public/common/zygote/zygote_fork_delegate_linux.h"
#include "mojo/core/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"
Expand Down Expand Up @@ -144,16 +144,16 @@ void ChildNaClLoaderInit(std::vector<base::ScopedFD> 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()));

// 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,
Expand Down Expand Up @@ -181,7 +181,7 @@ bool HandleForkRequest(std::vector<base::ScopedFD> 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;
Expand Down
6 changes: 3 additions & 3 deletions components/nacl/loader/nacl_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "native_client/src/public/nacl_desc.h"

#if defined(OS_LINUX)
#include "services/service_manager/zygote/common/common_sandbox_support_linux.h"
#include "content/public/common/zygote/sandbox_support_linux.h"
#endif

#if defined(OS_POSIX)
Expand Down Expand Up @@ -229,8 +229,8 @@ void NaClListener::Listen() {
#if defined(OS_LINUX)
// static
int NaClListener::MakeSharedMemorySegment(size_t length, int executable) {
return service_manager::SharedMemoryIPCSupport::MakeSharedMemorySegment(
length, executable);
return content::SharedMemoryIPCSupport::MakeSharedMemorySegment(length,
executable);
}
#endif

Expand Down
3 changes: 1 addition & 2 deletions components/nacl/zygote/nacl_fork_delegate_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ bool SendIPCRequestAndReadReply(int ipc_channel,
namespace nacl {

void AddNaClZygoteForkDelegates(
std::vector<std::unique_ptr<service_manager::ZygoteForkDelegate>>*
delegates) {
std::vector<std::unique_ptr<content::ZygoteForkDelegate>>* delegates) {
delegates->push_back(
std::make_unique<NaClForkDelegate>(false /* nonsfi_mode */));
delegates->push_back(
Expand Down
7 changes: 3 additions & 4 deletions components/nacl/zygote/nacl_fork_delegate_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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/zygote_fork_delegate_linux.h"

namespace base {
struct LaunchOptions;
Expand All @@ -22,15 +22,14 @@ namespace nacl {

// Appends any ZygoteForkDelegate instances needed by NaCl to |*delegates|.
void AddNaClZygoteForkDelegates(
std::vector<std::unique_ptr<service_manager::ZygoteForkDelegate>>*
delegates);
std::vector<std::unique_ptr<content::ZygoteForkDelegate>>* 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 {
class NaClForkDelegate : public content::ZygoteForkDelegate {
public:
explicit NaClForkDelegate(bool nonsfi_mode);
~NaClForkDelegate() override;
Expand Down
1 change: 1 addition & 0 deletions content/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ if (is_component_build) {
sources = [
"//services/service_manager/sandbox/linux/sandbox_seccomp_bpf_linux.cc",
"common/sandbox_init_linux.cc",
"common/zygote/send_zygote_child_ping_linux.cc",
"public/common/content_switches.cc",
"public/common/content_switches.h",
]
Expand Down
1 change: 1 addition & 0 deletions content/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ source_set("content_main_runner_app") {
"//content/public/utility:utility_sources",
"//content/renderer",
"//content/utility",
"//content/zygote",
]
}

Expand Down
Loading

0 comments on commit 8621aef

Please sign in to comment.