Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / base / posix / unix_domain_socket_linux.h
index 66fb8bb..59bb884 100644 (file)
@@ -10,6 +10,9 @@
 #include <vector>
 
 #include "base/base_export.h"
+#include "base/files/scoped_file.h"
+#include "base/memory/scoped_vector.h"
+#include "base/process/process_handle.h"
 
 class Pickle;
 
@@ -18,6 +21,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,
@@ -30,7 +38,17 @@ class BASE_EXPORT UnixDomainSocket {
   static ssize_t RecvMsg(int fd,
                          void* msg,
                          size_t length,
-                         std::vector<int>* fds);
+                         ScopedVector<base::ScopedFD>* 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,
+                                ScopedVector<base::ScopedFD>* fds,
+                                base::ProcessId* pid);
 
   // Perform a sendmsg/recvmsg pair.
   //   1. This process creates a UNIX SEQPACKET socketpair. Using
@@ -70,7 +88,8 @@ class BASE_EXPORT UnixDomainSocket {
                                   void* msg,
                                   size_t length,
                                   int flags,
-                                  std::vector<int>* fds);
+                                  ScopedVector<base::ScopedFD>* fds,
+                                  base::ProcessId* pid);
 };
 
 #endif  // BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_