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_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ |
6 #define CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | 6 #define CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ |
7 | 7 |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 int* uma_boundary_value) = 0; | 42 int* uma_boundary_value) = 0; |
43 | 43 |
44 // Returns 'true' if the delegate would like to handle a given fork | 44 // Returns 'true' if the delegate would like to handle a given fork |
45 // request. Otherwise returns false. Optionally, fills in uma_name et al | 45 // request. Otherwise returns false. Optionally, fills in uma_name et al |
46 // with a report the helper wants to make via UMA_HISTOGRAM_ENUMERATION. | 46 // with a report the helper wants to make via UMA_HISTOGRAM_ENUMERATION. |
47 virtual bool CanHelp(const std::string& process_type, std::string* uma_name, | 47 virtual bool CanHelp(const std::string& process_type, std::string* uma_name, |
48 int* uma_sample, int* uma_boundary_value) = 0; | 48 int* uma_sample, int* uma_boundary_value) = 0; |
49 | 49 |
50 // Indexes of FDs in the vector passed to Fork(). | 50 // Indexes of FDs in the vector passed to Fork(). |
51 enum { | 51 enum { |
52 // Used to pass in the descriptor for talking to the Browser | 52 // Used to pass in the descriptor for talking to the Browser. |
| 53 // Because the children use ChannelMojo, this is actually the Mojo fd. |
53 kBrowserFDIndex, | 54 kBrowserFDIndex, |
54 // The PID oracle is used in the protocol for discovering the | 55 // The PID oracle is used in the protocol for discovering the |
55 // child process's real PID from within the SUID sandbox. | 56 // child process's real PID from within the SUID sandbox. |
56 // The child process is required to write to the socket after | 57 // The child process is required to write to the socket after |
57 // successfully forking. | 58 // successfully forking. |
58 kPIDOracleFDIndex, | 59 kPIDOracleFDIndex, |
59 kMojoParentFDIndex, | |
60 kNumPassedFDs // Number of FDs in the vector passed to Fork(). | 60 kNumPassedFDs // Number of FDs in the vector passed to Fork(). |
61 }; | 61 }; |
62 | 62 |
63 // Delegate forks, returning a -1 on failure. Outside the | 63 // Delegate forks, returning a -1 on failure. Outside the |
64 // suid sandbox, Fork() returns the Linux process ID. | 64 // suid sandbox, Fork() returns the Linux process ID. |
65 // This method is not aware of any potential pid namespaces, so it'll | 65 // This method is not aware of any potential pid namespaces, so it'll |
66 // return a raw pid just like fork() would. | 66 // return a raw pid just like fork() would. |
67 // Delegate is responsible for communicating the channel ID to the | 67 // Delegate is responsible for communicating the channel ID to the |
68 // newly created child process. | 68 // newly created child process. |
69 virtual pid_t Fork(const std::string& process_type, | 69 virtual pid_t Fork(const std::string& process_type, |
70 const std::vector<int>& fds, | 70 const std::vector<int>& fds, |
71 const std::string& channel_id) = 0; | 71 const std::string& channel_id) = 0; |
72 | 72 |
73 // The fork delegate must also assume the role of waiting for its children | 73 // The fork delegate must also assume the role of waiting for its children |
74 // since the caller will not be their parents and cannot do it. |pid| here | 74 // since the caller will not be their parents and cannot do it. |pid| here |
75 // should be a pid that has been returned by the Fork() method. i.e. This | 75 // should be a pid that has been returned by the Fork() method. i.e. This |
76 // method is completely unaware of eventual PID namespaces due to sandboxing. | 76 // method is completely unaware of eventual PID namespaces due to sandboxing. |
77 // |known_dead| indicates that the process is already dead and that a | 77 // |known_dead| indicates that the process is already dead and that a |
78 // blocking wait() should be performed. In this case, GetTerminationStatus() | 78 // blocking wait() should be performed. In this case, GetTerminationStatus() |
79 // will send a SIGKILL to the target process first. | 79 // will send a SIGKILL to the target process first. |
80 virtual bool GetTerminationStatus(pid_t pid, bool known_dead, | 80 virtual bool GetTerminationStatus(pid_t pid, bool known_dead, |
81 base::TerminationStatus* status, | 81 base::TerminationStatus* status, |
82 int* exit_code) = 0; | 82 int* exit_code) = 0; |
83 }; | 83 }; |
84 | 84 |
85 } // namespace content | 85 } // namespace content |
86 | 86 |
87 #endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | 87 #endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ |
OLD | NEW |