diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-22 23:08:18 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-22 23:08:18 +0000 |
commit | bdb0e21c3e8eae56068895c859d887a9a3542468 (patch) | |
tree | 30675abb19927abe03fb37e6d2e8ea74cf46c0c3 /ppapi/native_client | |
parent | 3852decc13f121935e0b5f4eca4e2c9680c63749 (diff) | |
download | chromium_src-bdb0e21c3e8eae56068895c859d887a9a3542468.zip chromium_src-bdb0e21c3e8eae56068895c859d887a9a3542468.tar.gz chromium_src-bdb0e21c3e8eae56068895c859d887a9a3542468.tar.bz2 |
Revert 284766 "Pepper: Simplify TempFile in trusted plugin."
Sorry I had to revert this. It's not because it caused problems, but
rather I needed to revert r284684 as it caused problems and your patch
touches the same files.
> Pepper: Simplify TempFile in trusted plugin.
>
> This change makes the behavior of internal_handle_ in TempFile easier to reason
> about. This change is possible after a large refactoring of PnaclCoordinator
> that happened as a result of removing FileDownloader.
>
> BUG=239656
> R=bbudge@chromium.org
>
> Review URL: https://codereview.chromium.org/413493002
TBR=teravest@chromium.org
Review URL: https://codereview.chromium.org/406383002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
3 files changed, 22 insertions, 10 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc index 537ac06..6ce3646 100644 --- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc +++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc @@ -338,7 +338,8 @@ void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) { BitcodeStreamDidFinish(PP_ERROR_FAILED); return; } - temp_nexe_file_.reset(new TempFile(plugin_, handle)); + *temp_nexe_file_->internal_handle() = handle; + // Open it for reading as the cached nexe file. NexeReadDidOpen(temp_nexe_file_->Open(false)); } @@ -346,10 +347,12 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) { HistogramEnumerateTranslationCache(plugin_->uma_interface(), false); expected_pexe_size_ = expected_pexe_size; + // Open an object file first so the translator can start writing to it + // during streaming translation. + temp_nexe_file_.reset(new TempFile(plugin_)); + for (int i = 0; i < split_module_count_; i++) { - PP_FileHandle obj_handle = - plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); - nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle)); + nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_)); int32_t pp_error = temp_file->Open(true); if (pp_error != PP_OK) { ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, @@ -364,9 +367,6 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) { // Open the nexe file for connecting ld and sel_ldr. // Start translation when done with this last step of setup! - PP_FileHandle nexe_handle = - plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); - temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle)); RunTranslate(temp_nexe_file_->Open(true)); } diff --git a/ppapi/native_client/src/trusted/plugin/temporary_file.cc b/ppapi/native_client/src/trusted/plugin/temporary_file.cc index db02335..eee655f 100644 --- a/ppapi/native_client/src/trusted/plugin/temporary_file.cc +++ b/ppapi/native_client/src/trusted/plugin/temporary_file.cc @@ -18,12 +18,20 @@ namespace plugin { -TempFile::TempFile(Plugin* plugin, PP_FileHandle handle) - : plugin_(plugin), internal_handle_(handle) { } +TempFile::TempFile(Plugin* plugin) : plugin_(plugin), + internal_handle_(PP_kInvalidFileHandle) { +} TempFile::~TempFile() { } int32_t TempFile::Open(bool writeable) { + // TODO(teravest): Clean up this Open() behavior; this is really confusing as + // written. + if (internal_handle_ == PP_kInvalidFileHandle) { + internal_handle_ = + plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance()); + } + if (internal_handle_ == PP_kInvalidFileHandle) { PLUGIN_PRINTF(("TempFile::Open failed w/ PP_kInvalidFileHandle\n")); return PP_ERROR_FAILED; diff --git a/ppapi/native_client/src/trusted/plugin/temporary_file.h b/ppapi/native_client/src/trusted/plugin/temporary_file.h index e492668..4bc8f71 100644 --- a/ppapi/native_client/src/trusted/plugin/temporary_file.h +++ b/ppapi/native_client/src/trusted/plugin/temporary_file.h @@ -35,7 +35,8 @@ class Plugin; // of the file between sessions. class TempFile { public: - TempFile(Plugin* plugin, PP_FileHandle handle); + // Create a TempFile. + explicit TempFile(Plugin* plugin); ~TempFile(); // Opens a temporary file object and descriptor wrapper referring to the file. @@ -54,6 +55,9 @@ class TempFile { // and all wrappers. PP_FileHandle TakeFileHandle(); + // Used by GetNexeFd() to set the underlying internal handle. + PP_FileHandle* internal_handle() { return &internal_handle_; } + private: NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); |