Chromium Code Reviews| Index: chrome/renderer/pepper/ppb_nacl_private_impl.cc |
| diff --git a/chrome/renderer/pepper/ppb_nacl_private_impl.cc b/chrome/renderer/pepper/ppb_nacl_private_impl.cc |
| index f094f6590b35116d436f5cd93b1933ebca428136..ddfbe34c07a81dca77d4a1b6ab46475a251c918d 100644 |
| --- a/chrome/renderer/pepper/ppb_nacl_private_impl.cc |
| +++ b/chrome/renderer/pepper/ppb_nacl_private_impl.cc |
| @@ -6,11 +6,6 @@ |
| #ifndef DISABLE_NACL |
| -#if defined(OS_WIN) |
| -#include <fcntl.h> |
| -#include <io.h> |
| -#endif |
| - |
| #include "base/command_line.h" |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| @@ -24,6 +19,7 @@ |
| #include "content/public/renderer/render_thread.h" |
| #include "content/public/renderer/render_view.h" |
| #include "ipc/ipc_sync_message_filter.h" |
| +#include "ppapi/c/private/pp_file_handle.h" |
| #include "ppapi/c/private/ppb_nacl_private.h" |
| #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" |
| #include "ppapi/proxy/host_dispatcher.h" |
| @@ -38,6 +34,7 @@ |
| #include "webkit/plugins/ppapi/plugin_module.h" |
| #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
|
brettw
2012/07/27 22:38:17
Got an extra blank in here.
jvoung - send to chromium...
2012/07/28 01:30:05
Done.
|
| + |
| using content::RenderThread; |
| using content::RenderView; |
| using webkit::ppapi::HostGlobals; |
| @@ -265,7 +262,7 @@ int BrokerDuplicateHandle(void* source_handle, |
| #endif |
| } |
| -int GetReadonlyPnaclFD(const char* filename) { |
| +PP_FileHandle GetReadonlyPnaclFD(const char* filename) { |
| IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); |
| IPC::Sender* sender = content::RenderThread::Get(); |
| if (sender == NULL) |
| @@ -274,29 +271,36 @@ int GetReadonlyPnaclFD(const char* filename) { |
| if (!sender->Send(new ChromeViewHostMsg_GetReadonlyPnaclFD( |
| std::string(filename), |
| &out_fd))) { |
| - return -1; |
| + return base::kInvalidPlatformFileValue; |
| } |
| if (out_fd == IPC::InvalidPlatformFileForTransit()) { |
| - return -1; |
| + return base::kInvalidPlatformFileValue; |
| } |
| base::PlatformFile handle = |
| IPC::PlatformFileForTransitToPlatformFile(out_fd); |
| -#if defined(OS_WIN) |
| - int posix_desc = _open_osfhandle(reinterpret_cast<intptr_t>(handle), |
| - _O_RDONLY | _O_BINARY); |
| - if (posix_desc == -1) { |
| - // Close the Windows HANDLE if it can't be converted. |
| - CloseHandle(handle); |
| - return -1; |
| + return handle; |
| +} |
| + |
| +PP_FileHandle CreateTemporaryFile(PP_Instance instance) { |
| + IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); |
| + IPC::Sender* sender = content::RenderThread::Get(); |
| + if (sender == NULL) |
| + sender = g_background_thread_sender.Pointer()->get(); |
| + |
| + if (!sender->Send(new ChromeViewHostMsg_NaClCreateTemporaryFile( |
| + &transit_fd))) { |
| + return base::kInvalidPlatformFileValue; |
| + } |
| + |
| + if (transit_fd == IPC::InvalidPlatformFileForTransit()) { |
| + return base::kInvalidPlatformFileValue; |
| } |
| - return posix_desc; |
| -#elif defined(OS_POSIX) |
| + |
| + base::PlatformFile handle = IPC::PlatformFileForTransitToPlatformFile( |
| + transit_fd); |
| return handle; |
| -#else |
| -#error "GetReadonlyPnaclFD: Don't know how to convert FileDescriptor to native." |
| -#endif |
| } |
| const PPB_NaCl_Private nacl_interface = { |
| @@ -306,7 +310,8 @@ const PPB_NaCl_Private nacl_interface = { |
| &Are3DInterfacesDisabled, |
| &EnableBackgroundSelLdrLaunch, |
| &BrokerDuplicateHandle, |
| - &GetReadonlyPnaclFD |
| + &GetReadonlyPnaclFD, |
| + &CreateTemporaryFile |
| }; |
| } // namespace |