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_PULIC_COMMON_CHILD_PROCESS_HOST_H_ |
| 6 #define CONTENT_PULIC_COMMON_CHILD_PROCESS_HOST_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "build/build_config.h" |
| 10 #include "content/common/content_export.h" |
| 11 #include "ipc/ipc_channel_proxy.h" |
| 12 |
| 13 class FilePath; |
| 14 |
| 15 namespace content { |
| 16 |
| 17 class ChildProcessHostDelegate; |
| 18 |
| 19 // Interface that all users of ChildProcessHost need to provide. |
| 20 class ChildProcessHost : public IPC::Message::Sender { |
| 21 public: |
| 22 virtual ~ChildProcessHost() {} |
| 23 |
| 24 // Used to create a child process host. The delegate must outlive this object. |
| 25 CONTENT_EXPORT static ChildProcessHost* Create( |
| 26 ChildProcessHostDelegate* delegate); |
| 27 |
| 28 // These flags may be passed to GetChildPath in order to alter its behavior, |
| 29 // causing it to return a child path more suited to a specific task. |
| 30 enum { |
| 31 // No special behavior requested. |
| 32 CHILD_NORMAL = 0, |
| 33 |
| 34 #if defined(OS_LINUX) |
| 35 // Indicates that the child execed after forking may be execced from |
| 36 // /proc/self/exe rather than using the "real" app path. This prevents |
| 37 // autoupdate from confusing us if it changes the file out from under us. |
| 38 // You will generally want to set this on Linux, except when there is an |
| 39 // override to the command line (for example, we're forking a renderer in |
| 40 // gdb). In this case, you'd use GetChildPath to get the real executable |
| 41 // file name, and then prepend the GDB command to the command line. |
| 42 CHILD_ALLOW_SELF = 1 << 0, |
| 43 #elif defined(OS_MACOSX) |
| 44 |
| 45 // Requests that the child run in a process that does not have the |
| 46 // PIE (position-independent executable) bit set, effectively disabling |
| 47 // ASLR. For process types that need to allocate a large contiguous |
| 48 // region, ASLR may not leave a large enough "hole" for the purpose. This |
| 49 // option should be used sparingly, and only when absolutely necessary. |
| 50 // This option is currently incompatible with CHILD_ALLOW_HEAP_EXECUTION. |
| 51 CHILD_NO_PIE = 1 << 1, |
| 52 |
| 53 // Requests that the child run in a process that does not protect the |
| 54 // heap against execution. Normally, heap pages may be made executable |
| 55 // with mprotect, so this mode should be used sparingly. It is intended |
| 56 // for processes that may host plug-ins that expect an executable heap |
| 57 // without having to call mprotect. This option is currently incompatible |
| 58 // with CHILD_NO_PIE. |
| 59 CHILD_ALLOW_HEAP_EXECUTION = 1 << 2, |
| 60 #endif |
| 61 }; |
| 62 |
| 63 // Returns the pathname to be used for a child process. If a subprocess |
| 64 // pathname was specified on the command line, that will be used. Otherwise, |
| 65 // the default child process pathname will be returned. On most platforms, |
| 66 // this will be the same as the currently-executing process. |
| 67 // |
| 68 // The |flags| argument accepts one or more flags such as CHILD_ALLOW_SELF |
| 69 // and CHILD_ALLOW_HEAP_EXECUTION as defined above. Pass only CHILD_NORMAL |
| 70 // if none of these special behaviors are required. |
| 71 // |
| 72 // On failure, returns an empty FilePath. |
| 73 CONTENT_EXPORT static FilePath GetChildPath(int flags); |
| 74 |
| 75 // Send the shutdown message to the child process. |
| 76 // Does not check with the delegate's CanShutdown. |
| 77 virtual void ForceShutdown() = 0; |
| 78 |
| 79 // Creates the IPC channel. Returns the channel id if it succeeded, an |
| 80 // empty string otherwise |
| 81 virtual std::string CreateChannel() = 0; |
| 82 |
| 83 // Returns true iff the IPC channel is currently being opened; |
| 84 virtual bool IsChannelOpening() = 0; |
| 85 |
| 86 // Adds an IPC message filter. A reference will be kept to the filter. |
| 87 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; |
| 88 |
| 89 #if defined(OS_POSIX) |
| 90 // See IPC::Channel::TakeClientFileDescriptor. |
| 91 virtual int TakeClientFileDescriptor() = 0; |
| 92 #endif |
| 93 }; |
| 94 |
| 95 }; // namespace content |
| 96 |
| 97 #endif // CONTENT_PULIC_COMMON_CHILD_PROCESS_HOST_H_ |
OLD | NEW |