OLD | NEW |
(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 |
OLD | NEW |