Chromium Code Reviews| 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 CHROME_COMMON_NACL_FORK_DELEGATE_LINUX_H_ | |
| 6 #define CHROME_COMMON_NACL_FORK_DELEGATE_LINUX_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #if defined(OS_LINUX) | |
|
jam
2011/06/24 00:10:34
not needed
Brad Chen
2011/06/24 00:40:11
Done.
| |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "content/common/zygote_fork_delegate_linux.h" | |
| 13 | |
| 14 class NaClForkDelegate : public ZygoteForkDelegate { | |
| 15 public: | |
| 16 // The NaClForkDelegate is created during Chrome linux zygote | |
| 17 // initialization, and provides "fork()" functionality with | |
| 18 // NaCl specific process characteristics (specifically address | |
| 19 // space layout) as an alternative to forking the zygote. | |
| 20 // A new delegate is passed in as an argument to ZygoteMain(). | |
| 21 NaClForkDelegate(); | |
| 22 ~NaClForkDelegate(); | |
| 23 | |
| 24 // Initialization happens in the zygote after it has been | |
|
jam
2011/06/24 00:10:34
nit: no need to duplicate the comments from the in
Brad Chen
2011/06/24 00:40:11
Done.
| |
| 25 // started by ZygoteMain. | |
| 26 virtual void Init(const bool sandboxed, | |
| 27 const int browserdesc, | |
| 28 const int sandboxdesc); | |
| 29 // Returns 'true' if the delegate would like to handle a given | |
| 30 // fork request. Otherwise returns false. | |
| 31 virtual bool CanHelp(const std::string& process_type); | |
| 32 // Delegate forks, returning a -1 on failure. Outside the | |
| 33 // suid sandbox, Fork() returns the Linux process ID. Inside | |
| 34 // the sandbox, returns a positive integer, with PID discovery | |
| 35 // handled by the sandbox. | |
| 36 virtual pid_t Fork(const std::vector<int>& fds); | |
| 37 // After a successful for, signal the child to indicate that | |
| 38 // the child's PID has been received. Also communicate the | |
| 39 // channel switch as a part of acknowledgement message. | |
| 40 virtual bool AckChild(const int fd, const std::string& channel_switch); | |
| 41 | |
| 42 private: | |
| 43 pid_t Pid() { | |
|
jam
2011/06/24 00:10:34
nit: why are there private getters for these membe
Brad Chen
2011/06/24 00:40:11
Done.
| |
| 44 return pid_; | |
| 45 }; | |
| 46 int FD() { | |
| 47 return fd_; | |
| 48 }; | |
| 49 | |
| 50 bool sandboxed_; | |
| 51 int fd_; | |
| 52 pid_t pid_; | |
| 53 }; | |
| 54 | |
| 55 #endif // OS_LINUX | |
| 56 #endif // CHROME_COMMON_NACL_FORK_DELEGATE_LINUX_H_ | |
| OLD | NEW |