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

Unified Diff: content/common/gpu/client/gpu_channel_host.cc

Issue 1152273005: Prepare gpu_channel_host for SharedMemoryHandles not backed by POSIX fds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_make_class3_base
Patch Set: Undo change to Windows behavior. Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/client/gpu_channel_host.cc
diff --git a/content/common/gpu/client/gpu_channel_host.cc b/content/common/gpu/client/gpu_channel_host.cc
index b4460bbb56e3d1e999349bca9e972f756bc3612b..60c5bbe40b3cb16ce4904017d2a7dae1996c650c 100644
--- a/content/common/gpu/client/gpu_channel_host.cc
+++ b/content/common/gpu/client/gpu_channel_host.cc
@@ -18,7 +18,7 @@
#include "ipc/ipc_sync_message_filter.h"
#include "url/gurl.h"
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_MACOSX)
#include "content/public/common/sandbox_init.h"
#endif
@@ -303,8 +303,9 @@ base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess(
if (IsLost())
return base::SharedMemory::NULLHandle();
-#if defined(OS_WIN)
- // Windows needs to explicitly duplicate the handle out to another process.
+#if defined(OS_WIN) || defined(OS_MACOSX)
+ // Windows and Mac need to explicitly duplicate the handle out to another
+ // process.
base::SharedMemoryHandle target_handle;
base::ProcessId peer_pid;
{
@@ -313,22 +314,21 @@ base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess(
return base::SharedMemory::NULLHandle();
peer_pid = channel_->GetPeerPID();
}
- if (!BrokerDuplicateHandle(source_handle,
- peer_pid,
- &target_handle,
- FILE_GENERIC_READ | FILE_GENERIC_WRITE,
- 0)) {
+#if defined(OS_WIN)
+ bool success =
+ BrokerDuplicateHandle(source_handle, peer_pid, &target_handle,
+ FILE_GENERIC_READ | FILE_GENERIC_WRITE, 0);
+#elif defined(OS_MACOSX)
+ bool success = BrokerDuplicateSharedMemoryHandle(source_handle, peer_pid,
+ &target_handle);
+#endif
+ if (!success)
return base::SharedMemory::NULLHandle();
- }
return target_handle;
#else
- int duped_handle = HANDLE_EINTR(dup(source_handle.fd));
- if (duped_handle < 0)
- return base::SharedMemory::NULLHandle();
-
- return base::FileDescriptor(duped_handle, true);
-#endif
+ return base::SharedMemory::DuplicateHandle(source_handle);
+#endif // defined(OS_WIN) || defined(OS_MACOSX)
}
int32 GpuChannelHost::ReserveTransferBufferId() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698