| 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_LINUX_H_ | 5 #ifndef CONTENT_ZYGOTE_ZYGOTE_LINUX_H_ |
| 6 #define CONTENT_ZYGOTE_ZYGOTE_LINUX_H_ | 6 #define CONTENT_ZYGOTE_ZYGOTE_LINUX_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/containers/small_map.h" | 13 #include "base/containers/small_map.h" |
| 13 #include "base/files/scoped_file.h" | 14 #include "base/files/scoped_file.h" |
| 14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 15 #include "base/posix/global_descriptors.h" | 16 #include "base/posix/global_descriptors.h" |
| 16 #include "base/process/kill.h" | 17 #include "base/process/kill.h" |
| 17 #include "base/process/process.h" | 18 #include "base/process/process.h" |
| 18 #include "base/process/process_handle.h" | 19 #include "base/process/process_handle.h" |
| 19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 20 | 21 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 const std::string& channel_id, | 98 const std::string& channel_id, |
| 98 base::ScopedFD pid_oracle, | 99 base::ScopedFD pid_oracle, |
| 99 std::string* uma_name, | 100 std::string* uma_name, |
| 100 int* uma_sample, | 101 int* uma_sample, |
| 101 int* uma_boundary_value); | 102 int* uma_boundary_value); |
| 102 | 103 |
| 103 // Unpacks process type and arguments from |iter| and forks a new process. | 104 // Unpacks process type and arguments from |iter| and forks a new process. |
| 104 // Returns -1 on error, otherwise returns twice, returning 0 to the child | 105 // Returns -1 on error, otherwise returns twice, returning 0 to the child |
| 105 // process and the child process ID to the parent process, like fork(). | 106 // process and the child process ID to the parent process, like fork(). |
| 106 base::ProcessId ReadArgsAndFork(base::PickleIterator iter, | 107 base::ProcessId ReadArgsAndFork(base::PickleIterator iter, |
| 107 ScopedVector<base::ScopedFD> fds, | 108 std::vector<base::ScopedFD> fds, |
| 108 std::string* uma_name, | 109 std::string* uma_name, |
| 109 int* uma_sample, | 110 int* uma_sample, |
| 110 int* uma_boundary_value); | 111 int* uma_boundary_value); |
| 111 | 112 |
| 112 // Handle a 'fork' request from the browser: this means that the browser | 113 // Handle a 'fork' request from the browser: this means that the browser |
| 113 // wishes to start a new renderer. Returns true if we are in a new process, | 114 // wishes to start a new renderer. Returns true if we are in a new process, |
| 114 // otherwise writes the child_pid back to the browser via |fd|. Writes a | 115 // otherwise writes the child_pid back to the browser via |fd|. Writes a |
| 115 // child_pid of -1 on error. | 116 // child_pid of -1 on error. |
| 116 bool HandleForkRequest(int fd, | 117 bool HandleForkRequest(int fd, |
| 117 base::PickleIterator iter, | 118 base::PickleIterator iter, |
| 118 ScopedVector<base::ScopedFD> fds); | 119 std::vector<base::ScopedFD> fds); |
| 119 | 120 |
| 120 bool HandleGetSandboxStatus(int fd, | 121 bool HandleGetSandboxStatus(int fd, |
| 121 base::PickleIterator iter); | 122 base::PickleIterator iter); |
| 122 | 123 |
| 123 // Attempt to reap the child process by calling waitpid, and return | 124 // Attempt to reap the child process by calling waitpid, and return |
| 124 // whether successful. If the process has not terminated within | 125 // whether successful. If the process has not terminated within |
| 125 // 2 seconds of its reap request, send it SIGKILL. | 126 // 2 seconds of its reap request, send it SIGKILL. |
| 126 bool ReapChild(const base::TimeTicks& now, ZygoteProcessInfo* child); | 127 bool ReapChild(const base::TimeTicks& now, ZygoteProcessInfo* child); |
| 127 | 128 |
| 128 // Attempt to reap all outstanding children in |to_reap_|. | 129 // Attempt to reap all outstanding children in |to_reap_|. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 151 // children. | 152 // children. |
| 152 std::vector<int> extra_fds_; | 153 std::vector<int> extra_fds_; |
| 153 | 154 |
| 154 // The vector contains the child processes that need to be reaped. | 155 // The vector contains the child processes that need to be reaped. |
| 155 std::vector<ZygoteProcessInfo> to_reap_; | 156 std::vector<ZygoteProcessInfo> to_reap_; |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 } // namespace content | 159 } // namespace content |
| 159 | 160 |
| 160 #endif // CONTENT_ZYGOTE_ZYGOTE_LINUX_H_ | 161 #endif // CONTENT_ZYGOTE_ZYGOTE_LINUX_H_ |
| OLD | NEW |