OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/edk/embedder/named_platform_handle_utils.h" | 5 #include "mojo/edk/embedder/named_platform_handle_utils.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 #include <sys/un.h> | 9 #include <sys/un.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (HANDLE_EINTR(connect(handle.get().handle, | 92 if (HANDLE_EINTR(connect(handle.get().handle, |
93 reinterpret_cast<sockaddr*>(&unix_addr), | 93 reinterpret_cast<sockaddr*>(&unix_addr), |
94 unix_addr_len)) < 0) { | 94 unix_addr_len)) < 0) { |
95 PLOG(ERROR) << "connect " << named_handle.name; | 95 PLOG(ERROR) << "connect " << named_handle.name; |
96 return ScopedPlatformHandle(); | 96 return ScopedPlatformHandle(); |
97 } | 97 } |
98 | 98 |
99 return handle; | 99 return handle; |
100 } | 100 } |
101 | 101 |
102 ScopedPlatformHandle CreateServerHandle(const NamedPlatformHandle& named_handle, | 102 ScopedPlatformHandle CreateServerHandle( |
103 bool enforce_uniqueness) { | 103 const NamedPlatformHandle& named_handle, |
104 CHECK(!enforce_uniqueness); | 104 const CreateServerHandleOptions& options) { |
105 if (!named_handle.is_valid()) | 105 if (!named_handle.is_valid()) |
106 return ScopedPlatformHandle(); | 106 return ScopedPlatformHandle(); |
107 | 107 |
108 // Make sure the path we need exists. | 108 // Make sure the path we need exists. |
109 base::FilePath socket_dir = base::FilePath(named_handle.name).DirName(); | 109 base::FilePath socket_dir = base::FilePath(named_handle.name).DirName(); |
110 if (!base::CreateDirectory(socket_dir)) { | 110 if (!base::CreateDirectory(socket_dir)) { |
111 LOG(ERROR) << "Couldn't create directory: " << socket_dir.value(); | 111 LOG(ERROR) << "Couldn't create directory: " << socket_dir.value(); |
112 return ScopedPlatformHandle(); | 112 return ScopedPlatformHandle(); |
113 } | 113 } |
114 | 114 |
(...skipping 23 matching lines...) Expand all Loading... |
138 if (listen(handle.get().handle, SOMAXCONN) < 0) { | 138 if (listen(handle.get().handle, SOMAXCONN) < 0) { |
139 PLOG(ERROR) << "listen " << named_handle.name; | 139 PLOG(ERROR) << "listen " << named_handle.name; |
140 unlink(named_handle.name.c_str()); | 140 unlink(named_handle.name.c_str()); |
141 return ScopedPlatformHandle(); | 141 return ScopedPlatformHandle(); |
142 } | 142 } |
143 return handle; | 143 return handle; |
144 } | 144 } |
145 | 145 |
146 } // namespace edk | 146 } // namespace edk |
147 } // namespace mojo | 147 } // namespace mojo |
OLD | NEW |