OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ | 5 #ifndef MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ |
6 #define MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ | 6 #define MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <sys/types.h> // For |ssize_t|. | 9 #include <sys/types.h> // For |ssize_t|. |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "mojo/edk/embedder/platform_handle.h" | 14 #include "mojo/edk/embedder/platform_handle.h" |
15 #include "mojo/edk/system/system_impl_export.h" | 15 #include "mojo/edk/system/system_impl_export.h" |
16 | 16 |
17 struct iovec; // Declared in <sys/uio.h>. | 17 struct iovec; // Declared in <sys/uio.h>. |
18 | 18 |
19 namespace mojo { | 19 namespace mojo { |
20 namespace edk { | 20 namespace edk { |
| 21 class ScopedPlatformHandle; |
21 | 22 |
22 // The maximum number of handles that can be sent "at once" using | 23 // The maximum number of handles that can be sent "at once" using |
23 // |PlatformChannelSendmsgWithHandles()|. This must be less than the Linux | 24 // |PlatformChannelSendmsgWithHandles()|. This must be less than the Linux |
24 // kernel's SCM_MAX_FD which is 253. | 25 // kernel's SCM_MAX_FD which is 253. |
25 const size_t kPlatformChannelMaxNumHandles = 128; | 26 const size_t kPlatformChannelMaxNumHandles = 128; |
26 | 27 |
27 // Use these to write to a socket created using |PlatformChannelPair| (or | 28 // Use these to write to a socket created using |PlatformChannelPair| (or |
28 // equivalent). These are like |write()| and |writev()|, but handle |EINTR| and | 29 // equivalent). These are like |write()| and |writev()|, but handle |EINTR| and |
29 // never raise |SIGPIPE|. (Note: On Mac, the suppression of |SIGPIPE| is set up | 30 // never raise |SIGPIPE|. (Note: On Mac, the suppression of |SIGPIPE| is set up |
30 // by |PlatformChannelPair|.) | 31 // by |PlatformChannelPair|.) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Wrapper around |recvmsg()|, which will extract any attached file descriptors | 64 // Wrapper around |recvmsg()|, which will extract any attached file descriptors |
64 // (in the control message) to |PlatformHandle|s (and append them to | 65 // (in the control message) to |PlatformHandle|s (and append them to |
65 // |platform_handles|). (This also handles |EINTR|.) | 66 // |platform_handles|). (This also handles |EINTR|.) |
66 MOJO_SYSTEM_IMPL_EXPORT ssize_t | 67 MOJO_SYSTEM_IMPL_EXPORT ssize_t |
67 PlatformChannelRecvmsg(PlatformHandle h, | 68 PlatformChannelRecvmsg(PlatformHandle h, |
68 void* buf, | 69 void* buf, |
69 size_t num_bytes, | 70 size_t num_bytes, |
70 std::deque<PlatformHandle>* platform_handles, | 71 std::deque<PlatformHandle>* platform_handles, |
71 bool block = false); | 72 bool block = false); |
72 | 73 |
| 74 // Returns false if |server_handle| encounters an unrecoverable error. |
| 75 // Returns true if it's valid to keep listening on |server_handle|. In this |
| 76 // case, it's possible that a connection wasn't successfully established; then, |
| 77 // |connection_handle| will be invalid. |
| 78 bool ServerAcceptConnection(PlatformHandle server_handle, |
| 79 ScopedPlatformHandle* connection_handle); |
| 80 |
73 } // namespace edk | 81 } // namespace edk |
74 } // namespace mojo | 82 } // namespace mojo |
75 | 83 |
76 #endif // MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ | 84 #endif // MOJO_EDK_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ |
OLD | NEW |