Index: ipc/ipc_platform_file.cc |
diff --git a/ipc/ipc_platform_file.cc b/ipc/ipc_platform_file.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ddc6e1734dfdd5befbaa4472fddde48966ea17d2 |
--- /dev/null |
+++ b/ipc/ipc_platform_file.cc |
@@ -0,0 +1,37 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ipc/ipc_platform_file.h" |
+ |
+namespace IPC { |
+ |
+PlatformFileForTransit GetFileHandleForProcess(base::PlatformFile handle, |
+ base::ProcessHandle process, |
+ bool close_source_handle) { |
+ IPC::PlatformFileForTransit out_handle; |
+#if defined(OS_WIN) |
+ DWORD options = DUPLICATE_SAME_ACCESS; |
+ if (close_source_handle) |
+ options |= DUPLICATE_CLOSE_SOURCE; |
+ if (!::DuplicateHandle(::GetCurrentProcess(), |
+ handle, |
+ process, |
+ &out_handle, |
+ 0, |
+ FALSE, |
+ options)) { |
+ out_handle = IPC::InvalidPlatformFileForTransit(); |
+ } |
+#elif defined(OS_POSIX) |
+ // If asked to close the source, we can simply re-use the source fd instead of |
+ // dup()ing and close()ing. |
brettw
2011/06/14 15:17:24
Can you add to this comment, I had to ask Antoine
|
+ int fd = close_source_handle ? handle : ::dup(handle); |
+ out_handle = base::FileDescriptor(fd, true); |
+#else |
+ #error Not implemented. |
+#endif |
+ return out_handle; |
+} |
+ |
+} // namespace IPC |