OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_ZYGOTE_ZYGOTE_H_ | 5 #ifndef CONTENT_ZYGOTE_ZYGOTE_H_ |
6 #define CONTENT_ZYGOTE_ZYGOTE_H_ | 6 #define CONTENT_ZYGOTE_ZYGOTE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
24 class ZygoteForkDelegate; | 24 class ZygoteForkDelegate; |
25 | 25 |
26 // This is the object which implements the zygote. The ZygoteMain function, | 26 // This is the object which implements the zygote. The ZygoteMain function, |
27 // which is called from ChromeMain, simply constructs one of these objects and | 27 // which is called from ChromeMain, simply constructs one of these objects and |
28 // runs it. | 28 // runs it. |
29 class Zygote { | 29 class Zygote { |
30 public: | 30 public: |
31 Zygote(int sandbox_flags, ScopedVector<ZygoteForkDelegate> helpers); | 31 Zygote(int sandbox_flags, ScopedVector<ZygoteForkDelegate> helpers, |
| 32 const std::vector<base::ProcessHandle>& extra_children, |
| 33 const std::vector<int>& extra_fds); |
32 ~Zygote(); | 34 ~Zygote(); |
33 | 35 |
34 bool ProcessRequests(); | 36 bool ProcessRequests(); |
35 | 37 |
36 private: | 38 private: |
37 struct ZygoteProcessInfo { | 39 struct ZygoteProcessInfo { |
38 // Pid from inside the Zygote's PID namespace. | 40 // Pid from inside the Zygote's PID namespace. |
39 base::ProcessHandle internal_pid; | 41 base::ProcessHandle internal_pid; |
40 // Keeps track of which fork delegate helper the process was started from. | 42 // Keeps track of which fork delegate helper the process was started from. |
41 ZygoteForkDelegate* started_from_helper; | 43 ZygoteForkDelegate* started_from_helper; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // notably what the PID of the process is inside the PID namespace of | 118 // notably what the PID of the process is inside the PID namespace of |
117 // the Zygote and whether or not a process was started by the | 119 // the Zygote and whether or not a process was started by the |
118 // ZygoteForkDelegate helper. | 120 // ZygoteForkDelegate helper. |
119 ZygoteProcessMap process_info_map_; | 121 ZygoteProcessMap process_info_map_; |
120 | 122 |
121 const int sandbox_flags_; | 123 const int sandbox_flags_; |
122 ScopedVector<ZygoteForkDelegate> helpers_; | 124 ScopedVector<ZygoteForkDelegate> helpers_; |
123 | 125 |
124 // Count of how many fork delegates for which we've invoked InitialUMA(). | 126 // Count of how many fork delegates for which we've invoked InitialUMA(). |
125 size_t initial_uma_index_; | 127 size_t initial_uma_index_; |
| 128 |
| 129 // This vector contains the PIDs of any child processes which have been |
| 130 // created prior to the construction of the Zygote object, and must be reaped |
| 131 // before the Zygote exits. The Zygote will perform a blocking wait on these |
| 132 // children, so they must be guaranteed to be exiting by the time the Zygote |
| 133 // exits. |
| 134 std::vector<base::ProcessHandle> extra_children_; |
| 135 |
| 136 // This vector contains the FDs that must be closed before reaping the extra |
| 137 // children. |
| 138 std::vector<int> extra_fds_; |
126 }; | 139 }; |
127 | 140 |
128 } // namespace content | 141 } // namespace content |
129 | 142 |
130 #endif // CONTENT_ZYGOTE_ZYGOTE_H_ | 143 #endif // CONTENT_ZYGOTE_ZYGOTE_H_ |
OLD | NEW |