Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: ppapi/proxy/ppb_context_3d_proxy.cc

Issue 6580050: Factor fd sharing code in proxy and fix fd issues once and for all. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/ppb_context_3d_proxy.cc
diff --git a/ppapi/proxy/ppb_context_3d_proxy.cc b/ppapi/proxy/ppb_context_3d_proxy.cc
index 076f13310493f7b9076dc9c2f203a4fe00ed9dd9..d096929942354572638a6de7c52144da18f0ca61 100644
--- a/ppapi/proxy/ppb_context_3d_proxy.cc
+++ b/ppapi/proxy/ppb_context_3d_proxy.cc
@@ -131,17 +131,19 @@ 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>(handle));
+#elif defined(OS_POSIX)
+ shm_handle;
#else
-#error "Platform not supported."
+ #error Not implemented.
#endif
+ return dispatcher->ShareHandleWithRemote(source, false);
}
gpu::CommandBuffer::State GPUStateFromPPState(
@@ -537,7 +539,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,
@@ -588,7 +590,7 @@ void PPB_Context3D_Proxy::OnMsgGetTransferBuffer(
&shm_size)) {
return;
}
- *transfer_buffer = SHMHandleFromInt(shm_handle);
+ *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle);
*size = shm_size;
}

Powered by Google App Engine
This is Rietveld 408576698