Chromium Code Reviews| Index: ppapi/native_client/src/trusted/plugin/plugin.cc |
| diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc |
| index b516879d6f5d8a2914f175d9fc1807067b87cec5..3c316feb6284a8de827725b8b6f389004725bce9 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" |
| @@ -375,6 +376,8 @@ Plugin::Plugin(PP_Instance pp_instance) |
| // We call set_exit_status() here to ensure that the 'exitStatus' property is |
| // set. This can only be called when nacl_interface_ is not NULL. |
| set_exit_status(-1); |
| + memset(&nexe_file_info_, 0, sizeof nexe_file_info_); |
| + nexe_file_info_.desc = -1; |
| } |
| @@ -446,11 +449,17 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) { |
| if (pp_error != PP_OK) |
| return; |
| - int32_t desc = ConvertFileDescriptor(nexe_handle_); |
| + nexe_file_info_.desc = ConvertFileDescriptor(nexe_handle_); |
|
teravest
2014/05/21 16:49:42
I'm a little confused why nexe_file_info_ needs to
jvoung (off chromium)
2014/05/21 21:10:56
It was mostly to avoid heap allocating the NaClFil
|
| nexe_handle_ = PP_kInvalidFileHandle; // Clear out nexe handle. |
| + 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(), |
| @@ -574,6 +583,8 @@ void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { |
| nacl_interface_->DownloadNexe(pp_instance(), |
| program_url_.c_str(), |
| &nexe_handle_, |
| + &nexe_file_info_.file_token.lo, |
| + &nexe_file_info_.file_token.hi, |
| open_callback.pp_completion_callback()); |
| return; |
| } |