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

Unified Diff: content/browser/zygote_host/zygote_host_impl_linux.h

Issue 1532423003: Have each SandboxedProcessLauncherDelegate maintain a zygote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Correctly initialize the sandbox_binary_ command before launching the zygote. 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/zygote_host/zygote_host_impl_linux.h
diff --git a/content/browser/zygote_host/zygote_host_impl_linux.h b/content/browser/zygote_host/zygote_host_impl_linux.h
index 6793f73757c8be61eaacd4db0c08cc480dc2e99d..e640a990a6f2e992a9726c34874a3a7e7b55f8cd 100644
--- a/content/browser/zygote_host/zygote_host_impl_linux.h
+++ b/content/browser/zygote_host/zygote_host_impl_linux.h
@@ -5,16 +5,13 @@
#ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
#define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
-#include <stddef.h>
+#include <sys/types.h>
#include <set>
#include <string>
-#include <vector>
-#include "base/pickle.h"
-#include "base/process/kill.h"
+#include "base/process/process_handle.h"
#include "base/synchronization/lock.h"
-#include "content/public/browser/file_descriptor_info.h"
#include "content/public/browser/zygote_host_linux.h"
namespace base {
@@ -31,35 +28,17 @@ class CONTENT_EXPORT ZygoteHostImpl : public ZygoteHost {
void Init(const std::string& sandbox_cmd);
- // After the last known Zygote child exits, notify the Zygote to exit.
- void TearDownAfterLastChild();
-
- // Tries to start a process of type indicated by process_type.
- // Returns its pid on success, otherwise
- // base::kNullProcessHandle;
- pid_t ForkRequest(const std::vector<std::string>& command_line,
- scoped_ptr<FileDescriptorInfo> mapping,
- const std::string& process_type);
- void EnsureProcessTerminated(pid_t process);
-
- // Get the termination status (and, optionally, the exit code) of
- // the process. |exit_code| is set to the exit code of the child
- // process. (|exit_code| may be NULL.)
- // Unfortunately the Zygote can not accurately figure out if a process
- // is already dead without waiting synchronously for it.
- // |known_dead| should be set to true when we already know that the process
- // is dead. When |known_dead| is false, processes could be seen as
- // 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 crbug.com/157458.
- base::TerminationStatus GetTerminationStatus(base::ProcessHandle handle,
- bool known_dead,
- int* exit_code);
-
- // ZygoteHost implementation:
- pid_t GetPid() const override;
- int GetSandboxStatus() const override;
+ // Retrieves the sandbox command passed into Init();
+ const std::string& SandboxCommand() const;
+
+ // Tells the ZygoteHost the PIDs of all the zygotes.
+ void AddZygotePid(pid_t pid);
+
+ // Returns whether or not this pid is the pid of a zygote.
+ bool IsZygotePid(pid_t pid) override;
+
+ void SetRendererSandboxStatus(int status);
+ int GetRendererSandboxStatus() const override;
void AdjustRendererOOMScore(base::ProcessHandle process_handle,
int score) override;
@@ -69,42 +48,13 @@ class CONTENT_EXPORT ZygoteHostImpl : public ZygoteHost {
ZygoteHostImpl();
~ZygoteHostImpl() override;
- // Notify the Zygote to exit immediately. This object should not be
- // used afterwards.
- void TearDown();
-
- // Should be called every time a Zygote child is born.
- void ZygoteChildBorn(pid_t process);
-
- // Should be called every time a Zygote child died.
- void ZygoteChildDied(pid_t process);
-
- // Sends |data| to the zygote via |control_fd_|. If |fds| is non-NULL, the
- // included file descriptors will also be passed. The caller is responsible
- // for acquiring |control_lock_|.
- bool SendMessage(const base::Pickle& data, const std::vector<int>* fds);
-
- ssize_t ReadReply(void* buf, size_t buflen);
-
- // Whether we should use the namespace sandbox instead of the setuid sandbox.
- bool ShouldUseNamespaceSandbox();
-
- int control_fd_; // the socket to the zygote
- // A lock protecting all communication with the zygote. This lock must be
- // acquired before sending a command and released after the result has been
- // received.
- base::Lock control_lock_;
- pid_t pid_;
- bool init_;
+ int renderer_sandbox_status_;
bool use_suid_sandbox_for_adj_oom_score_;
std::string sandbox_binary_;
- bool have_read_sandbox_status_word_;
- int sandbox_status_;
- // A lock protecting list_of_running_zygote_children_ and
- // should_teardown_after_last_child_exits_.
- base::Lock child_tracking_lock_;
- std::set<pid_t> list_of_running_zygote_children_;
- bool should_teardown_after_last_child_exits_;
+ // This lock protects the |zygote_pids_| set.
+ base::Lock zygote_pids_lock_;
+ // This is a set of PIDs representing all the running zygotes.
+ std::set<pid_t> zygote_pids_;
};
} // namespace content
« no previous file with comments | « content/browser/zygote_host/zygote_handle_linux.cc ('k') | content/browser/zygote_host/zygote_host_impl_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698