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

Unified Diff: ppapi/native_client/src/trusted/plugin/file_utils.cc

Issue 224803002: Enable mmap and identity-based validation caching on pnacl-{llc,ld}.nexe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix token handover for main nexe Created 6 years, 8 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: ppapi/native_client/src/trusted/plugin/file_utils.cc
diff --git a/ppapi/native_client/src/trusted/plugin/file_utils.cc b/ppapi/native_client/src/trusted/plugin/file_utils.cc
index d83432785b2ac433404ec4ae8d35104eac3a6264..639c3e49b186f9b1a13a900d614f6650eefc435d 100644
--- a/ppapi/native_client/src/trusted/plugin/file_utils.cc
+++ b/ppapi/native_client/src/trusted/plugin/file_utils.cc
@@ -16,6 +16,7 @@
#include "native_client/src/include/nacl_scoped_ptr.h"
#include "native_client/src/include/portability_io.h"
#include "native_client/src/include/portability_string.h"
+#include "ppapi/native_client/src/trusted/plugin/utility.h"
namespace plugin {
@@ -72,6 +73,25 @@ StatusCode SlurpFile(int32_t fd,
return PLUGIN_FILE_SUCCESS;
}
+// Converts a PP_FileHandle to a POSIX file descriptor.
+int32_t ConvertFileDescriptor(PP_FileHandle handle) {
+ PLUGIN_PRINTF(("ConvertFileDescriptor, handle=%d\n", handle));
+#if NACL_WINDOWS
+ int32_t file_desc = NACL_NO_FILE_DESC;
+ // On Windows, valid handles are 32 bit unsigned integers so this is safe.
+ file_desc = reinterpret_cast<uintptr_t>(handle);
+ // Convert the Windows HANDLE from Pepper to a POSIX file descriptor.
+ int32_t posix_desc = _open_osfhandle(file_desc, _O_RDWR | _O_BINARY);
+ if (posix_desc == -1) {
+ // Close the Windows HANDLE if it can't be converted.
+ CloseHandle(reinterpret_cast<HANDLE>(file_desc));
+ return -1;
+ }
+ return posix_desc;
+#else
+ return handle;
+#endif
+}
+
} // namespace file_utils
} // namespace plugin
-
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/file_utils.h ('k') | ppapi/native_client/src/trusted/plugin/plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698