diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-03 07:10:44 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-03 07:10:44 +0000 |
commit | 4734d0becafa5b77d708020eed24d97148ea208d (patch) | |
tree | db94ca97a1ac3f1831033ef07dbda98ccb53dfa6 /content/public/common/child_process_host.h | |
parent | 463ea5fc399e6275a2351df6b398b7d91b8f5a61 (diff) | |
download | chromium_src-4734d0becafa5b77d708020eed24d97148ea208d.zip chromium_src-4734d0becafa5b77d708020eed24d97148ea208d.tar.gz chromium_src-4734d0becafa5b77d708020eed24d97148ea208d.tar.bz2 |
Make ChildProcessHost be used through an interface in content/public, instead of by inheritence.
BUG=98716
Review URL: http://codereview.chromium.org/8787004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public/common/child_process_host.h')
-rw-r--r-- | content/public/common/child_process_host.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/content/public/common/child_process_host.h b/content/public/common/child_process_host.h new file mode 100644 index 0000000..31839fc --- /dev/null +++ b/content/public/common/child_process_host.h @@ -0,0 +1,97 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PULIC_COMMON_CHILD_PROCESS_HOST_H_ +#define CONTENT_PULIC_COMMON_CHILD_PROCESS_HOST_H_ +#pragma once + +#include "build/build_config.h" +#include "content/common/content_export.h" +#include "ipc/ipc_channel_proxy.h" + +class FilePath; + +namespace content { + +class ChildProcessHostDelegate; + +// Interface that all users of ChildProcessHost need to provide. +class ChildProcessHost : public IPC::Message::Sender { + public: + virtual ~ChildProcessHost() {} + + // Used to create a child process host. The delegate must outlive this object. + CONTENT_EXPORT static ChildProcessHost* Create( + ChildProcessHostDelegate* delegate); + + // These flags may be passed to GetChildPath in order to alter its behavior, + // causing it to return a child path more suited to a specific task. + enum { + // No special behavior requested. + CHILD_NORMAL = 0, + +#if defined(OS_LINUX) + // Indicates that the child execed after forking may be execced from + // /proc/self/exe rather than using the "real" app path. This prevents + // autoupdate from confusing us if it changes the file out from under us. + // You will generally want to set this on Linux, except when there is an + // override to the command line (for example, we're forking a renderer in + // gdb). In this case, you'd use GetChildPath to get the real executable + // file name, and then prepend the GDB command to the command line. + CHILD_ALLOW_SELF = 1 << 0, +#elif defined(OS_MACOSX) + + // Requests that the child run in a process that does not have the + // PIE (position-independent executable) bit set, effectively disabling + // ASLR. For process types that need to allocate a large contiguous + // region, ASLR may not leave a large enough "hole" for the purpose. This + // option should be used sparingly, and only when absolutely necessary. + // This option is currently incompatible with CHILD_ALLOW_HEAP_EXECUTION. + CHILD_NO_PIE = 1 << 1, + + // Requests that the child run in a process that does not protect the + // heap against execution. Normally, heap pages may be made executable + // with mprotect, so this mode should be used sparingly. It is intended + // for processes that may host plug-ins that expect an executable heap + // without having to call mprotect. This option is currently incompatible + // with CHILD_NO_PIE. + CHILD_ALLOW_HEAP_EXECUTION = 1 << 2, +#endif + }; + + // Returns the pathname to be used for a child process. If a subprocess + // pathname was specified on the command line, that will be used. Otherwise, + // the default child process pathname will be returned. On most platforms, + // this will be the same as the currently-executing process. + // + // The |flags| argument accepts one or more flags such as CHILD_ALLOW_SELF + // and CHILD_ALLOW_HEAP_EXECUTION as defined above. Pass only CHILD_NORMAL + // if none of these special behaviors are required. + // + // On failure, returns an empty FilePath. + CONTENT_EXPORT static FilePath GetChildPath(int flags); + + // Send the shutdown message to the child process. + // Does not check with the delegate's CanShutdown. + virtual void ForceShutdown() = 0; + + // Creates the IPC channel. Returns the channel id if it succeeded, an + // empty string otherwise + virtual std::string CreateChannel() = 0; + + // Returns true iff the IPC channel is currently being opened; + virtual bool IsChannelOpening() = 0; + + // Adds an IPC message filter. A reference will be kept to the filter. + virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) = 0; + +#if defined(OS_POSIX) + // See IPC::Channel::TakeClientFileDescriptor. + virtual int TakeClientFileDescriptor() = 0; +#endif +}; + +}; // namespace content + +#endif // CONTENT_PULIC_COMMON_CHILD_PROCESS_HOST_H_ |