| Index: chrome/renderer/pepper/ppb_nacl_private_impl.cc
|
| diff --git a/chrome/renderer/pepper/ppb_nacl_private_impl.cc b/chrome/renderer/pepper/ppb_nacl_private_impl.cc
|
| index 2e9b494ef03c6edbbc61bfeec26ac330a9079b57..b8667f9e57a0ea0a31e922fec0510fb34926d638 100644
|
| --- a/chrome/renderer/pepper/ppb_nacl_private_impl.cc
|
| +++ b/chrome/renderer/pepper/ppb_nacl_private_impl.cc
|
| @@ -33,6 +33,11 @@
|
| #include "webkit/plugins/ppapi/plugin_module.h"
|
| #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
|
|
|
| +#if defined(OS_WIN)
|
| +#include <fcntl.h>
|
| +#include <io.h>
|
| +#endif
|
| +
|
| using content::RenderThread;
|
| using content::RenderView;
|
| using webkit::ppapi::HostGlobals;
|
| @@ -257,6 +262,40 @@ int BrokerDuplicateHandle(void* source_handle,
|
| #endif
|
| }
|
|
|
| +int GetReadonlyPnaclFD(const char* filename) {
|
| + IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit();
|
| + IPC::Sender* sender = content::RenderThread::Get();
|
| + if (sender == NULL)
|
| + sender = g_background_thread_sender.Pointer()->get();
|
| +
|
| + if (!sender->Send(new ChromeViewHostMsg_GetReadonlyPnaclFD(
|
| + std::string(filename),
|
| + &out_fd))) {
|
| + return -1;
|
| + }
|
| +
|
| + if (out_fd == IPC::InvalidPlatformFileForTransit()) {
|
| + return -1;
|
| + }
|
| +
|
| + base::PlatformFile handle = IPC::PlatformFileForTransitToPlatformFile(
|
| + out_fd);
|
| +#if defined(OS_WIN)
|
| + int posix_desc = _open_osfhandle(reinterpret_cast<intptr_t>(handle),
|
| + _O_RDONLY | _O_BINARY);
|
| + if (posix_desc == -1) {
|
| + // Close the Windows HANDLE if it can't be converted.
|
| + CloseHandle(handle);
|
| + return -1;
|
| + }
|
| + return posix_desc;
|
| +#elif defined(OS_POSIX)
|
| + return handle;
|
| +#else
|
| +#error "GetReadonlyPnaclFD: Don't know how to convert FileDescriptor to native."
|
| +#endif
|
| +}
|
| +
|
| const PPB_NaCl_Private nacl_interface = {
|
| &LaunchSelLdr,
|
| &StartPpapiProxy,
|
| @@ -264,6 +303,7 @@ const PPB_NaCl_Private nacl_interface = {
|
| &Are3DInterfacesDisabled,
|
| &EnableBackgroundSelLdrLaunch,
|
| &BrokerDuplicateHandle,
|
| + &GetReadonlyPnaclFD
|
| };
|
|
|
| } // namespace
|
|
|