Index: ppapi/native_client/src/trusted/plugin/temporary_file.cc |
diff --git a/ppapi/native_client/src/trusted/plugin/temporary_file.cc b/ppapi/native_client/src/trusted/plugin/temporary_file.cc |
index 4b19e8f9208244e438a88fe35157f494b584d3d4..74ec74cce07e3ebd9a6b81bc1c9cc1a80364b657 100644 |
--- a/ppapi/native_client/src/trusted/plugin/temporary_file.cc |
+++ b/ppapi/native_client/src/trusted/plugin/temporary_file.cc |
@@ -20,15 +20,13 @@ namespace plugin { |
TempFile::TempFile(Plugin* plugin) : plugin_(plugin), |
existing_handle_(PP_kInvalidFileHandle) { |
- PLUGIN_PRINTF(("TempFile::TempFile\n")); |
} |
-TempFile::~TempFile() { |
- PLUGIN_PRINTF(("TempFile::~TempFile\n")); |
-} |
+TempFile::~TempFile() { } |
-void TempFile::Open(const pp::CompletionCallback& cb, bool writeable) { |
- PLUGIN_PRINTF(("TempFile::Open\n")); |
+int32_t TempFile::Open(bool writeable) { |
+ // TODO(teravest): Clean up this Open() behavior; this is really confusing as |
+ // written. |
PP_FileHandle file_handle; |
if (existing_handle_ == PP_kInvalidFileHandle) { |
file_handle = |
@@ -37,10 +35,9 @@ void TempFile::Open(const pp::CompletionCallback& cb, bool writeable) { |
file_handle = existing_handle_; |
} |
- pp::Core* core = pp::Module::Get()->core(); |
if (file_handle == PP_kInvalidFileHandle) { |
PLUGIN_PRINTF(("TempFile::Open failed w/ PP_kInvalidFileHandle\n")); |
- core->CallOnMainThread(0, cb, PP_ERROR_FAILED); |
+ return PP_ERROR_FAILED; |
} |
#if NACL_WINDOWS |
@@ -63,16 +60,14 @@ void TempFile::Open(const pp::CompletionCallback& cb, bool writeable) { |
if (fd < 0) { |
PLUGIN_PRINTF(("TempFile::Open failed\n")); |
- core->CallOnMainThread(0, cb, PP_ERROR_FAILED); |
- return; |
+ return PP_ERROR_FAILED; |
} |
// dup the fd to make allow making separate read and write wrappers. |
int32_t read_fd = DUP(fd); |
if (read_fd == NACL_NO_FILE_DESC) { |
PLUGIN_PRINTF(("TempFile::Open DUP failed\n")); |
- core->CallOnMainThread(0, cb, PP_ERROR_FAILED); |
- return; |
+ return PP_ERROR_FAILED; |
} |
if (writeable) { |
@@ -82,7 +77,7 @@ void TempFile::Open(const pp::CompletionCallback& cb, bool writeable) { |
read_wrapper_.reset( |
plugin_->wrapper_factory()->MakeFileDesc(read_fd, O_RDONLY)); |
- core->CallOnMainThread(0, cb, PP_OK); |
+ return PP_OK; |
} |
bool TempFile::Reset() { |
@@ -94,4 +89,13 @@ bool TempFile::Reset() { |
return newpos == 0; |
} |
+PP_FileHandle TempFile::TakeFileHandle() { |
+ PP_FileHandle to_return = existing_handle_; |
+ existing_handle_ = PP_kInvalidFileHandle; |
+ // TODO(teravest): Figure out why we can't reset read_wrapper_ and |
jvoung (off chromium)
2014/05/23 17:53:04
=/ not sure why either...
|
+ // write_wrapper_ here; it seems like when this is called, we shouldn't need |
+ // those DescWrappers to be valid anymore. |
+ return to_return; |
+} |
+ |
} // namespace plugin |