X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fppapi%2Fnative_client%2Fsrc%2Ftrusted%2Fplugin%2Ftemporary_file.cc;h=d84ce77303f13fe314a2756d8917a60d3951a243;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=eee655f40bec8de405af0e44c90f61088703dbfb;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/ppapi/native_client/src/trusted/plugin/temporary_file.cc b/src/ppapi/native_client/src/trusted/plugin/temporary_file.cc index eee655f..d84ce77 100644 --- a/src/ppapi/native_client/src/trusted/plugin/temporary_file.cc +++ b/src/ppapi/native_client/src/trusted/plugin/temporary_file.cc @@ -18,24 +18,15 @@ 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")); + if (internal_handle_ == PP_kInvalidFileHandle) return PP_ERROR_FAILED; - } #if NACL_WINDOWS HANDLE handle = internal_handle_; @@ -45,9 +36,10 @@ int32_t TempFile::Open(bool writeable) { int32_t posix_desc = _open_osfhandle(reinterpret_cast(handle), rdwr_flag | _O_BINARY | _O_TEMPORARY | _O_SHORT_LIVED ); + + // Close the Windows HANDLE if it can't be converted. if (posix_desc == -1) { PLUGIN_PRINTF(("TempFile::Open failed to convert HANDLE to posix\n")); - // Close the Windows HANDLE if it can't be converted. CloseHandle(handle); } int32_t fd = posix_desc; @@ -55,17 +47,13 @@ int32_t TempFile::Open(bool writeable) { int32_t fd = internal_handle_; #endif - if (fd < 0) { - PLUGIN_PRINTF(("TempFile::Open failed\n")); + if (fd < 0) 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")); + if (read_fd == NACL_NO_FILE_DESC) return PP_ERROR_FAILED; - } if (writeable) { write_wrapper_.reset( @@ -78,7 +66,6 @@ int32_t TempFile::Open(bool writeable) { } bool TempFile::Reset() { - PLUGIN_PRINTF(("TempFile::Reset\n")); // Use the read_wrapper_ to reset the file pos. The write_wrapper_ is also // backed by the same file, so it should also reset. CHECK(read_wrapper_.get() != NULL);