diff options
author | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-03 04:27:43 +0000 |
---|---|---|
committer | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-03 04:27:43 +0000 |
commit | 338466a8586c58074b8ffb9fcc0d8739a9ff2729 (patch) | |
tree | 93cfefbf64c382aee5b3972b8781dbd59f94567f /chrome/nacl | |
parent | acf668bc247c7d432ca6b4e348d1dcdbef408557 (diff) | |
download | chromium_src-338466a8586c58074b8ffb9fcc0d8739a9ff2729.zip chromium_src-338466a8586c58074b8ffb9fcc0d8739a9ff2729.tar.gz chromium_src-338466a8586c58074b8ffb9fcc0d8739a9ff2729.tar.bz2 |
NaCl: Send the integrated runtime (IRT) library to NaCl
Change the browser process to open the IRT file and send it to the
nascent NaCl process.
If the IRT file is not present, handle this gracefully while still
allowing the NaCl process to run. This is because there may be corner
cases to sort out for getting the IRT into the various Chrome install
images. In the mean time, NaCl executables that are not built to use
the IRT should continue to work.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=1595
TEST=nacl_integration on the Chrome trybot
Review URL: http://codereview.chromium.org/6873133
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/nacl')
-rw-r--r-- | chrome/nacl/nacl_launcher_thread.cc | 27 | ||||
-rw-r--r-- | chrome/nacl/nacl_launcher_thread.h | 3 |
2 files changed, 28 insertions, 2 deletions
diff --git a/chrome/nacl/nacl_launcher_thread.cc b/chrome/nacl/nacl_launcher_thread.cc index 1a435a0..6ea9a6c 100644 --- a/chrome/nacl/nacl_launcher_thread.cc +++ b/chrome/nacl/nacl_launcher_thread.cc @@ -15,6 +15,11 @@ #include "content/renderer/renderer_sandbox_support_linux.h" #endif +#if defined(OS_WIN) +#include <fcntl.h> +#include <io.h> +#endif + #if defined(OS_MACOSX) namespace { @@ -65,6 +70,7 @@ typedef int NaClHandle; // LOG_FATAL (from base/logging.h). extern "C" int NaClMainForChromium(int handle_count, const NaClHandle* handles, int debug); +extern "C" void NaClSetIrtFileDesc(int fd); NaClLauncherThread::NaClLauncherThread(bool debug) { debug_enabled_ = debug ? 1 : 0; @@ -87,7 +93,8 @@ bool NaClLauncherThread::OnControlMessageReceived(const IPC::Message& msg) { } void NaClLauncherThread::OnStartSelLdr( - std::vector<nacl::FileDescriptor> handles) { + std::vector<nacl::FileDescriptor> handles, + bool have_irt_file) { #if defined(OS_LINUX) nacl::SetCreateMemoryObjectFunc( renderer_sandbox_support::MakeSharedMemorySegmentViaIPC); @@ -97,6 +104,24 @@ void NaClLauncherThread::OnStartSelLdr( g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); handles.pop_back(); #endif + + if (have_irt_file) { + CHECK(handles.size() >= 1); + NaClHandle irt_handle = nacl::ToNativeHandle(handles[handles.size() - 1]); + handles.pop_back(); +#if defined(OS_WIN) + int irt_desc = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle), + _O_RDWR | _O_BINARY); + if (irt_desc < 0) { + LOG(ERROR) << "_open_osfhandle() failed"; + return; + } +#else + int irt_desc = irt_handle; +#endif + NaClSetIrtFileDesc(irt_desc); + } + 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/nacl/nacl_launcher_thread.h b/chrome/nacl/nacl_launcher_thread.h index 4452ef1..26992ae 100644 --- a/chrome/nacl/nacl_launcher_thread.h +++ b/chrome/nacl/nacl_launcher_thread.h @@ -21,7 +21,8 @@ class NaClLauncherThread : public ChildThread { private: virtual bool OnControlMessageReceived(const IPC::Message& msg); - void OnStartSelLdr(std::vector<nacl::FileDescriptor> handles); + void OnStartSelLdr(std::vector<nacl::FileDescriptor> handles, + bool have_irt_file); int debug_enabled_; |