OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | |
6 #define CONTENT_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | |
7 #pragma once | |
8 | |
9 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
jam
2011/06/24 00:10:34
this isn't needed because the "_linux" at the end
Brad Chen
2011/06/24 00:40:11
Done.
| |
10 | |
11 #include <unistd.h> | |
12 | |
13 #include "base/basictypes.h" | |
14 | |
15 class ZygoteForkDelegate { | |
16 public: | |
17 // A ZygoteForkDelegate is created during Chrome linux zygote | |
18 // initialization, and provides "fork()" functionality with | |
19 // as an alternative to forking the zygote. A new delegate is | |
20 // passed in as an argument to ZygoteMain(). | |
21 ZygoteForkDelegate() {} | |
22 virtual ~ZygoteForkDelegate() {} | |
23 // Initialization happens in the zygote after it has been | |
24 // started by ZygoteMain. | |
25 virtual void Init(const bool sandboxed, | |
26 const int browserdesc, | |
27 const int sandboxdesc) = 0; | |
28 // Returns 'true' if the delegate would like to handle a given | |
29 // fork request. Otherwise returns false. | |
30 virtual bool CanHelp(const std::string& process_type) = 0; | |
31 // Delegate forks, returning a -1 on failure. Outside the | |
32 // suid sandbox, Fork() returns the Linux process ID. Inside | |
33 // the sandbox, returns a positive integer, with PID discovery | |
34 // handled by the sandbox. | |
35 virtual pid_t Fork(const std::vector<int>& fds) = 0; | |
36 // After a successful for, signal the child to indicate that | |
37 // the child's PID has been received. Also communicate the | |
38 // channel switch as a part of acknowledgement message. | |
39 virtual bool AckChild(const int fd, const std::string& channel_switch) = 0; | |
40 }; | |
41 | |
42 class NullForkDelegate : public ZygoteForkDelegate { | |
jam
2011/06/24 00:10:34
I don't see this being used?
Brad Chen
2011/06/24 00:40:11
It's not. However I figured you'd need a ZygoteFor
jam
2011/06/24 05:14:04
If you change this line in ZygoteMain from
const
Brad Chen
2011/06/24 15:37:14
Done. Also deleted NullForkDelegate().
| |
43 public: | |
44 NullForkDelegate() {} | |
45 ~NullForkDelegate() {} | |
46 virtual void Init(const bool sandboxed, | |
47 const int browserdesc, | |
48 const int sandboxdesc) {} | |
49 virtual bool CanHelp(const std::string& process_type) { return false; } | |
50 virtual pid_t Fork(const std::vector<int>& fds) { return -1; } | |
51 virtual bool AckChild(const int fd, const std::string& channel_switch) { | |
52 return false; | |
53 } | |
54 }; | |
55 | |
56 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | |
57 | |
58 #endif // CONTENT_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ | |
OLD | NEW |