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

Unified Diff: content/browser/zygote_host/zygote_handle_linux.cc

Issue 2850903002: Clean up Linux zygote creation code (Closed)
Patch Set: Created 3 years, 8 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_handle_linux.cc
diff --git a/content/browser/zygote_host/zygote_handle_linux.cc b/content/browser/zygote_host/zygote_handle_linux.cc
index 55830f57487209651585838f1271d8b4ceb4efb9..61780112eca95e423c1f20e35c832c7534525078 100644
--- a/content/browser/zygote_host/zygote_handle_linux.cc
+++ b/content/browser/zygote_host/zygote_handle_linux.cc
@@ -7,16 +7,23 @@
#include "content/browser/zygote_host/zygote_communication_linux.h"
namespace content {
+namespace {
-ZygoteHandle CreateZygote() {
- ZygoteHandle zygote = new ZygoteCommunication();
- zygote->Init();
- return zygote;
+// Intentionally leaked.
James Cook 2017/04/28 20:07:52 The old code leaks the ZygoteCommunication object.
mdempsky 2017/04/28 22:13:45 By "leaks" do you mean that it's not destroyed whe
+ZygoteHandle g_generic_zygote = nullptr;
+
+} // namespace
+
+ZygoteHandle CreateGenericZygote() {
+ CHECK(!g_generic_zygote);
+ g_generic_zygote = new ZygoteCommunication();
+ g_generic_zygote->Init();
+ return g_generic_zygote;
}
-ZygoteHandle* GetGenericZygote() {
- static ZygoteHandle zygote;
- return &zygote;
+ZygoteHandle GetGenericZygote() {
+ CHECK(g_generic_zygote);
+ return g_generic_zygote;
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698