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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "mojo/edk/embedder/named_platform_handle_utils.h"
6
7 #include "base/files/file_path.h"
8 #include "ipc/unix_domain_socket_util.h"
9 #include "mojo/edk/embedder/named_platform_handle.h"
10
11 namespace mojo {
12 namespace edk {
13
14 ScopedPlatformHandle CreateClientHandle(
15 const NamedPlatformHandle& named_handle) {
16 if (!named_handle.is_valid())
17 return ScopedPlatformHandle();
18
19 int fd;
20 IPC::CreateClientUnixDomainSocket(base::FilePath(named_handle.name), &fd);
21 return ScopedPlatformHandle(PlatformHandle(fd));
22 }
23
24 ScopedPlatformHandle CreateServerHandle(const NamedPlatformHandle& named_handle,
25 bool enforce_uniqueness) {
26 CHECK(!enforce_uniqueness);
27 if (!named_handle.is_valid())
28 return ScopedPlatformHandle();
29
30 int fd;
31 IPC::CreateServerUnixDomainSocket(base::FilePath(named_handle.name), &fd);
32 PlatformHandle handle(fd);
33 handle.needs_connection = true;
34 return ScopedPlatformHandle(handle);
35 }
36
37 } // namespace edk
38 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698