Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1398)

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1532423003: Have each SandboxedProcessLauncherDelegate maintain a zygote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Load and initialize all zygotes on browser startup. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 610e2a344e39da8957a116312f23f2fd8ae76045..0729a7d0e29644b5423c8b181f3542431b018e2f 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -201,6 +201,11 @@
#include "content/browser/mach_broker_mac.h"
#endif
+#if defined(OS_POSIX)
+#include "content/browser/zygote_host/zygote_communication_linux.h"
+#include "content/browser/zygote_host/zygote_host_impl_linux.h"
+#endif // defined(OS_POSIX)
+
#if defined(USE_OZONE)
#include "ui/ozone/public/client_native_pixmap_factory.h"
#include "ui/ozone/public/ozone_platform.h"
@@ -362,6 +367,12 @@ SiteProcessMap* GetSiteProcessMapForBrowserContext(BrowserContext* context) {
return map;
}
+#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
+// This static member variable holds the zygote communication information for
+// the renderer.
+ZygoteHandle zygote;
+#endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
+
// NOTE: changes to this class need to be reviewed by the security team.
class RendererSandboxedProcessLauncherDelegate
: public SandboxedProcessLauncherDelegate {
@@ -389,13 +400,17 @@ class RendererSandboxedProcessLauncherDelegate
}
#elif defined(OS_POSIX)
- bool ShouldUseZygote() override {
+#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
+ ZygoteHandle* GetZygote() override {
const base::CommandLine& browser_command_line =
*base::CommandLine::ForCurrentProcess();
base::CommandLine::StringType renderer_prefix =
browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix);
- return renderer_prefix.empty();
+ if (!renderer_prefix.empty())
+ return nullptr;
+ return &zygote;
}
+#endif // !defined(OS_MACOSX) && !defined(OS_ANDROID)
base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); }
#endif // OS_WIN
@@ -525,6 +540,20 @@ void RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
g_max_renderer_count_override = count;
}
+#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
+// static
+void RenderProcessHostImpl::EarlyZygoteLaunch() {
+ DCHECK(!zygote);
+ zygote = new ZygoteCommunication();
+ zygote->Init();
+ // TODO(kerrnel): Investigate doing this without the ZygoteHostImpl as a
+ // proxy. It is currently done this way due to concerns about race
+ // conditions.
+ ZygoteHostImpl::GetInstance()->SetRendererSandboxStatus(
+ zygote->GetSandboxStatus());
+}
+#endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
+
RenderProcessHostImpl::RenderProcessHostImpl(
BrowserContext* browser_context,
StoragePartitionImpl* storage_partition_impl,

Powered by Google App Engine
This is Rietveld 408576698