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_NACL_NACL_FORK_DELEGATE_LINUX_H_ |
| 6 #define CHROME_NACL_NACL_FORK_DELEGATE_LINUX_H_ |
| 7 #pragma once |
| 8 |
| 9 #if defined(OS_LINUX) |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "content/common/zygote_fork_delegate.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 |
| 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 |
| 38 private: |
| 39 pid_t Pid() { |
| 40 return pid_; |
| 41 }; |
| 42 int FD() { |
| 43 return fd_; |
| 44 }; |
| 45 |
| 46 bool sandboxed_; |
| 47 int fd_; |
| 48 pid_t pid_; |
| 49 }; |
| 50 |
| 51 #endif // OS_LINUX |
| 52 #endif // CHROME_NACL_NACL_FORK_DELEGATE_LINUX_H_ |
OLD | NEW |