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 27c75c7400dda53d1ca3a704f00b60191cd4cb0f..3417b92989ad6e8b837d62b63cedbdf6fe8c91d7 100644 |
--- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
@@ -199,9 +199,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, |
@@ -440,9 +440,8 @@ 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")); |
@@ -462,18 +461,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()); |
@@ -484,6 +485,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)); |
+ } |
} |
} |
@@ -590,25 +597,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)); |