| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_ | 5 #ifndef BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_ |
| 6 #define BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_ | 6 #define BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/base_export.h" | 12 #include "base/base_export.h" |
| 13 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
| 16 | 16 |
| 17 namespace base { |
| 17 class Pickle; | 18 class Pickle; |
| 19 } |
| 18 | 20 |
| 19 class BASE_EXPORT UnixDomainSocket { | 21 class BASE_EXPORT UnixDomainSocket { |
| 20 public: | 22 public: |
| 21 // Maximum number of file descriptors that can be read by RecvMsg(). | 23 // Maximum number of file descriptors that can be read by RecvMsg(). |
| 22 static const size_t kMaxFileDescriptors; | 24 static const size_t kMaxFileDescriptors; |
| 23 | 25 |
| 24 #if !defined(OS_NACL_NONSFI) | 26 #if !defined(OS_NACL_NONSFI) |
| 25 // Use to enable receiving process IDs in RecvMsgWithPid. Should be called on | 27 // Use to enable receiving process IDs in RecvMsgWithPid. Should be called on |
| 26 // the receiving socket (i.e., the socket passed to RecvMsgWithPid). Returns | 28 // the receiving socket (i.e., the socket passed to RecvMsgWithPid). Returns |
| 27 // true if successful. | 29 // true if successful. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // fd: descriptor to send the request on | 70 // fd: descriptor to send the request on |
| 69 // reply: buffer for the reply | 71 // reply: buffer for the reply |
| 70 // reply_len: size of |reply| | 72 // reply_len: size of |reply| |
| 71 // result_fd: (may be NULL) the file descriptor returned in the reply | 73 // result_fd: (may be NULL) the file descriptor returned in the reply |
| 72 // (if any) | 74 // (if any) |
| 73 // request: the bytes to send in the request | 75 // request: the bytes to send in the request |
| 74 static ssize_t SendRecvMsg(int fd, | 76 static ssize_t SendRecvMsg(int fd, |
| 75 uint8_t* reply, | 77 uint8_t* reply, |
| 76 unsigned reply_len, | 78 unsigned reply_len, |
| 77 int* result_fd, | 79 int* result_fd, |
| 78 const Pickle& request); | 80 const base::Pickle& request); |
| 79 | 81 |
| 80 // Similar to SendRecvMsg(), but |recvmsg_flags| allows to control the flags | 82 // Similar to SendRecvMsg(), but |recvmsg_flags| allows to control the flags |
| 81 // of the recvmsg(2) call. | 83 // of the recvmsg(2) call. |
| 82 static ssize_t SendRecvMsgWithFlags(int fd, | 84 static ssize_t SendRecvMsgWithFlags(int fd, |
| 83 uint8_t* reply, | 85 uint8_t* reply, |
| 84 unsigned reply_len, | 86 unsigned reply_len, |
| 85 int recvmsg_flags, | 87 int recvmsg_flags, |
| 86 int* result_fd, | 88 int* result_fd, |
| 87 const Pickle& request); | 89 const base::Pickle& request); |
| 88 #endif // !defined(OS_NACL_NONSFI) | 90 #endif // !defined(OS_NACL_NONSFI) |
| 89 private: | 91 private: |
| 90 // Similar to RecvMsg, but allows to specify |flags| for recvmsg(2). | 92 // Similar to RecvMsg, but allows to specify |flags| for recvmsg(2). |
| 91 static ssize_t RecvMsgWithFlags(int fd, | 93 static ssize_t RecvMsgWithFlags(int fd, |
| 92 void* msg, | 94 void* msg, |
| 93 size_t length, | 95 size_t length, |
| 94 int flags, | 96 int flags, |
| 95 ScopedVector<base::ScopedFD>* fds, | 97 ScopedVector<base::ScopedFD>* fds, |
| 96 base::ProcessId* pid); | 98 base::ProcessId* pid); |
| 97 }; | 99 }; |
| 98 | 100 |
| 99 #endif // BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_ | 101 #endif // BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_ |
| OLD | NEW |