Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1776)

Unified Diff: chrome/renderer/chrome_ppapi_interfaces.cc

Issue 9158005: RFC: Add an interface for having the browser open a pnacl support file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, update for pnacl layout change Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {

Powered by Google App Engine
This is Rietveld 408576698