Index: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
index 831ba865ce4d14f592b626f9d3fdb9b3fc07d9a0..72e188a5ac31ec71aab93228888378e3bb1dcfe8 100644 |
--- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
@@ -195,9 +195,9 @@ PnaclCoordinator::~PnaclCoordinator() { |
} |
} |
-nacl::DescWrapper* PnaclCoordinator::ReleaseTranslatedFD() { |
+PP_FileHandle PnaclCoordinator::TakeTranslatedFileHandle() { |
DCHECK(temp_nexe_file_ != NULL); |
- return temp_nexe_file_->release_read_wrapper(); |
+ return temp_nexe_file_->TakeFileHandle(); |
} |
void PnaclCoordinator::ReportNonPpapiError(PP_NaClError err_code, |
@@ -426,7 +426,7 @@ void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) { |
headers.c_str(), |
architecture_attributes_.c_str(), // Extra compile flags. |
&is_cache_hit_, |
- temp_nexe_file_->existing_handle(), |
+ temp_nexe_file_->internal_handle(), |
cb.pp_completion_callback()); |
if (nexe_fd_err < PP_OK_COMPLETIONPENDING) { |
ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, nexe_fd_err, |
@@ -436,16 +436,15 @@ void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) { |
void PnaclCoordinator::NexeFdDidOpen(int32_t pp_error) { |
PLUGIN_PRINTF(("PnaclCoordinator::NexeFdDidOpen (pp_error=%" |
- NACL_PRId32 ", hit=%d, handle=%d)\n", pp_error, |
- is_cache_hit_ == PP_TRUE, |
- *temp_nexe_file_->existing_handle())); |
+ NACL_PRId32 ", hit=%d)\n", pp_error, |
+ is_cache_hit_ == PP_TRUE)); |
if (pp_error < PP_OK) { |
ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, pp_error, |
nacl::string("GetNexeFd failed")); |
return; |
} |
- if (*temp_nexe_file_->existing_handle() == PP_kInvalidFileHandle) { |
+ if (*temp_nexe_file_->internal_handle() == PP_kInvalidFileHandle) { |
ReportNonPpapiError( |
PP_NACL_ERROR_PNACL_CREATE_TEMP, |
nacl::string( |
@@ -458,18 +457,20 @@ void PnaclCoordinator::NexeFdDidOpen(int32_t pp_error) { |
// Cache hit -- no need to stream the rest of the file. |
streaming_downloader_.reset(NULL); |
// Open it for reading as the cached nexe file. |
- pp::CompletionCallback cb = |
- callback_factory_.NewCallback(&PnaclCoordinator::NexeReadDidOpen); |
- temp_nexe_file_->Open(cb, false); |
+ NexeReadDidOpen(temp_nexe_file_->Open(false)); |
} else { |
// Open an object file first so the translator can start writing to it |
// during streaming translation. |
for (int i = 0; i < split_module_count_; i++) { |
obj_files_.push_back(new TempFile(plugin_)); |
- |
- pp::CompletionCallback obj_cb = |
- callback_factory_.NewCallback(&PnaclCoordinator::ObjectFileDidOpen); |
- obj_files_[i]->Open(obj_cb, true); |
+ int32_t pp_error = obj_files_[i]->Open(true); |
+ if (pp_error != PP_OK) { |
+ ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, |
+ pp_error, |
+ "Failed to open scratch object file."); |
+ } else { |
+ num_object_files_opened_++; |
+ } |
} |
invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); |
@@ -480,6 +481,12 @@ void PnaclCoordinator::NexeFdDidOpen(int32_t pp_error) { |
pp::CompletionCallback finish_cb = callback_factory_.NewCallback( |
&PnaclCoordinator::BitcodeStreamDidFinish); |
streaming_downloader_->FinishStreaming(finish_cb); |
+ |
+ if (num_object_files_opened_ == split_module_count_) { |
+ // Open the nexe file for connecting ld and sel_ldr. |
+ // Start translation when done with this last step of setup! |
+ RunTranslate(temp_nexe_file_->Open(true)); |
+ } |
} |
} |
@@ -586,25 +593,6 @@ void PnaclCoordinator::GetCurrentProgress(int64_t* bytes_loaded, |
*bytes_total = expected_pexe_size_; |
} |
-void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) { |
- PLUGIN_PRINTF(("PnaclCoordinator::ObjectFileDidOpen (pp_error=%" |
- NACL_PRId32 ")\n", pp_error)); |
- if (pp_error != PP_OK) { |
- ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, |
- pp_error, |
- "Failed to open scratch object file."); |
- return; |
- } |
- num_object_files_opened_++; |
- if (num_object_files_opened_ == split_module_count_) { |
- // Open the nexe file for connecting ld and sel_ldr. |
- // Start translation when done with this last step of setup! |
- pp::CompletionCallback cb = |
- callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate); |
- temp_nexe_file_->Open(cb, true); |
- } |
-} |
- |
void PnaclCoordinator::RunTranslate(int32_t pp_error) { |
PLUGIN_PRINTF(("PnaclCoordinator::RunTranslate (pp_error=%" |
NACL_PRId32 ")\n", pp_error)); |