| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Note: This header should be compilable as C. | 5 // Note: This header should be compilable as C. |
| 6 | 6 |
| 7 #ifndef MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_IMPL_PRIVATE_H_ | 7 #ifndef MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_IMPL_PRIVATE_H_ |
| 8 #define MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_IMPL_PRIVATE_H_ | 8 #define MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_IMPL_PRIVATE_H_ |
| 9 | 9 |
| 10 #include "mojo/public/c/system/system_export.h" | |
| 11 #include "mojo/public/c/system/types.h" | 10 #include "mojo/public/c/system/types.h" |
| 12 | 11 |
| 13 // This interface provides the Mojo system API, but with the ability to confine | 12 // This interface provides the Mojo system API, but with the ability to confine |
| 14 // calls to a specific handle namespace. Handles in one namespace are unrelated | 13 // calls to a specific handle namespace. Handles in one namespace are unrelated |
| 15 // to handles in another namespace. Two ends of a pipe may live in different | 14 // to handles in another namespace. Two ends of a pipe may live in different |
| 16 // handle namespaces, however. | 15 // handle namespaces, however. |
| 17 | 16 |
| 18 typedef void* MojoSystemImpl; | 17 typedef void* MojoSystemImpl; |
| 19 | 18 |
| 20 #ifdef __cplusplus | 19 #ifdef __cplusplus |
| 21 extern "C" { | 20 extern "C" { |
| 22 #endif // __cplusplus | 21 #endif // __cplusplus |
| 23 | 22 |
| 24 // APIs for creating and manipulating MojoSystemImpls. | 23 // APIs for creating and manipulating MojoSystemImpls. |
| 25 | 24 |
| 26 // Returns the MojoSystemImpl implicitly used by the non-SystemImpl version of | 25 // Returns the MojoSystemImpl implicitly used by the non-SystemImpl version of |
| 27 // the Mojo sytem APIs. | 26 // the Mojo sytem APIs. |
| 28 MOJO_SYSTEM_EXPORT MojoSystemImpl MojoSystemImplGetDefaultImpl(); | 27 MojoSystemImpl MojoSystemImplGetDefaultImpl(); |
| 29 | 28 |
| 30 // Creates and returns a new MojoSystemImpl. Currently there is no way to | 29 // Creates and returns a new MojoSystemImpl. Currently there is no way to |
| 31 // destroy a MojoSystemImpl, once created. | 30 // destroy a MojoSystemImpl, once created. |
| 32 MOJO_SYSTEM_EXPORT MojoSystemImpl MojoSystemImplCreateImpl(); | 31 MojoSystemImpl MojoSystemImplCreateImpl(); |
| 33 | 32 |
| 34 // Moves a handle from one MojoSystemImpl to another. | 33 // Moves a handle from one MojoSystemImpl to another. |
| 35 // On success, |result_handle| contains the name of the handle in the new | 34 // On success, |result_handle| contains the name of the handle in the new |
| 36 // namespace. | 35 // namespace. |
| 37 // If |MOJO_RESULT_RESOURCE_EXHAUSTED| is returned, the |handle| will have been | 36 // If |MOJO_RESULT_RESOURCE_EXHAUSTED| is returned, the |handle| will have been |
| 38 // closed, and is now lost. | 37 // closed, and is now lost. |
| 39 // Busy handles cannot be transfered. | 38 // Busy handles cannot be transfered. |
| 40 // To avoid trouble, this API should only be used to bootstrap a newly created | 39 // To avoid trouble, this API should only be used to bootstrap a newly created |
| 41 // |to_system| with a newly created |handle|. | 40 // |to_system| with a newly created |handle|. |
| 42 MOJO_SYSTEM_EXPORT MojoResult | 41 MojoResult MojoSystemImplTransferHandle(MojoSystemImpl from_system, |
| 43 MojoSystemImplTransferHandle(MojoSystemImpl from_system, | 42 MojoHandle handle, |
| 44 MojoHandle handle, | 43 MojoSystemImpl to_system, |
| 45 MojoSystemImpl to_system, | 44 MojoHandle* result_handle); |
| 46 MojoHandle* result_handle); | |
| 47 | 45 |
| 48 // APIs mirroring the Mojo system APIs, but also taking a MojoSystemImpl param. | 46 // APIs mirroring the Mojo system APIs, but also taking a MojoSystemImpl param. |
| 49 MOJO_SYSTEM_EXPORT MojoTimeTicks | 47 MojoTimeTicks MojoSystemImplGetTimeTicksNow(MojoSystemImpl system); |
| 50 MojoSystemImplGetTimeTicksNow(MojoSystemImpl system); | 48 MojoResult MojoSystemImplClose(MojoSystemImpl system, MojoHandle handle); |
| 51 MOJO_SYSTEM_EXPORT MojoResult | 49 MojoResult MojoSystemImplWait(MojoSystemImpl system, |
| 52 MojoSystemImplClose(MojoSystemImpl system, MojoHandle handle); | 50 MojoHandle handle, |
| 53 MOJO_SYSTEM_EXPORT MojoResult | 51 MojoHandleSignals signals, |
| 54 MojoSystemImplWait(MojoSystemImpl system, | 52 MojoDeadline deadline, |
| 55 MojoHandle handle, | 53 struct MojoHandleSignalsState* signals_state); |
| 56 MojoHandleSignals signals, | 54 MojoResult MojoSystemImplWaitMany( |
| 57 MojoDeadline deadline, | 55 MojoSystemImpl system, |
| 58 struct MojoHandleSignalsState* signals_state); | 56 const MojoHandle* handles, |
| 59 MOJO_SYSTEM_EXPORT MojoResult | 57 const MojoHandleSignals* signals, |
| 60 MojoSystemImplWaitMany(MojoSystemImpl system, | 58 uint32_t num_handles, |
| 61 const MojoHandle* handles, | 59 MojoDeadline deadline, |
| 62 const MojoHandleSignals* signals, | 60 uint32_t* result_index, |
| 63 uint32_t num_handles, | 61 struct MojoHandleSignalsState* signals_states); |
| 64 MojoDeadline deadline, | 62 MojoResult MojoSystemImplCreateMessagePipe( |
| 65 uint32_t* result_index, | |
| 66 struct MojoHandleSignalsState* signals_states); | |
| 67 MOJO_SYSTEM_EXPORT MojoResult MojoSystemImplCreateMessagePipe( | |
| 68 MojoSystemImpl system, | 63 MojoSystemImpl system, |
| 69 const struct MojoCreateMessagePipeOptions* options, | 64 const struct MojoCreateMessagePipeOptions* options, |
| 70 MojoHandle* message_pipe_handle0, | 65 MojoHandle* message_pipe_handle0, |
| 71 MojoHandle* message_pipe_handle1); | 66 MojoHandle* message_pipe_handle1); |
| 72 MOJO_SYSTEM_EXPORT MojoResult | 67 MojoResult MojoSystemImplWriteMessage(MojoSystemImpl system, |
| 73 MojoSystemImplWriteMessage(MojoSystemImpl system, | 68 MojoHandle message_pipe_handle, |
| 74 MojoHandle message_pipe_handle, | 69 const void* bytes, |
| 75 const void* bytes, | 70 uint32_t num_bytes, |
| 76 uint32_t num_bytes, | 71 const MojoHandle* handles, |
| 77 const MojoHandle* handles, | 72 uint32_t num_handles, |
| 78 uint32_t num_handles, | 73 MojoWriteMessageFlags flags); |
| 79 MojoWriteMessageFlags flags); | 74 MojoResult MojoSystemImplReadMessage(MojoSystemImpl system, |
| 80 MOJO_SYSTEM_EXPORT MojoResult | 75 MojoHandle message_pipe_handle, |
| 81 MojoSystemImplReadMessage(MojoSystemImpl system, | 76 void* bytes, |
| 82 MojoHandle message_pipe_handle, | 77 uint32_t* num_bytes, |
| 83 void* bytes, | 78 MojoHandle* handles, |
| 84 uint32_t* num_bytes, | 79 uint32_t* num_handles, |
| 85 MojoHandle* handles, | 80 MojoReadMessageFlags flags); |
| 86 uint32_t* num_handles, | 81 MojoResult MojoSystemImplCreateDataPipe( |
| 87 MojoReadMessageFlags flags); | 82 MojoSystemImpl system, |
| 88 MOJO_SYSTEM_EXPORT MojoResult | 83 const struct MojoCreateDataPipeOptions* options, |
| 89 MojoSystemImplCreateDataPipe(MojoSystemImpl system, | 84 MojoHandle* data_pipe_producer_handle, |
| 90 const struct MojoCreateDataPipeOptions* options, | 85 MojoHandle* data_pipe_consumer_handle); |
| 91 MojoHandle* data_pipe_producer_handle, | 86 MojoResult MojoSystemImplWriteData(MojoSystemImpl system, |
| 92 MojoHandle* data_pipe_consumer_handle); | 87 MojoHandle data_pipe_producer_handle, |
| 93 MOJO_SYSTEM_EXPORT MojoResult | 88 const void* elements, |
| 94 MojoSystemImplWriteData(MojoSystemImpl system, | 89 uint32_t* num_elements, |
| 95 MojoHandle data_pipe_producer_handle, | 90 MojoWriteDataFlags flags); |
| 96 const void* elements, | 91 MojoResult MojoSystemImplBeginWriteData(MojoSystemImpl system, |
| 97 uint32_t* num_elements, | 92 MojoHandle data_pipe_producer_handle, |
| 98 MojoWriteDataFlags flags); | 93 void** buffer, |
| 99 MOJO_SYSTEM_EXPORT MojoResult | 94 uint32_t* buffer_num_elements, |
| 100 MojoSystemImplBeginWriteData(MojoSystemImpl system, | 95 MojoWriteDataFlags flags); |
| 101 MojoHandle data_pipe_producer_handle, | 96 MojoResult MojoSystemImplEndWriteData(MojoSystemImpl system, |
| 102 void** buffer, | 97 MojoHandle data_pipe_producer_handle, |
| 103 uint32_t* buffer_num_elements, | 98 uint32_t num_elements_written); |
| 104 MojoWriteDataFlags flags); | 99 MojoResult MojoSystemImplReadData(MojoSystemImpl system, |
| 105 MOJO_SYSTEM_EXPORT MojoResult | 100 MojoHandle data_pipe_consumer_handle, |
| 106 MojoSystemImplEndWriteData(MojoSystemImpl system, | 101 void* elements, |
| 107 MojoHandle data_pipe_producer_handle, | 102 uint32_t* num_elements, |
| 108 uint32_t num_elements_written); | 103 MojoReadDataFlags flags); |
| 109 MOJO_SYSTEM_EXPORT MojoResult | 104 MojoResult MojoSystemImplBeginReadData(MojoSystemImpl system, |
| 110 MojoSystemImplReadData(MojoSystemImpl system, | 105 MojoHandle data_pipe_consumer_handle, |
| 111 MojoHandle data_pipe_consumer_handle, | 106 const void** buffer, |
| 112 void* elements, | 107 uint32_t* buffer_num_elements, |
| 113 uint32_t* num_elements, | 108 MojoReadDataFlags flags); |
| 114 MojoReadDataFlags flags); | 109 MojoResult MojoSystemImplEndReadData(MojoSystemImpl system, |
| 115 MOJO_SYSTEM_EXPORT MojoResult | 110 MojoHandle data_pipe_consumer_handle, |
| 116 MojoSystemImplBeginReadData(MojoSystemImpl system, | 111 uint32_t num_elements_read); |
| 117 MojoHandle data_pipe_consumer_handle, | 112 MojoResult MojoSystemImplCreateSharedBuffer( |
| 118 const void** buffer, | |
| 119 uint32_t* buffer_num_elements, | |
| 120 MojoReadDataFlags flags); | |
| 121 MOJO_SYSTEM_EXPORT MojoResult | |
| 122 MojoSystemImplEndReadData(MojoSystemImpl system, | |
| 123 MojoHandle data_pipe_consumer_handle, | |
| 124 uint32_t num_elements_read); | |
| 125 MOJO_SYSTEM_EXPORT MojoResult MojoSystemImplCreateSharedBuffer( | |
| 126 MojoSystemImpl system, | 113 MojoSystemImpl system, |
| 127 const struct MojoCreateSharedBufferOptions* options, | 114 const struct MojoCreateSharedBufferOptions* options, |
| 128 uint64_t num_bytes, | 115 uint64_t num_bytes, |
| 129 MojoHandle* shared_buffer_handle); | 116 MojoHandle* shared_buffer_handle); |
| 130 MOJO_SYSTEM_EXPORT MojoResult MojoSystemImplDuplicateBufferHandle( | 117 MojoResult MojoSystemImplDuplicateBufferHandle( |
| 131 MojoSystemImpl system, | 118 MojoSystemImpl system, |
| 132 MojoHandle buffer_handle, | 119 MojoHandle buffer_handle, |
| 133 const struct MojoDuplicateBufferHandleOptions* options, | 120 const struct MojoDuplicateBufferHandleOptions* options, |
| 134 MojoHandle* new_buffer_handle); | 121 MojoHandle* new_buffer_handle); |
| 135 MOJO_SYSTEM_EXPORT MojoResult MojoSystemImplMapBuffer(MojoSystemImpl system, | 122 MojoResult MojoSystemImplMapBuffer(MojoSystemImpl system, |
| 136 MojoHandle buffer_handle, | 123 MojoHandle buffer_handle, |
| 137 uint64_t offset, | 124 uint64_t offset, |
| 138 uint64_t num_bytes, | 125 uint64_t num_bytes, |
| 139 void** buffer, | 126 void** buffer, |
| 140 MojoMapBufferFlags flags); | 127 MojoMapBufferFlags flags); |
| 141 MOJO_SYSTEM_EXPORT MojoResult | 128 MojoResult MojoSystemImplUnmapBuffer(MojoSystemImpl system, void* buffer); |
| 142 MojoSystemImplUnmapBuffer(MojoSystemImpl system, void* buffer); | |
| 143 | 129 |
| 144 #ifdef __cplusplus | 130 #ifdef __cplusplus |
| 145 } // extern "C" | 131 } // extern "C" |
| 146 #endif // __cplusplus | 132 #endif // __cplusplus |
| 147 | 133 |
| 148 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_IMPL_PRIVATE_H_ | 134 #endif // MOJO_PUBLIC_PLATFORM_NATIVE_SYSTEM_IMPL_PRIVATE_H_ |
| OLD | NEW |