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

Unified Diff: mojo/edk/embedder/named_platform_handle_utils_posix.cc

Issue 2282413004: Support creating mojo peer connections from named pipes. (Closed)
Patch Set: Created 4 years, 4 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: 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

Powered by Google App Engine
This is Rietveld 408576698