Index: mojo/edk/embedder/named_platform_handle_utils_posix.cc |
diff --git a/mojo/edk/embedder/named_platform_handle_utils_posix.cc b/mojo/edk/embedder/named_platform_handle_utils_posix.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..62aa4d0e08b607f21eaa741723ce8612070e1c54 |
--- /dev/null |
+++ b/mojo/edk/embedder/named_platform_handle_utils_posix.cc |
@@ -0,0 +1,38 @@ |
+// Copyright 2016 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 "mojo/edk/embedder/named_platform_handle_utils.h" |
+ |
+#include "base/files/file_path.h" |
+#include "ipc/unix_domain_socket_util.h" |
+#include "mojo/edk/embedder/named_platform_handle.h" |
+ |
+namespace mojo { |
+namespace edk { |
+ |
+ScopedPlatformHandle CreateClientHandle( |
+ const NamedPlatformHandle& named_handle) { |
+ if (!named_handle.is_valid()) |
+ return ScopedPlatformHandle(); |
+ |
+ int fd; |
+ IPC::CreateClientUnixDomainSocket(base::FilePath(named_handle.name), &fd); |
+ return ScopedPlatformHandle(PlatformHandle(fd)); |
+} |
+ |
+ScopedPlatformHandle CreateServerHandle(const NamedPlatformHandle& named_handle, |
+ bool enforce_uniqueness) { |
+ CHECK(!enforce_uniqueness); |
+ if (!named_handle.is_valid()) |
+ return ScopedPlatformHandle(); |
+ |
+ int fd; |
+ IPC::CreateServerUnixDomainSocket(base::FilePath(named_handle.name), &fd); |
+ PlatformHandle handle(fd); |
+ handle.needs_connection = true; |
+ return ScopedPlatformHandle(handle); |
+} |
+ |
+} // namespace edk |
+} // namespace mojo |