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

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

Issue 148443006: Linux: tear down Zygote at browser shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't reset init_. Rely on control_fd_ for DCHECKs. Created 6 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 95591a4b1be800295d375de9bd734fa50cbf5167..08044fa5a888c5ee8667d0c01d0455bda2df0767 100644
--- a/content/browser/zygote_host/zygote_host_impl_linux.h
+++ b/content/browser/zygote_host/zygote_host_impl_linux.h
@@ -5,6 +5,7 @@
#ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
#define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
+#include <set>
#include <string>
#include <vector>
@@ -26,6 +27,9 @@ 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;
@@ -62,6 +66,16 @@ class CONTENT_EXPORT ZygoteHostImpl : public ZygoteHost {
ZygoteHostImpl();
virtual ~ZygoteHostImpl();
+ // 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_|.
@@ -80,6 +94,11 @@ class CONTENT_EXPORT ZygoteHostImpl : public ZygoteHost {
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_;
};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698