Commit bdb0e21c authored by sky@chromium.org's avatar sky@chromium.org

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
parent 3852decc
...@@ -338,7 +338,8 @@ void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) { ...@@ -338,7 +338,8 @@ void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) {
BitcodeStreamDidFinish(PP_ERROR_FAILED); BitcodeStreamDidFinish(PP_ERROR_FAILED);
return; 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)); NexeReadDidOpen(temp_nexe_file_->Open(false));
} }
...@@ -346,10 +347,12 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) { ...@@ -346,10 +347,12 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) {
HistogramEnumerateTranslationCache(plugin_->uma_interface(), false); HistogramEnumerateTranslationCache(plugin_->uma_interface(), false);
expected_pexe_size_ = expected_pexe_size; 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++) { for (int i = 0; i < split_module_count_; i++) {
PP_FileHandle obj_handle = nacl::scoped_ptr<TempFile> temp_file(new TempFile(plugin_));
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); int32_t pp_error = temp_file->Open(true);
if (pp_error != PP_OK) { if (pp_error != PP_OK) {
ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP,
...@@ -364,9 +367,6 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) { ...@@ -364,9 +367,6 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) {
// Open the nexe file for connecting ld and sel_ldr. // Open the nexe file for connecting ld and sel_ldr.
// Start translation when done with this last step of setup! // 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)); RunTranslate(temp_nexe_file_->Open(true));
} }
......
...@@ -18,12 +18,20 @@ ...@@ -18,12 +18,20 @@
namespace plugin { namespace plugin {
TempFile::TempFile(Plugin* plugin, PP_FileHandle handle) TempFile::TempFile(Plugin* plugin) : plugin_(plugin),
: plugin_(plugin), internal_handle_(handle) { } internal_handle_(PP_kInvalidFileHandle) {
}
TempFile::~TempFile() { } TempFile::~TempFile() { }
int32_t TempFile::Open(bool writeable) { 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) { if (internal_handle_ == PP_kInvalidFileHandle) {
PLUGIN_PRINTF(("TempFile::Open failed w/ PP_kInvalidFileHandle\n")); PLUGIN_PRINTF(("TempFile::Open failed w/ PP_kInvalidFileHandle\n"));
return PP_ERROR_FAILED; return PP_ERROR_FAILED;
......
...@@ -35,7 +35,8 @@ class Plugin; ...@@ -35,7 +35,8 @@ class Plugin;
// of the file between sessions. // of the file between sessions.
class TempFile { class TempFile {
public: public:
TempFile(Plugin* plugin, PP_FileHandle handle); // Create a TempFile.
explicit TempFile(Plugin* plugin);
~TempFile(); ~TempFile();
// Opens a temporary file object and descriptor wrapper referring to the file. // Opens a temporary file object and descriptor wrapper referring to the file.
...@@ -54,6 +55,9 @@ class TempFile { ...@@ -54,6 +55,9 @@ class TempFile {
// and all wrappers. // and all wrappers.
PP_FileHandle TakeFileHandle(); PP_FileHandle TakeFileHandle();
// Used by GetNexeFd() to set the underlying internal handle.
PP_FileHandle* internal_handle() { return &internal_handle_; }
private: private:
NACL_DISALLOW_COPY_AND_ASSIGN(TempFile); NACL_DISALLOW_COPY_AND_ASSIGN(TempFile);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment