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_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ | 5 #ifndef MOJO_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ |
6 #define MOJO_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ | 6 #define MOJO_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 <vector> | 11 #include <deque> |
12 | 12 |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "mojo/embedder/platform_handle.h" | 14 #include "mojo/embedder/platform_handle.h" |
15 #include "mojo/embedder/platform_handle_vector.h" | |
16 #include "mojo/system/system_impl_export.h" | 15 #include "mojo/system/system_impl_export.h" |
17 | 16 |
18 struct iovec; // Declared in <sys/uio.h>. | 17 struct iovec; // Declared in <sys/uio.h>. |
19 | 18 |
20 namespace mojo { | 19 namespace mojo { |
21 namespace embedder { | 20 namespace embedder { |
22 | 21 |
23 // The maximum number of handles that can be sent "at once" using | 22 // The maximum number of handles that can be sent "at once" using |
24 // |PlatformChannelSendHandles()|. | 23 // |PlatformChannelSendHandles()|. |
25 // TODO(vtl): This number is taken from ipc/file_descriptor_set_posix.h: | 24 // TODO(vtl): This number is taken from ipc/file_descriptor_set_posix.h: |
(...skipping 15 matching lines...) Expand all Loading... | |
41 // (e.g., created using PlatformChannelPair|). (These will be sent in a single | 40 // (e.g., created using PlatformChannelPair|). (These will be sent in a single |
42 // message having one null byte of data and one control message header with all | 41 // message having one null byte of data and one control message header with all |
43 // the file descriptors.) All of the handles must be valid, and there must be at | 42 // the file descriptors.) All of the handles must be valid, and there must be at |
44 // most |kPlatformChannelMaxNumHandles| (and at least one handle). Returns true | 43 // most |kPlatformChannelMaxNumHandles| (and at least one handle). Returns true |
45 // on success, in which case it closes all the handles. | 44 // on success, in which case it closes all the handles. |
46 MOJO_SYSTEM_IMPL_EXPORT bool PlatformChannelSendHandles(PlatformHandle h, | 45 MOJO_SYSTEM_IMPL_EXPORT bool PlatformChannelSendHandles(PlatformHandle h, |
47 PlatformHandle* handles, | 46 PlatformHandle* handles, |
48 size_t num_handles); | 47 size_t num_handles); |
49 | 48 |
50 // Wrapper around |recvmsg()|, which will extract any attached file descriptors | 49 // Wrapper around |recvmsg()|, which will extract any attached file descriptors |
51 // (in the control message) to |PlatformHandle|s. (This also handles |EINTR|.) | 50 // (in the control message) to |PlatformHandle|s (and appended to |
yzshen1
2014/05/20 21:09:46
nit: appended -> append them?
viettrungluu
2014/05/20 21:17:36
Done.
| |
52 // If |*handles| is null and handles are received, a vector will be allocated; | 51 // |platform_handles|). (This also handles |EINTR|.) |
53 // otherwise, any handles received will be appended to the existing vector. | |
54 MOJO_SYSTEM_IMPL_EXPORT ssize_t PlatformChannelRecvmsg( | 52 MOJO_SYSTEM_IMPL_EXPORT ssize_t PlatformChannelRecvmsg( |
55 PlatformHandle h, | 53 PlatformHandle h, |
56 void* buf, | 54 void* buf, |
57 size_t num_bytes, | 55 size_t num_bytes, |
58 ScopedPlatformHandleVectorPtr* handles); | 56 std::deque<PlatformHandle>* platform_handles); |
59 | 57 |
60 } // namespace embedder | 58 } // namespace embedder |
61 } // namespace mojo | 59 } // namespace mojo |
62 | 60 |
63 #endif // MOJO_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ | 61 #endif // MOJO_EMBEDDER_PLATFORM_CHANNEL_UTILS_POSIX_H_ |
OLD | NEW |