Index: chrome/renderer/chrome_ppapi_interfaces.cc |
diff --git a/chrome/renderer/chrome_ppapi_interfaces.cc b/chrome/renderer/chrome_ppapi_interfaces.cc |
index 517dbcfdbdabfd3e3d9e962b772dd9122574a039..ac11993107f92531c5a9192f132359309aca214e 100644 |
--- a/chrome/renderer/chrome_ppapi_interfaces.cc |
+++ b/chrome/renderer/chrome_ppapi_interfaces.cc |
@@ -69,6 +69,33 @@ int UrandomFD(void) { |
#endif |
} |
+int GetReadonlyPnaclFD(const char* filename) { |
+ nacl::FileDescriptor out_fd; |
+ if (!RenderThread::Get()->Send( |
+ new ChromeViewHostMsg_GetReadonlyPnaclFD( |
+ std::string(filename), |
+ &out_fd))) { |
+ return -1; |
+ } |
+ |
+ // TODO(jvoung): Should nacl::FileDescriptor handle this? |
+ // Should we leave the HANDLE as a HANDLE for now? |
+#if defined(OS_WIN) |
+ HANDLE handle = nacl::ToNativeHandle(out_fd); |
+ int posix_desc = _open_osfhandle(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 nacl::ToNativeHandle(out_fd); |
+#else |
+#error "GetReadonlyPnaclFD: Don't know how to convert FileDescriptor to native." |
+#endif |
+} |
+ |
bool Are3DInterfacesDisabled() { |
return CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisable3DAPIs); |
} |
@@ -83,6 +110,7 @@ const PPB_NaCl_Private ppb_nacl = { |
&UrandomFD, |
&Are3DInterfacesDisabled, |
&EnableBackgroundSelLdrLaunch, |
+ &GetReadonlyPnaclFD |
}; |
class PPB_NaCl_Impl { |