Chromium Code Reviews| 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 // This file contains types/constants and functions specific to message pipes. | 5 // This file contains types/constants and functions specific to message pipes. |
| 6 // | 6 // |
| 7 // Note: This header should be compilable as C. | 7 // Note: This header should be compilable as C. |
| 8 | 8 |
| 9 #ifndef MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ | 9 #ifndef MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ |
| 10 #define MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ | 10 #define MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 // receiver will receive equivalent, but logically different, handles). Handles | 92 // receiver will receive equivalent, but logically different, handles). Handles |
| 93 // to be sent should not be in simultaneous use (e.g., on another thread). On | 93 // to be sent should not be in simultaneous use (e.g., on another thread). On |
| 94 // failure, any handles to be attached will remain valid. | 94 // failure, any handles to be attached will remain valid. |
| 95 // | 95 // |
| 96 // Returns: | 96 // Returns: |
| 97 // |MOJO_RESULT_OK| on success (i.e., the message was enqueued). | 97 // |MOJO_RESULT_OK| on success (i.e., the message was enqueued). |
| 98 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., if | 98 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., if |
| 99 // |message_pipe_handle| is not a valid handle, or some of the | 99 // |message_pipe_handle| is not a valid handle, or some of the |
| 100 // requirements above are not satisfied). | 100 // requirements above are not satisfied). |
| 101 // |MOJO_RESULT_PERMISSION_DENIED| if |message_pipe_handle| does not have the | 101 // |MOJO_RESULT_PERMISSION_DENIED| if |message_pipe_handle| does not have the |
| 102 // |MOJO_HANDLE_RIGHT_WRITE| right. | 102 // |MOJO_HANDLE_RIGHT_WRITE| right or if one of the handles to be sent |
| 103 // does not have the |MOJO_HANDLE_RIGHT_TRANSFER| right. | |
| 103 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if some system limit has been reached, or | 104 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if some system limit has been reached, or |
| 104 // the number of handles to send is too large (TODO(vtl): reconsider the | 105 // the number of handles to send is too large (TODO(vtl): reconsider the |
| 105 // latter case). | 106 // latter case). |
| 106 // |MOJO_RESULT_FAILED_PRECONDITION| if the other endpoint has been closed. | 107 // |MOJO_RESULT_FAILED_PRECONDITION| if the other endpoint has been closed. |
| 107 // Note that closing an endpoint is not necessarily synchronous (e.g., | 108 // Note that closing an endpoint is not necessarily synchronous (e.g., |
| 108 // across processes), so this function may succeed even if the other | 109 // across processes), so this function may succeed even if the other |
| 109 // endpoint has been closed (in which case the message would be dropped). | 110 // endpoint has been closed (in which case the message would be dropped). |
| 110 // |MOJO_RESULT_UNIMPLEMENTED| if an unsupported flag was set in |*options|. | 111 // |MOJO_RESULT_UNIMPLEMENTED| if an unsupported flag was set in |*options|. |
| 111 // |MOJO_RESULT_BUSY| if |message_pipe_handle| is currently in use in some | 112 // |MOJO_RESULT_BUSY| if |message_pipe_handle| is currently in use in some |
| 112 // transaction (that, e.g., may result in it being invalidated, such as | 113 // transaction (that, e.g., may result in it being invalidated, such as |
| 113 // being sent in a message), or if some handle to be sent is currently in | 114 // being sent in a message), or if some handle to be sent is currently in |
| 114 // use. | 115 // use. |
| 115 // | 116 // |
| 117 // Note: |MOJO_RESULT_BUSY| is generally "preferred" over | |
|
azani
2016/05/25 03:23:53
I'm curious as to why that is. It seems like it's
| |
| 118 // |MOJO_RESULT_PERMISSION_DENIED|. E.g., if a handle to be sent both is busy | |
| 119 // and does not have the transfer right, then the result will be "busy". | |
| 120 // | |
| 121 // TODO(vtl): We'll also report |MOJO_RESULT_BUSY| if a (data pipe | |
| 122 // producer/consumer) handle to be sent is in a two-phase write/read). But | |
| 123 // should we? (For comparison, there's no such provision in |MojoClose()|.) | |
| 124 // https://github.com/domokit/mojo/issues/782 | |
| 125 // | |
| 116 // TODO(vtl): Add a notion of capacity for message pipes, and return | 126 // TODO(vtl): Add a notion of capacity for message pipes, and return |
| 117 // |MOJO_RESULT_SHOULD_WAIT| if the message pipe is full. | 127 // |MOJO_RESULT_SHOULD_WAIT| if the message pipe is full. |
| 118 MojoResult MojoWriteMessage(MojoHandle message_pipe_handle, // In. | 128 MojoResult MojoWriteMessage(MojoHandle message_pipe_handle, // In. |
| 119 const void* bytes, // Optional in. | 129 const void* bytes, // Optional in. |
| 120 uint32_t num_bytes, // In. | 130 uint32_t num_bytes, // In. |
| 121 const MojoHandle* handles, // Optional in. | 131 const MojoHandle* handles, // Optional in. |
| 122 uint32_t num_handles, // In. | 132 uint32_t num_handles, // In. |
| 123 MojoWriteMessageFlags flags); // In. | 133 MojoWriteMessageFlags flags); // In. |
| 124 | 134 |
| 125 // |MojoReadMessage()|: Reads the next message from the message pipe endpoint | 135 // |MojoReadMessage()|: Reads the next message from the message pipe endpoint |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 MojoHandle message_pipe_handle, // In. | 173 MojoHandle message_pipe_handle, // In. |
| 164 void* MOJO_RESTRICT bytes, // Optional out. | 174 void* MOJO_RESTRICT bytes, // Optional out. |
| 165 uint32_t* MOJO_RESTRICT num_bytes, // Optional in/out. | 175 uint32_t* MOJO_RESTRICT num_bytes, // Optional in/out. |
| 166 MojoHandle* MOJO_RESTRICT handles, // Optional out. | 176 MojoHandle* MOJO_RESTRICT handles, // Optional out. |
| 167 uint32_t* MOJO_RESTRICT num_handles, // Optional in/out. | 177 uint32_t* MOJO_RESTRICT num_handles, // Optional in/out. |
| 168 MojoReadMessageFlags flags); // In. | 178 MojoReadMessageFlags flags); // In. |
| 169 | 179 |
| 170 MOJO_END_EXTERN_C | 180 MOJO_END_EXTERN_C |
| 171 | 181 |
| 172 #endif // MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ | 182 #endif // MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ |
| OLD | NEW |