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> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/containers/small_map.h" | 12 #include "base/containers/small_map.h" |
11 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
12 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
13 #include "base/posix/global_descriptors.h" | 15 #include "base/posix/global_descriptors.h" |
14 #include "base/process/kill.h" | 16 #include "base/process/kill.h" |
15 #include "base/process/process.h" | 17 #include "base/process/process.h" |
16 | 18 |
17 class Pickle; | 19 class Pickle; |
18 class PickleIterator; | 20 class PickleIterator; |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 | 23 |
22 class ZygoteForkDelegate; | 24 class ZygoteForkDelegate; |
23 | 25 |
24 // This is the object which implements the zygote. The ZygoteMain function, | 26 // This is the object which implements the zygote. The ZygoteMain function, |
25 // 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 |
26 // runs it. | 28 // runs it. |
27 class Zygote { | 29 class Zygote { |
28 public: | 30 public: |
29 Zygote(int sandbox_flags, | 31 Zygote(int sandbox_flags, ScopedVector<ZygoteForkDelegate> helpers); |
30 ZygoteForkDelegate* helper); | |
31 ~Zygote(); | 32 ~Zygote(); |
32 | 33 |
33 bool ProcessRequests(); | 34 bool ProcessRequests(); |
34 | 35 |
35 private: | 36 private: |
36 struct ZygoteProcessInfo { | 37 struct ZygoteProcessInfo { |
37 // Pid from inside the Zygote's PID namespace. | 38 // Pid from inside the Zygote's PID namespace. |
38 base::ProcessHandle internal_pid; | 39 base::ProcessHandle internal_pid; |
39 // Keeps track of whether or not a process was started from a fork | 40 // Keeps track of which fork delegate helper the process was started from. |
40 // delegate helper. | 41 ZygoteForkDelegate* started_from_helper; |
41 bool started_from_helper; | |
42 }; | 42 }; |
43 typedef base::SmallMap< std::map<base::ProcessHandle, ZygoteProcessInfo> > | 43 typedef base::SmallMap< std::map<base::ProcessHandle, ZygoteProcessInfo> > |
44 ZygoteProcessMap; | 44 ZygoteProcessMap; |
45 | 45 |
46 // Retrieve a ZygoteProcessInfo from the process_info_map_. | 46 // Retrieve a ZygoteProcessInfo from the process_info_map_. |
47 // Returns true and write to process_info if |pid| can be found, return | 47 // Returns true and write to process_info if |pid| can be found, return |
48 // false otherwise. | 48 // false otherwise. |
49 bool GetProcessInfo(base::ProcessHandle pid, | 49 bool GetProcessInfo(base::ProcessHandle pid, |
50 ZygoteProcessInfo* process_info); | 50 ZygoteProcessInfo* process_info); |
51 | 51 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 const Pickle& pickle, | 112 const Pickle& pickle, |
113 PickleIterator iter); | 113 PickleIterator iter); |
114 | 114 |
115 // The Zygote needs to keep some information about each process. Most | 115 // The Zygote needs to keep some information about each process. Most |
116 // notably what the PID of the process is inside the PID namespace of | 116 // 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 | 117 // the Zygote and whether or not a process was started by the |
118 // ZygoteForkDelegate helper. | 118 // ZygoteForkDelegate helper. |
119 ZygoteProcessMap process_info_map_; | 119 ZygoteProcessMap process_info_map_; |
120 | 120 |
121 const int sandbox_flags_; | 121 const int sandbox_flags_; |
122 ZygoteForkDelegate* helper_; | 122 ScopedVector<ZygoteForkDelegate> helpers_; |
123 | 123 |
124 // These might be set by helper_->InitialUMA. They supply a UMA enumeration | 124 // Count of how many fork delegates for which we've invoked InitialUMA(). |
125 // sample we should report on the first fork. | 125 size_t initial_uma_index_; |
126 std::string initial_uma_name_; | |
127 int initial_uma_sample_; | |
128 int initial_uma_boundary_value_; | |
129 }; | 126 }; |
130 | 127 |
131 } // namespace content | 128 } // namespace content |
132 | 129 |
133 #endif // CONTENT_ZYGOTE_ZYGOTE_H_ | 130 #endif // CONTENT_ZYGOTE_ZYGOTE_H_ |
OLD | NEW |