diff options
author | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-08 20:49:43 +0000 |
---|---|---|
committer | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-08 20:49:43 +0000 |
commit | 08cf125f544b93da1ca4c3ed2840bce7fc9ff3fb (patch) | |
tree | 4a9efc495cec1225f7b4d75ec709676b83bc322e /chrome | |
parent | 44b94b8f2d7a1b9a4990f0ad5c0805397215813a (diff) | |
download | chromium_src-08cf125f544b93da1ca4c3ed2840bce7fc9ff3fb.zip chromium_src-08cf125f544b93da1ca4c3ed2840bce7fc9ff3fb.tar.gz chromium_src-08cf125f544b93da1ca4c3ed2840bce7fc9ff3fb.tar.bz2 |
NaCl: Supply MakeSharedMemorySegmentViaIPC() via dependency injection
This will allow NaCl's #include of a Chromium header to be removed.
The extra "executable" argument is in preparation for implementing
this function for Mac OS X.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=469
BUG=http://code.google.com/p/nativeclient/issues/detail?id=583
TEST=NaCl's test_runner.html with NaCl-side change applied
Review URL: http://codereview.chromium.org/4361001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65419 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/nacl/DEPS | 7 | ||||
-rw-r--r-- | chrome/nacl/nacl_thread.cc | 9 | ||||
-rw-r--r-- | chrome/renderer/render_process_impl.cc | 9 | ||||
-rw-r--r-- | chrome/renderer/renderer_sandbox_support_linux.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/renderer_sandbox_support_linux.h | 6 |
5 files changed, 35 insertions, 0 deletions
diff --git a/chrome/nacl/DEPS b/chrome/nacl/DEPS index 8bdeefd..c2468b9 100644 --- a/chrome/nacl/DEPS +++ b/chrome/nacl/DEPS @@ -1,5 +1,12 @@ include_rules = [ "+app", + # TODO(mseaborn): Remove chrome/renderer from this list. This is + # here because we need chrome/renderer/renderer_sandbox_support_linux.h + # for creating shared memory segments. We should probably move this + # sandbox support code out of chrome/renderer. (Previously, this + # header was #included from the native_client directory, which was + # worse.) + "+chrome/renderer", "+chrome/test", "+sandbox/src", "+native_client/src", diff --git a/chrome/nacl/nacl_thread.cc b/chrome/nacl/nacl_thread.cc index c0a64a7..709b976 100644 --- a/chrome/nacl/nacl_thread.cc +++ b/chrome/nacl/nacl_thread.cc @@ -7,6 +7,11 @@ #include "base/scoped_ptr.h" #include "chrome/common/notification_service.h" #include "chrome/common/nacl_messages.h" +#include "native_client/src/shared/imc/nacl_imc.h" + +#if defined(OS_LINUX) +#include "chrome/renderer/renderer_sandbox_support_linux.h" +#endif // This is ugly. We need an interface header file for the exported // sel_ldr interfaces. @@ -40,6 +45,10 @@ void NaClThread::OnControlMessageReceived(const IPC::Message& msg) { } void NaClThread::OnStartSelLdr(std::vector<nacl::FileDescriptor> handles) { +#if defined(OS_LINUX) + nacl::SetCreateMemoryObjectFunc( + renderer_sandbox_support::MakeSharedMemorySegmentViaIPCExecutable); +#endif scoped_array<NaClHandle> array(new NaClHandle[handles.size()]); for (size_t i = 0; i < handles.size(); i++) { array[i] = nacl::ToNativeHandle(handles[i]); diff --git a/chrome/renderer/render_process_impl.cc b/chrome/renderer/render_process_impl.cc index e084000..058758c 100644 --- a/chrome/renderer/render_process_impl.cc +++ b/chrome/renderer/render_process_impl.cc @@ -32,6 +32,7 @@ #include "ipc/ipc_message_utils.h" #include "media/base/media.h" #include "media/base/media_switches.h" +#include "native_client/src/shared/imc/nacl_imc.h" #include "native_client/src/trusted/plugin/nacl_entry_points.h" #include "skia/ext/platform_canvas.h" #include "webkit/glue/plugins/plugin_instance.h" @@ -44,6 +45,10 @@ #include "app/win/iat_patch_function.h" #endif +#if defined(OS_LINUX) +#include "chrome/renderer/renderer_sandbox_support_linux.h" +#endif + namespace { #if !defined(DISABLE_NACL) @@ -168,6 +173,10 @@ RenderProcessImpl::RenderProcessImpl() funcs["launch_nacl_process_multi_fd"] = reinterpret_cast<uintptr_t>(LaunchNaClProcessMultiFD); RegisterInternalNaClPlugin(funcs); +#if defined(OS_LINUX) + nacl::SetCreateMemoryObjectFunc( + renderer_sandbox_support::MakeSharedMemorySegmentViaIPCExecutable); +#endif } #endif diff --git a/chrome/renderer/renderer_sandbox_support_linux.cc b/chrome/renderer/renderer_sandbox_support_linux.cc index 6733f75..283afe6 100644 --- a/chrome/renderer/renderer_sandbox_support_linux.cc +++ b/chrome/renderer/renderer_sandbox_support_linux.cc @@ -92,6 +92,10 @@ int MakeSharedMemorySegmentViaIPC(size_t length) { return result_fd; } +int MakeSharedMemorySegmentViaIPCExecutable(size_t length, bool executable) { + return MakeSharedMemorySegmentViaIPC(length); +} + int MatchFontWithFallback(const std::string& face, bool bold, bool italic, int charset) { Pickle request; diff --git a/chrome/renderer/renderer_sandbox_support_linux.h b/chrome/renderer/renderer_sandbox_support_linux.h index 5f253c9..1b71f38 100644 --- a/chrome/renderer/renderer_sandbox_support_linux.h +++ b/chrome/renderer/renderer_sandbox_support_linux.h @@ -29,8 +29,14 @@ void getRenderStyleForStrike(const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); // Returns a file descriptor for a shared memory segment. +// TODO(mseaborn): Remove this when the call site is gone from native_client. int MakeSharedMemorySegmentViaIPC(size_t length); +// Returns a file descriptor for a shared memory segment. +// The second argument is ignored because SHM segments are always +// mappable with PROT_EXEC on Linux. +int MakeSharedMemorySegmentViaIPCExecutable(size_t length, bool executable); + // Return a read-only file descriptor to the font which best matches the given // properties or -1 on failure. // charset: specifies the language(s) that the font must cover. See |