summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-22 21:06:11 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-22 21:06:11 +0000
commit5cf25409780d50c9aa2f3c3f6071c4cafd08513b (patch)
tree7858ab97992c53c7750568af77b80a4778ba003c /ppapi
parent711e9080edb08dae0bb79e68b14c697e73b740dd (diff)
downloadchromium_src-5cf25409780d50c9aa2f3c3f6071c4cafd08513b.zip
chromium_src-5cf25409780d50c9aa2f3c3f6071c4cafd08513b.tar.gz
chromium_src-5cf25409780d50c9aa2f3c3f6071c4cafd08513b.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc14
-rw-r--r--ppapi/native_client/src/trusted/plugin/temporary_file.cc12
-rw-r--r--ppapi/native_client/src/trusted/plugin/temporary_file.h6
3 files changed, 10 insertions, 22 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
index 6ce3646..537ac06 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
@@ -338,8 +338,7 @@ void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) {
BitcodeStreamDidFinish(PP_ERROR_FAILED);
return;
}
- *temp_nexe_file_->internal_handle() = handle;
- // Open it for reading as the cached nexe file.
+ temp_nexe_file_.reset(new TempFile(plugin_, handle));
NexeReadDidOpen(temp_nexe_file_->Open(false));
}
@@ -347,12 +346,10 @@ 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++) {
- nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_));
+ PP_FileHandle obj_handle =
+ plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance());
+ nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_, obj_handle));
int32_t pp_error = temp_file->Open(true);
if (pp_error != PP_OK) {
ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP,
@@ -367,6 +364,9 @@ 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 eee655f..db02335 100644
--- a/ppapi/native_client/src/trusted/plugin/temporary_file.cc
+++ b/ppapi/native_client/src/trusted/plugin/temporary_file.cc
@@ -18,20 +18,12 @@
namespace plugin {
-TempFile::TempFile(Plugin* plugin) : plugin_(plugin),
- internal_handle_(PP_kInvalidFileHandle) {
-}
+TempFile::TempFile(Plugin* plugin, PP_FileHandle handle)
+ : plugin_(plugin), internal_handle_(handle) { }
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 4bc8f71..e492668 100644
--- a/ppapi/native_client/src/trusted/plugin/temporary_file.h
+++ b/ppapi/native_client/src/trusted/plugin/temporary_file.h
@@ -35,8 +35,7 @@ class Plugin;
// of the file between sessions.
class TempFile {
public:
- // Create a TempFile.
- explicit TempFile(Plugin* plugin);
+ TempFile(Plugin* plugin, PP_FileHandle handle);
~TempFile();
// Opens a temporary file object and descriptor wrapper referring to the file.
@@ -55,9 +54,6 @@ 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);