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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 // The ZygoteForkDelegate allows the Chrome Linux zygote to delegate | 15 // The ZygoteForkDelegate allows the Chrome Linux zygote to delegate |
16 // fork operations to another class that knows how to do some | 16 // fork operations to another class that knows how to do some |
17 // specialized version of fork. | 17 // specialized version of fork. |
18 class ZygoteForkDelegate { | 18 class ZygoteForkDelegate { |
19 public: | 19 public: |
20 // A ZygoteForkDelegate is created during Chrome linux zygote | 20 // A ZygoteForkDelegate is created during Chrome linux zygote |
21 // initialization, and provides "fork()" functionality as an | 21 // initialization, and provides "fork()" functionality as an |
22 // alternative to forking the zygote. A new delegate is passed in | 22 // alternative to forking the zygote. A new delegate is passed in |
23 // as an argument to ZygoteMain(). | 23 // as an argument to ZygoteMain(). |
24 virtual ~ZygoteForkDelegate() {} | 24 virtual ~ZygoteForkDelegate() {} |
25 | 25 |
26 // Initialization happens in the zygote after it has been | 26 // Initialization happens in the zygote after it has been |
27 // started by ZygoteMain. | 27 // started by ZygoteMain. |
28 virtual void Init(int browserdesc, int sandboxdesc) = 0; | 28 virtual void Init(int sandboxdesc) = 0; |
29 | 29 |
30 // After Init, supply a UMA_HISTOGRAM_ENUMERATION the delegate | 30 // After Init, supply a UMA_HISTOGRAM_ENUMERATION the delegate |
31 // would like to supply on the first fork. | 31 // would like to supply on the first fork. |
32 virtual void InitialUMA(std::string* uma_name, | 32 virtual void InitialUMA(std::string* uma_name, |
33 int* uma_sample, | 33 int* uma_sample, |
34 int* uma_boundary_value) = 0; | 34 int* uma_boundary_value) = 0; |
35 | 35 |
36 // Returns 'true' if the delegate would like to handle a given fork | 36 // Returns 'true' if the delegate would like to handle a given fork |
37 // request. Otherwise returns false. Optionally, fills in uma_name et al | 37 // request. Otherwise returns false. Optionally, fills in uma_name et al |
38 // with a report the helper wants to make via UMA_HISTOGRAM_ENUMERATION. | 38 // with a report the helper wants to make via UMA_HISTOGRAM_ENUMERATION. |
39 virtual bool CanHelp(const std::string& process_type, std::string* uma_name, | 39 virtual bool CanHelp(const std::string& process_type, std::string* uma_name, |
40 int* uma_sample, int* uma_boundary_value) = 0; | 40 int* uma_sample, int* uma_boundary_value) = 0; |
41 | 41 |
42 // Delegate forks, returning a -1 on failure. Outside the | 42 // Delegate forks, returning a -1 on failure. Outside the |
43 // suid sandbox, Fork() returns the Linux process ID. Inside | 43 // suid sandbox, Fork() returns the Linux process ID. Inside |
44 // the sandbox, returns a positive integer, with PID discovery | 44 // the sandbox, returns a positive integer, with PID discovery |
45 // handled by the sandbox. | 45 // handled by the sandbox. |
46 virtual pid_t Fork(const std::vector<int>& fds) = 0; | 46 virtual pid_t Fork(const std::vector<int>& fds) = 0; |
47 | 47 |
48 // After a successful for, signal the child to indicate that | 48 // After a successful for, signal the child to indicate that |
49 // the child's PID has been received. Also communicate the | 49 // the child's PID has been received. Also communicate the |
50 // channel switch as a part of acknowledgement message. | 50 // channel switch as a part of acknowledgement message. |
51 virtual bool AckChild(int fd, const std::string& channel_switch) = 0; | 51 virtual bool AckChild(int fd, const std::string& channel_switch) = 0; |
52 }; | 52 }; |
53 | 53 |
54 } // namespace content | 54 } // namespace content |
55 | 55 |
56 #endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | 56 #endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ |
OLD | NEW |