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

Unified Diff: ppapi/native_client/src/trusted/plugin/pnacl_resources.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/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.
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_resources.h ('k') | ppapi/native_client/src/trusted/plugin/service_runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698