Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Mojo system handle-related declarations/definitions. | 5 // This file contains Mojo system handle-related declarations/definitions. |
| 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_HANDLE_H_ | 9 #ifndef MOJO_PUBLIC_C_SYSTEM_HANDLE_H_ |
| 10 #define MOJO_PUBLIC_C_SYSTEM_HANDLE_H_ | 10 #define MOJO_PUBLIC_C_SYSTEM_HANDLE_H_ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 // rights. | 120 // rights. |
| 121 // | 121 // |
| 122 // Returns: | 122 // Returns: |
| 123 // |MOJO_RESULT_OK| on success. | 123 // |MOJO_RESULT_OK| on success. |
| 124 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | 124 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. |
| 125 // |MOJO_RESULT_BUSY| if |handle| is currently in use in some transaction | 125 // |MOJO_RESULT_BUSY| if |handle| is currently in use in some transaction |
| 126 // (that, e.g., may result in it being invalidated, such as being sent in | 126 // (that, e.g., may result in it being invalidated, such as being sent in |
| 127 // a message). | 127 // a message). |
| 128 MojoResult MojoGetRights(MojoHandle handle, MojoHandleRights* rights); // Out. | 128 MojoResult MojoGetRights(MojoHandle handle, MojoHandleRights* rights); // Out. |
| 129 | 129 |
| 130 // |MojoReduceRights()|: Reduces rights that the given |handle| may have. | 130 // |MojoReplaceHandleWithReducedRights()|: Replaces |handle| with an equivalent |
| 131 // one with reduced rights. | |
| 131 // | 132 // |
| 132 // That is, on success: | 133 // On success, |*replacement_handle| will be a handle that is equivalent to |
| 134 // |handle| (before the call), but with: | |
| 133 // | 135 // |
| 134 // new rights = current rights & ~rights_to_remove. | 136 // replacement handle rights = current rights & ~rights_to_remove. |
| 137 // | |
| 138 // |handle| will be invalidated, and any ongoing two-phase operations (e.g., for | |
| 139 // data pipes) on |handle| will be aborted. | |
|
jamesr
2016/05/26 19:51:39
this behavior needs to be defined
| |
| 140 // | |
| 141 // On failure, |handle| will remain valid and unchanged (with any ongoing | |
| 142 // two-phase operations undisturbed) and |*replacement_handle| will not be set. | |
| 135 // | 143 // |
| 136 // Note that it is not an error to "remove" rights that the handle does not | 144 // Note that it is not an error to "remove" rights that the handle does not |
| 137 // (currently) possess. | 145 // (currently) possess. |
| 138 // | 146 // |
| 139 // Returns: | 147 // Returns: |
| 140 // |MOJO_RESULT_OK| on success. | 148 // |MOJO_RESULT_OK| on success. |
| 141 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | 149 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. |
| 150 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has | |
| 151 // been reached. | |
| 142 // |MOJO_RESULT_BUSY| if |handle| is currently in use in some transaction | 152 // |MOJO_RESULT_BUSY| if |handle| is currently in use in some transaction |
| 143 // (that, e.g., may result in it being invalidated, such as being sent in | 153 // (that, e.g., may result in it being invalidated, such as being sent in |
| 144 // a message). | 154 // a message). |
| 145 // | 155 MojoResult MojoReplaceHandleWithReducedRights( |
| 146 // TODO(vtl): Discuss this API some more. It may be more desirable to replace | 156 MojoHandle handle, |
| 147 // the handle with a new one (with reduced rights). | 157 MojoHandleRights rights_to_remove, |
| 148 MojoResult MojoReduceRights(MojoHandle handle, | 158 MojoHandle* replacement_handle); // Out. |
| 149 MojoHandleRights rights_to_remove); | |
| 150 | 159 |
| 151 // |MojoDuplicateHandleWithReducedRights()|: Duplicates |handle| to a new handle | 160 // |MojoDuplicateHandleWithReducedRights()|: Duplicates |handle| to a new handle |
| 152 // with reduced rights. This requires |handle| to have the | 161 // with reduced rights. This requires |handle| to have the |
| 153 // |MOJO_HANDLE_RIGHT_DUPLICATE| (note that some handle types may never have | 162 // |MOJO_HANDLE_RIGHT_DUPLICATE| (note that some handle types may never have |
| 154 // this right). | 163 // this right). |
| 155 // | 164 // |
| 156 // The rights for the new handle are determined as in |MojoReduceRights()|. That | 165 // The rights for the new handle are determined as in |
| 157 // is, on success: | 166 // |MojoReplaceHandleWithReducedRights()|. That is, on success: |
| 158 // | 167 // |
| 159 // new handle rights = original handle rights & ~rights_to_remove. | 168 // new handle rights = original handle rights & ~rights_to_remove. |
| 160 // | 169 // |
| 161 // Returns: | 170 // Returns: |
| 162 // |MOJO_RESULT_OK| on success. | 171 // |MOJO_RESULT_OK| on success. |
| 163 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | 172 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. |
| 164 // |MOJO_RESULT_PERMISSION_DENIED| if |handle| does not have the | 173 // |MOJO_RESULT_PERMISSION_DENIED| if |handle| does not have the |
| 165 // |MOJO_HANDLE_RIGHT_DUPLICATE| right. | 174 // |MOJO_HANDLE_RIGHT_DUPLICATE| right. |
| 166 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has | 175 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has |
| 167 // been reached. | 176 // been reached. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 187 // been reached. | 196 // been reached. |
| 188 // |MOJO_RESULT_BUSY| if |handle| is currently in use in some transaction | 197 // |MOJO_RESULT_BUSY| if |handle| is currently in use in some transaction |
| 189 // (that, e.g., may result in it being invalidated, such as being sent in | 198 // (that, e.g., may result in it being invalidated, such as being sent in |
| 190 // a message). | 199 // a message). |
| 191 MojoResult MojoDuplicateHandle(MojoHandle handle, | 200 MojoResult MojoDuplicateHandle(MojoHandle handle, |
| 192 MojoHandle* new_handle); // Out. | 201 MojoHandle* new_handle); // Out. |
| 193 | 202 |
| 194 MOJO_END_EXTERN_C | 203 MOJO_END_EXTERN_C |
| 195 | 204 |
| 196 #endif // MOJO_PUBLIC_C_SYSTEM_HANDLE_H_ | 205 #endif // MOJO_PUBLIC_C_SYSTEM_HANDLE_H_ |
| OLD | NEW |