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

Side by Side Diff: mojo/edk/embedder/named_platform_handle_utils_posix.cc

Issue 2500263004: Remove ipc/unix_domain_socket_util.* (Closed)
Patch Set: rebase Created 4 years 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
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>
11 11
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/posix/eintr_wrapper.h" 15 #include "base/posix/eintr_wrapper.h"
16 #include "mojo/edk/embedder/named_platform_handle.h" 16 #include "mojo/edk/embedder/named_platform_handle.h"
17 17
18 namespace mojo { 18 namespace mojo {
19 namespace edk { 19 namespace edk {
20 namespace { 20 namespace {
21 21
22 // The maximum length of the name of a socket for MODE_NAMED_SERVER or
23 // MODE_NAMED_CLIENT if you want to pass in your own socket.
24 // The standard size on linux is 108, mac is 104. To maintain consistency
25 // across platforms we standardize on the smaller value.
26 const size_t kMaxSocketNameLength = 104;
27
28 // This function fills in |unix_addr| with the appropriate data for the socket, 22 // This function fills in |unix_addr| with the appropriate data for the socket,
29 // and sets |unix_addr_len| to the length of the data therein. 23 // and sets |unix_addr_len| to the length of the data therein.
30 // Returns true on success, or false on failure (typically because |handle.name| 24 // Returns true on success, or false on failure (typically because |handle.name|
31 // violated the naming rules). 25 // violated the naming rules).
32 bool MakeUnixAddr(const NamedPlatformHandle& handle, 26 bool MakeUnixAddr(const NamedPlatformHandle& handle,
33 struct sockaddr_un* unix_addr, 27 struct sockaddr_un* unix_addr,
34 size_t* unix_addr_len) { 28 size_t* unix_addr_len) {
35 DCHECK(unix_addr); 29 DCHECK(unix_addr);
36 DCHECK(unix_addr_len); 30 DCHECK(unix_addr_len);
37 DCHECK(handle.is_valid()); 31 DCHECK(handle.is_valid());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (listen(handle.get().handle, SOMAXCONN) < 0) { 132 if (listen(handle.get().handle, SOMAXCONN) < 0) {
139 PLOG(ERROR) << "listen " << named_handle.name; 133 PLOG(ERROR) << "listen " << named_handle.name;
140 unlink(named_handle.name.c_str()); 134 unlink(named_handle.name.c_str());
141 return ScopedPlatformHandle(); 135 return ScopedPlatformHandle();
142 } 136 }
143 return handle; 137 return handle;
144 } 138 }
145 139
146 } // namespace edk 140 } // namespace edk
147 } // namespace mojo 141 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/embedder/named_platform_handle_utils.h ('k') | mojo/edk/embedder/platform_channel_utils_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698