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

Side by Side Diff: base/posix/unix_domain_socket_linux.h

Issue 659513004: Non-SFI Mode: Build base/ library by PNaCL toolchain for nacl_helper_nonsfi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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 (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 class Pickle; 17 class Pickle;
18 18
19 class BASE_EXPORT UnixDomainSocket { 19 class BASE_EXPORT UnixDomainSocket {
20 public: 20 public:
21 // Maximum number of file descriptors that can be read by RecvMsg(). 21 // Maximum number of file descriptors that can be read by RecvMsg().
22 static const size_t kMaxFileDescriptors; 22 static const size_t kMaxFileDescriptors;
23 23
24 #if !defined(__native_client_nonsfi__)
24 // Use to enable receiving process IDs in RecvMsgWithPid. Should be called on 25 // Use to enable receiving process IDs in RecvMsgWithPid. Should be called on
25 // the receiving socket (i.e., the socket passed to RecvMsgWithPid). Returns 26 // the receiving socket (i.e., the socket passed to RecvMsgWithPid). Returns
26 // true if successful. 27 // true if successful.
27 static bool EnableReceiveProcessId(int fd); 28 static bool EnableReceiveProcessId(int fd);
29 #endif // !defined(__native_client_nonsfi__)
28 30
29 // Use sendmsg to write the given msg and include a vector of file 31 // Use sendmsg to write the given msg and include a vector of file
30 // descriptors. Returns true if successful. 32 // descriptors. Returns true if successful.
31 static bool SendMsg(int fd, 33 static bool SendMsg(int fd,
32 const void* msg, 34 const void* msg,
33 size_t length, 35 size_t length,
34 const std::vector<int>& fds); 36 const std::vector<int>& fds);
35 37
36 // Use recvmsg to read a message and an array of file descriptors. Returns 38 // Use recvmsg to read a message and an array of file descriptors. Returns
37 // -1 on failure. Note: will read, at most, |kMaxFileDescriptors| descriptors. 39 // -1 on failure. Note: will read, at most, |kMaxFileDescriptors| descriptors.
38 static ssize_t RecvMsg(int fd, 40 static ssize_t RecvMsg(int fd,
39 void* msg, 41 void* msg,
40 size_t length, 42 size_t length,
41 ScopedVector<base::ScopedFD>* fds); 43 ScopedVector<base::ScopedFD>* fds);
42 44
43 // Same as RecvMsg above, but also returns the sender's process ID (as seen 45 // Same as RecvMsg above, but also returns the sender's process ID (as seen
44 // from the caller's namespace). However, before using this function to 46 // from the caller's namespace). However, before using this function to
45 // receive process IDs, EnableReceiveProcessId() should be called on the 47 // receive process IDs, EnableReceiveProcessId() should be called on the
46 // receiving socket. 48 // receiving socket.
47 static ssize_t RecvMsgWithPid(int fd, 49 static ssize_t RecvMsgWithPid(int fd,
48 void* msg, 50 void* msg,
49 size_t length, 51 size_t length,
50 ScopedVector<base::ScopedFD>* fds, 52 ScopedVector<base::ScopedFD>* fds,
51 base::ProcessId* pid); 53 base::ProcessId* pid);
52 54
55 #if !defined(__native_client_nonsfi__)
53 // Perform a sendmsg/recvmsg pair. 56 // Perform a sendmsg/recvmsg pair.
54 // 1. This process creates a UNIX SEQPACKET socketpair. Using 57 // 1. This process creates a UNIX SEQPACKET socketpair. Using
55 // connection-oriented sockets (SEQPACKET or STREAM) is critical here, 58 // connection-oriented sockets (SEQPACKET or STREAM) is critical here,
56 // because if one of the ends closes the other one must be notified. 59 // because if one of the ends closes the other one must be notified.
57 // 2. This process writes a request to |fd| with an SCM_RIGHTS control 60 // 2. This process writes a request to |fd| with an SCM_RIGHTS control
58 // message containing on end of the fresh socket pair. 61 // message containing on end of the fresh socket pair.
59 // 3. This process blocks reading from the other end of the fresh 62 // 3. This process blocks reading from the other end of the fresh
60 // socketpair. 63 // socketpair.
61 // 4. The target process receives the request, processes it and writes the 64 // 4. The target process receives the request, processes it and writes the
62 // reply to the end of the socketpair contained in the request. 65 // reply to the end of the socketpair contained in the request.
(...skipping 12 matching lines...) Expand all
75 const Pickle& request); 78 const Pickle& request);
76 79
77 // Similar to SendRecvMsg(), but |recvmsg_flags| allows to control the flags 80 // Similar to SendRecvMsg(), but |recvmsg_flags| allows to control the flags
78 // of the recvmsg(2) call. 81 // of the recvmsg(2) call.
79 static ssize_t SendRecvMsgWithFlags(int fd, 82 static ssize_t SendRecvMsgWithFlags(int fd,
80 uint8_t* reply, 83 uint8_t* reply,
81 unsigned reply_len, 84 unsigned reply_len,
82 int recvmsg_flags, 85 int recvmsg_flags,
83 int* result_fd, 86 int* result_fd,
84 const Pickle& request); 87 const Pickle& request);
88 #endif // !defined(__native_client_nonsfi__)
85 private: 89 private:
86 // Similar to RecvMsg, but allows to specify |flags| for recvmsg(2). 90 // Similar to RecvMsg, but allows to specify |flags| for recvmsg(2).
87 static ssize_t RecvMsgWithFlags(int fd, 91 static ssize_t RecvMsgWithFlags(int fd,
88 void* msg, 92 void* msg,
89 size_t length, 93 size_t length,
90 int flags, 94 int flags,
91 ScopedVector<base::ScopedFD>* fds, 95 ScopedVector<base::ScopedFD>* fds,
92 base::ProcessId* pid); 96 base::ProcessId* pid);
93 }; 97 };
94 98
95 #endif // BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_ 99 #endif // BASE_POSIX_UNIX_DOMAIN_SOCKET_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698