Index: ppapi/native_client/src/trusted/plugin/pnacl_resources.cc |
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc b/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc |
index bdd5fca188b709528da85315b11a9dab90d1bdbe..15cefb26068314d48c49bcaa1f0646437589388a 100644 |
--- a/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc |
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc |
@@ -7,6 +7,7 @@ |
#include "native_client/src/include/portability_io.h" |
#include "native_client/src/shared/platform/nacl_check.h" |
#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
+#include "native_client/src/trusted/desc_cacheability/desc_cacheability.h" |
#include "ppapi/c/pp_errors.h" |
#include "ppapi/native_client/src/trusted/plugin/file_utils.h" |
#include "ppapi/native_client/src/trusted/plugin/manifest.h" |
@@ -64,26 +65,19 @@ PnaclResources::~PnaclResources() { |
} |
// static |
-int32_t PnaclResources::GetPnaclFD(Plugin* plugin, const char* filename) { |
+int32_t PnaclResources::GetPnaclFD(Plugin* plugin, |
+ const char* filename, |
+ bool is_executable, |
+ uint64_t* file_token_lo, |
+ uint64_t* file_token_hi) { |
PP_FileHandle file_handle = |
- plugin->nacl_interface()->GetReadonlyPnaclFd(filename); |
+ plugin->nacl_interface()->GetReadonlyPnaclFd( |
+ filename, PP_FromBool(is_executable), file_token_lo, file_token_hi); |
if (file_handle == PP_kInvalidFileHandle) |
return -1; |
-#if NACL_WINDOWS |
- //////// Now try the posix view. |
- int32_t posix_desc = _open_osfhandle(reinterpret_cast<intptr_t>(file_handle), |
- _O_RDONLY | _O_BINARY); |
- if (posix_desc == -1) { |
- PLUGIN_PRINTF(( |
- "PnaclResources::GetPnaclFD failed to convert HANDLE to posix\n")); |
- // Close the Windows HANDLE if it can't be converted. |
- CloseHandle(file_handle); |
- } |
- return posix_desc; |
-#else |
- return file_handle; |
-#endif |
+ int32_t posix_desc = file_utils::ConvertFileDescriptor(file_handle); |
+ return posix_desc; // Also need file info! |
} |
nacl::DescWrapper* PnaclResources::WrapperForUrl(const nacl::string& url) { |
@@ -104,7 +98,10 @@ void PnaclResources::ReadResourceInfo( |
PLUGIN_PRINTF(("Pnacl-converted resources info url: %s\n", |
resource_info_filename.c_str())); |
- int32_t fd = GetPnaclFD(plugin_, resource_info_filename.c_str()); |
+ uint64_t file_token_lo; |
+ uint64_t file_token_hi; |
+ int32_t fd = GetPnaclFD(plugin_, resource_info_filename.c_str(), false, |
+ &file_token_lo, &file_token_hi); |
if (fd < 0) { |
// File-open failed. Assume this means that the file is |
// not actually installed. |
@@ -207,8 +204,11 @@ void PnaclResources::StartLoad( |
} |
nacl::string filename = PnaclUrls::PnaclComponentURLToFilename(full_url); |
- int32_t fd = PnaclResources::GetPnaclFD(plugin_, filename.c_str()); |
- if (fd < 0) { |
+ NaClFileInfo tmp_info; |
+ tmp_info.desc = PnaclResources::GetPnaclFD(plugin_, filename.c_str(), true, |
+ &tmp_info.file_token.lo, |
+ &tmp_info.file_token.hi); |
+ if (tmp_info.desc < 0) { |
// File-open failed. Assume this means that the file is |
// not actually installed. This shouldn't actually occur since |
// ReadResourceInfo() should happen first, and error out. |
@@ -221,7 +221,20 @@ void PnaclResources::StartLoad( |
break; |
} else { |
resource_wrappers_[resource_urls[i]] = |
- plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY); |
+ plugin_->wrapper_factory()->MakeFileDesc(tmp_info.desc, O_RDONLY); |
+ if (tmp_info.file_token.lo != 0 && tmp_info.file_token.hi != 0) { |
+ if (!NaClDescSetFileToken(resource_wrappers_[resource_urls[i]]->desc(), |
+ &tmp_info.file_token)) { |
+ PLUGIN_PRINTF(( |
+ "PnaclResources::StartLoad: NaClDescSetFileToken failed\n")); |
+ } else { |
+ PLUGIN_PRINTF(( |
+ "PnaclResources::StartLoad: NaClDescSetFileToken success\n")); |
+ } |
+ } else { |
+ PLUGIN_PRINTF(( |
+ "PnaclResources::StartLoad: no file token\n")); |
+ } |
} |
} |
// We're done! Queue the callback. |