Chromium Code Reviews| Index: base/posix/unix_domain_socket_linux.h |
| diff --git a/base/posix/unix_domain_socket_linux.h b/base/posix/unix_domain_socket_linux.h |
| index 66fb8bb1bf629894c5badb4564cf517a5e4ded71..1b30ef5e5e452eaa96433c90cbd3b23d699dd8c7 100644 |
| --- a/base/posix/unix_domain_socket_linux.h |
| +++ b/base/posix/unix_domain_socket_linux.h |
| @@ -10,6 +10,7 @@ |
| #include <vector> |
| #include "base/base_export.h" |
| +#include "base/process/process_handle.h" |
|
jln (very slow on Chromium)
2014/04/24 19:24:38
You could forward declare base::ProcessId.
mdempsky
2014/04/24 20:23:30
As discussed at lunch, base::ProcessId can't be fo
willchan no longer on Chromium
2014/04/24 20:44:04
I'm fine with including and not forward declaring,
mdempsky
2014/04/24 20:59:14
I think it would be technically okay to use pid_t
willchan no longer on Chromium
2014/04/24 21:09:56
I generally encourage using the cross-platform typ
|
| class Pickle; |
| @@ -18,6 +19,11 @@ class BASE_EXPORT UnixDomainSocket { |
| // Maximum number of file descriptors that can be read by RecvMsg(). |
| static const size_t kMaxFileDescriptors; |
| + // Use to enable receiving process IDs in RecvMsgWithPid. Should be called on |
| + // the receiving socket (i.e., the socket passed to RecvMsgWithPid). Returns |
| + // true if successful. |
| + static bool EnableReceiveProcessId(int fd); |
| + |
| // Use sendmsg to write the given msg and include a vector of file |
| // descriptors. Returns true if successful. |
| static bool SendMsg(int fd, |
| @@ -32,6 +38,16 @@ class BASE_EXPORT UnixDomainSocket { |
| size_t length, |
| std::vector<int>* fds); |
| + // Same as RecvMsg above, but also returns the sender's process ID (as seen |
| + // from the caller's namespace). However, before using this function to |
| + // receive process IDs, EnableReceiveProcessId() should be called on the |
| + // receiving socket. |
| + static ssize_t RecvMsgWithPid(int fd, |
| + void* msg, |
| + size_t length, |
| + std::vector<int>* fds, |
| + base::ProcessId* pid); |
| + |
| // Perform a sendmsg/recvmsg pair. |
| // 1. This process creates a UNIX SEQPACKET socketpair. Using |
| // connection-oriented sockets (SEQPACKET or STREAM) is critical here, |
| @@ -70,7 +86,8 @@ class BASE_EXPORT UnixDomainSocket { |
| void* msg, |
| size_t length, |
| int flags, |
| - std::vector<int>* fds); |
| + std::vector<int>* fds, |
| + base::ProcessId* pid); |
| }; |
| #endif // BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_ |