diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 03:54:54 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 03:54:54 +0000 |
commit | db0f57f52949c468843c1c60edfff0955a63712c (patch) | |
tree | da4b266e8213d697963a91838592b540eb549aa4 /ppapi/proxy/ppb_context_3d_proxy.cc | |
parent | 17d36074c141f63997b56317bca04d207efbed3e (diff) | |
download | chromium_src-db0f57f52949c468843c1c60edfff0955a63712c.zip chromium_src-db0f57f52949c468843c1c60edfff0955a63712c.tar.gz chromium_src-db0f57f52949c468843c1c60edfff0955a63712c.tar.bz2 |
Factor fd sharing code in proxy and fix fd issues once and for all.
BUG=none
TEST=use flapper, go to youtube, make plugin crash and check no warning about close() failing.
Review URL: http://codereview.chromium.org/6580050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppb_context_3d_proxy.cc')
-rw-r--r-- | ppapi/proxy/ppb_context_3d_proxy.cc | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/ppapi/proxy/ppb_context_3d_proxy.cc b/ppapi/proxy/ppb_context_3d_proxy.cc index d36ed2a..55df27b 100644 --- a/ppapi/proxy/ppb_context_3d_proxy.cc +++ b/ppapi/proxy/ppb_context_3d_proxy.cc @@ -131,17 +131,20 @@ const PPB_Context3D_Dev context_3d_interface = { &GetBoundSurfaces, }; -base::SharedMemoryHandle SHMHandleFromInt(int shm_handle) { -#if defined(OS_POSIX) - // The handle isn't ours to close, but we want to keep a reference to the - // handle until it is actually sent, so duplicate it, and mark auto-close. - return base::FileDescriptor(dup(shm_handle), true); -#elif defined(OS_WIN) - // TODO(piman): DuplicateHandle to the plugin process. - return reinterpret_cast<HANDLE>(shm_handle); +base::SharedMemoryHandle TransportSHMHandleFromInt(Dispatcher* dispatcher, + int shm_handle) { + // TODO(piman): Change trusted interface to return a PP_FileHandle, those + // casts are ugly. + base::PlatformFile source = +#if defined(OS_WIN) + reinterpret_cast<HANDLE>(static_cast<intptr_t>(shm_handle)); +#elif defined(OS_POSIX) + shm_handle; #else -#error "Platform not supported." + #error Not implemented. #endif + // Don't close the handle, it doesn't belong to us. + return dispatcher->ShareHandleWithRemote(source, false); } gpu::CommandBuffer::State GPUStateFromPPState( @@ -547,7 +550,7 @@ void PPB_Context3D_Proxy::OnMsgInitialize( return; } - *ring_buffer = SHMHandleFromInt(shm_handle); + *ring_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); } void PPB_Context3D_Proxy::OnMsgGetState(const HostResource& context, @@ -598,7 +601,7 @@ void PPB_Context3D_Proxy::OnMsgGetTransferBuffer( &shm_size)) { return; } - *transfer_buffer = SHMHandleFromInt(shm_handle); + *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); *size = shm_size; } |