diff options
author | jvoung@chromium.org <jvoung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-23 07:26:07 +0000 |
---|---|---|
committer | jvoung@chromium.org <jvoung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-23 07:26:07 +0000 |
commit | 1090d2b8925a4ca54b21c6f999fbf9ca992cd44e (patch) | |
tree | 5b9985406fba93bf94af93acf3e84f984c83ae74 /ppapi | |
parent | 8b2f47cc891e5e84c7f4772f9b8df732ea28ac91 (diff) | |
download | chromium_src-1090d2b8925a4ca54b21c6f999fbf9ca992cd44e.zip chromium_src-1090d2b8925a4ca54b21c6f999fbf9ca992cd44e.tar.gz chromium_src-1090d2b8925a4ca54b21c6f999fbf9ca992cd44e.tar.bz2 |
Set file tokens for NaCl main nexe if available to enable validation caching.
Also enable mmap'ing the main nexe, which may help a bit
in subsequent runs as well (first run the validator needs
page in all of the text anyway).
pnacl-llc.nexe, etc will be handled separately:
https://codereview.chromium.org/224803002/
TEST=NaClBrowserTestVcacheExtension.ValidationCacheOfMainNexe
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3421
Review URL: https://codereview.chromium.org/263683002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272429 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/private/ppb_nacl_private.idl | 7 | ||||
-rw-r--r-- | ppapi/c/private/ppb_nacl_private.h | 9 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.cc | 21 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.h | 2 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 6 |
5 files changed, 37 insertions, 8 deletions
diff --git a/ppapi/api/private/ppb_nacl_private.idl b/ppapi/api/private/ppb_nacl_private.idl index 8bdcc07..530132d 100644 --- a/ppapi/api/private/ppb_nacl_private.idl +++ b/ppapi/api/private/ppb_nacl_private.idl @@ -426,9 +426,14 @@ interface PPB_NaCl_Private { [in] str_t message); /* Downloads the .nexe file at the given URL to a file, and sets |handle| - * to a handle to a file containing its contents. */ + * to a handle to a file containing its contents. + * If metadata for identity-based validation caching is available + * then it sets file_token_lo and file_token_lo (otherwise left untouched). + */ void DownloadNexe([in] PP_Instance instance, [in] str_t url, [out] PP_FileHandle handle, + [out] uint64_t file_token_lo, + [out] uint64_t file_token_hi, [in] PP_CompletionCallback callback); }; diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h index ec26a17..fbf57cd 100644 --- a/ppapi/c/private/ppb_nacl_private.h +++ b/ppapi/c/private/ppb_nacl_private.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/ppb_nacl_private.idl modified Mon May 19 11:12:19 2014. */ +/* From private/ppb_nacl_private.idl modified Wed May 21 13:23:26 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ @@ -416,10 +416,15 @@ struct PPB_NaCl_Private_1_0 { */ void (*PostMessageToJavaScript)(PP_Instance instance, const char* message); /* Downloads the .nexe file at the given URL to a file, and sets |handle| - * to a handle to a file containing its contents. */ + * to a handle to a file containing its contents. + * If metadata for identity-based validation caching is available + * then it sets file_token_lo and file_token_lo (otherwise left untouched). + */ void (*DownloadNexe)(PP_Instance instance, const char* url, PP_FileHandle* handle, + uint64_t* file_token_lo, + uint64_t* file_token_hi, struct PP_CompletionCallback callback); }; diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index f88c754..d53e6e2 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -23,6 +23,7 @@ #include "native_client/src/include/portability.h" #include "native_client/src/include/portability_io.h" #include "native_client/src/include/portability_string.h" +#include "native_client/src/public/nacl_file_info.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/nonnacl_util/sel_ldr_launcher.h" @@ -330,6 +331,8 @@ Plugin::Plugin(PP_Instance pp_instance) time_of_last_progress_event_(0), manifest_id_(-1), nexe_handle_(PP_kInvalidFileHandle), + nexe_token_lo_(0), + nexe_token_hi_(0), nacl_interface_(NULL), uma_interface_(this) { PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" @@ -411,11 +414,23 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) { if (pp_error != PP_OK) return; - int32_t desc = ConvertFileDescriptor(nexe_handle_, true); + NaClFileInfo nexe_file_info; + nexe_file_info.desc = ConvertFileDescriptor(nexe_handle_, true); + nexe_file_info.file_token.lo = nexe_token_lo_; + nexe_file_info.file_token.hi = nexe_token_hi_; nexe_handle_ = PP_kInvalidFileHandle; // Clear out nexe handle. + nexe_token_lo_ = 0; + nexe_token_hi_ = 0; + + NaClDesc *desc = NaClDescIoFromFileInfo(nexe_file_info, O_RDONLY); + if (desc == NULL) + return; + // nexe_file_info_ is handed to desc, clear out old copy. + memset(&nexe_file_info, 0, sizeof nexe_file_info); + nexe_file_info.desc = -1; nacl::scoped_ptr<nacl::DescWrapper> - wrapper(wrapper_factory()->MakeFileDesc(desc, O_RDONLY)); + wrapper(wrapper_factory()->MakeGenericCleanup(desc)); NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n"); LoadNaClModule( wrapper.release(), @@ -526,6 +541,8 @@ void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { nacl_interface_->DownloadNexe(pp_instance(), program_url_.c_str(), &nexe_handle_, + &nexe_token_lo_, + &nexe_token_hi_, open_callback.pp_completion_callback()); return; } diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h index 244c824..a2e0c02 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.h +++ b/ppapi/native_client/src/trusted/plugin/plugin.h @@ -297,6 +297,8 @@ class Plugin : public pp::Instance { int32_t manifest_id_; PP_FileHandle nexe_handle_; + uint64_t nexe_token_lo_; + uint64_t nexe_token_hi_; const PPB_NaCl_Private* nacl_interface_; pp::UMAPrivate uma_interface_; diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 911380b..0ac1cae 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -3402,9 +3402,9 @@ static void Pnacl_M25_PPB_NaCl_Private_PostMessageToJavaScript(PP_Instance insta iface->PostMessageToJavaScript(instance, message); } -static void Pnacl_M25_PPB_NaCl_Private_DownloadNexe(PP_Instance instance, const char* url, PP_FileHandle* handle, struct PP_CompletionCallback* callback) { +static void Pnacl_M25_PPB_NaCl_Private_DownloadNexe(PP_Instance instance, const char* url, PP_FileHandle* handle, uint64_t* file_token_lo, uint64_t* file_token_hi, struct PP_CompletionCallback* callback) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->DownloadNexe(instance, url, handle, *callback); + iface->DownloadNexe(instance, url, handle, file_token_lo, file_token_hi, *callback); } /* End wrapper methods for PPB_NaCl_Private_1_0 */ @@ -5167,7 +5167,7 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = { .GetPnaclResourceInfo = (PP_Bool (*)(PP_Instance instance, const char* filename, struct PP_Var* llc_tool_name, struct PP_Var* ld_tool_name))&Pnacl_M25_PPB_NaCl_Private_GetPnaclResourceInfo, .GetCpuFeatureAttrs = (struct PP_Var (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetCpuFeatureAttrs, .PostMessageToJavaScript = (void (*)(PP_Instance instance, const char* message))&Pnacl_M25_PPB_NaCl_Private_PostMessageToJavaScript, - .DownloadNexe = (void (*)(PP_Instance instance, const char* url, PP_FileHandle* handle, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_DownloadNexe + .DownloadNexe = (void (*)(PP_Instance instance, const char* url, PP_FileHandle* handle, uint64_t* file_token_lo, uint64_t* file_token_hi, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_DownloadNexe }; static const struct PPB_NetAddress_Private_0_1 Pnacl_Wrappers_PPB_NetAddress_Private_0_1 = { |