| Index: ppapi/native_client/src/trusted/plugin/file_downloader.cc
|
| diff --git a/ppapi/native_client/src/trusted/plugin/file_downloader.cc b/ppapi/native_client/src/trusted/plugin/file_downloader.cc
|
| index 9bfe0e97369ea402a1cec9eae4d8ed7a5bc71cdc..e453f13777cda35af1601afcab746d034a682ee2 100644
|
| --- a/ppapi/native_client/src/trusted/plugin/file_downloader.cc
|
| +++ b/ppapi/native_client/src/trusted/plugin/file_downloader.cc
|
| @@ -18,6 +18,7 @@
|
| #include "ppapi/cpp/url_request_info.h"
|
| #include "ppapi/cpp/url_response_info.h"
|
| #include "ppapi/native_client/src/trusted/plugin/callback_source.h"
|
| +#include "ppapi/native_client/src/trusted/plugin/file_utils.h"
|
| #include "ppapi/native_client/src/trusted/plugin/plugin.h"
|
| #include "ppapi/native_client/src/trusted/plugin/utility.h"
|
|
|
| @@ -33,26 +34,6 @@ struct NaClFileInfo NoFileInfo() {
|
| return info;
|
| }
|
|
|
| -// Converts a PP_FileHandle to a POSIX file descriptor.
|
| -int32_t ConvertFileDescriptor(PP_FileHandle handle) {
|
| - PLUGIN_PRINTF(("ConvertFileDescriptor, handle=%d\n", handle));
|
| -#if NACL_WINDOWS
|
| - int32_t file_desc = NACL_NO_FILE_DESC;
|
| - // On Windows, valid handles are 32 bit unsigned integers so this is safe.
|
| - file_desc = reinterpret_cast<uintptr_t>(handle);
|
| - // Convert the Windows HANDLE from Pepper to a POSIX file descriptor.
|
| - int32_t posix_desc = _open_osfhandle(file_desc, _O_RDWR | _O_BINARY);
|
| - if (posix_desc == -1) {
|
| - // Close the Windows HANDLE if it can't be converted.
|
| - CloseHandle(reinterpret_cast<HANDLE>(file_desc));
|
| - return -1;
|
| - }
|
| - return posix_desc;
|
| -#else
|
| - return handle;
|
| -#endif
|
| -}
|
| -
|
| } // namespace
|
|
|
| namespace plugin {
|
| @@ -217,7 +198,7 @@ void FileDownloader::OpenFast(const nacl::string& url,
|
| mode_ = DOWNLOAD_NONE;
|
| if (file_handle != PP_kInvalidFileHandle) {
|
| NaClFileInfo tmp_info = NoFileInfo();
|
| - tmp_info.desc = ConvertFileDescriptor(file_handle);
|
| + tmp_info.desc = file_utils::ConvertFileDescriptor(file_handle);
|
| tmp_info.file_token.lo = file_token_lo;
|
| tmp_info.file_token.hi = file_token_hi;
|
| file_info_.TakeOwnership(&tmp_info);
|
| @@ -469,7 +450,7 @@ void FileDownloader::GotFileHandleNotify(int32_t pp_error,
|
| pp_error));
|
| if (pp_error == PP_OK) {
|
| NaClFileInfo tmp_info = NoFileInfo();
|
| - tmp_info.desc = ConvertFileDescriptor(handle);
|
| + tmp_info.desc = file_utils::ConvertFileDescriptor(handle);
|
| file_info_.TakeOwnership(&tmp_info);
|
| }
|
|
|
|
|