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 <string> | 8 #include <string> |
9 #include <vector> | |
10 | 9 |
11 #include "base/containers/small_map.h" | 10 #include "base/containers/small_map.h" |
| 11 #include "base/files/scoped_file.h" |
| 12 #include "base/memory/scoped_vector.h" |
12 #include "base/posix/global_descriptors.h" | 13 #include "base/posix/global_descriptors.h" |
13 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
14 #include "base/process/process.h" | 15 #include "base/process/process.h" |
15 | 16 |
16 class Pickle; | 17 class Pickle; |
17 class PickleIterator; | 18 class PickleIterator; |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 class ZygoteForkDelegate; | 22 class ZygoteForkDelegate; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const std::string& channel_id, | 83 const std::string& channel_id, |
83 std::string* uma_name, | 84 std::string* uma_name, |
84 int* uma_sample, | 85 int* uma_sample, |
85 int* uma_boundary_value); | 86 int* uma_boundary_value); |
86 | 87 |
87 // Unpacks process type and arguments from |pickle| and forks a new process. | 88 // Unpacks process type and arguments from |pickle| and forks a new process. |
88 // Returns -1 on error, otherwise returns twice, returning 0 to the child | 89 // Returns -1 on error, otherwise returns twice, returning 0 to the child |
89 // process and the child process ID to the parent process, like fork(). | 90 // process and the child process ID to the parent process, like fork(). |
90 base::ProcessId ReadArgsAndFork(const Pickle& pickle, | 91 base::ProcessId ReadArgsAndFork(const Pickle& pickle, |
91 PickleIterator iter, | 92 PickleIterator iter, |
92 std::vector<int>& fds, | 93 ScopedVector<base::ScopedFD> fds, |
93 std::string* uma_name, | 94 std::string* uma_name, |
94 int* uma_sample, | 95 int* uma_sample, |
95 int* uma_boundary_value); | 96 int* uma_boundary_value); |
96 | 97 |
97 // Handle a 'fork' request from the browser: this means that the browser | 98 // Handle a 'fork' request from the browser: this means that the browser |
98 // wishes to start a new renderer. Returns true if we are in a new process, | 99 // wishes to start a new renderer. Returns true if we are in a new process, |
99 // otherwise writes the child_pid back to the browser via |fd|. Writes a | 100 // otherwise writes the child_pid back to the browser via |fd|. Writes a |
100 // child_pid of -1 on error. | 101 // child_pid of -1 on error. |
101 bool HandleForkRequest(int fd, | 102 bool HandleForkRequest(int fd, |
102 const Pickle& pickle, | 103 const Pickle& pickle, |
103 PickleIterator iter, | 104 PickleIterator iter, |
104 std::vector<int>& fds); | 105 ScopedVector<base::ScopedFD> fds); |
105 | 106 |
106 bool HandleGetSandboxStatus(int fd, | 107 bool HandleGetSandboxStatus(int fd, |
107 const Pickle& pickle, | 108 const Pickle& pickle, |
108 PickleIterator iter); | 109 PickleIterator iter); |
109 | 110 |
110 // The Zygote needs to keep some information about each process. Most | 111 // The Zygote needs to keep some information about each process. Most |
111 // notably what the PID of the process is inside the PID namespace of | 112 // notably what the PID of the process is inside the PID namespace of |
112 // the Zygote and whether or not a process was started by the | 113 // the Zygote and whether or not a process was started by the |
113 // ZygoteForkDelegate helper. | 114 // ZygoteForkDelegate helper. |
114 ZygoteProcessMap process_info_map_; | 115 ZygoteProcessMap process_info_map_; |
115 | 116 |
116 const int sandbox_flags_; | 117 const int sandbox_flags_; |
117 ZygoteForkDelegate* helper_; | 118 ZygoteForkDelegate* helper_; |
118 | 119 |
119 // These might be set by helper_->InitialUMA. They supply a UMA enumeration | 120 // These might be set by helper_->InitialUMA. They supply a UMA enumeration |
120 // sample we should report on the first fork. | 121 // sample we should report on the first fork. |
121 std::string initial_uma_name_; | 122 std::string initial_uma_name_; |
122 int initial_uma_sample_; | 123 int initial_uma_sample_; |
123 int initial_uma_boundary_value_; | 124 int initial_uma_boundary_value_; |
124 }; | 125 }; |
125 | 126 |
126 } // namespace content | 127 } // namespace content |
127 | 128 |
128 #endif // CONTENT_ZYGOTE_ZYGOTE_H_ | 129 #endif // CONTENT_ZYGOTE_ZYGOTE_H_ |
OLD | NEW |