| 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_SYSTEM_HANDLE_TABLE_H_ | 5 #ifndef MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ |
| 6 #define MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ | 6 #define MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 // Adds the given vector of handles (of size at most | 68 // Adds the given vector of handles (of size at most |
| 69 // |kMaxMessageNumHandles|). |handle_values| must point to an array of size at | 69 // |kMaxMessageNumHandles|). |handle_values| must point to an array of size at |
| 70 // least |handles->size()|. Unlike the other |AddHandle...()| functions, some | 70 // least |handles->size()|. Unlike the other |AddHandle...()| functions, some |
| 71 // of the handles may be invalid ("null"). Returns true on success in which | 71 // of the handles may be invalid ("null"). Returns true on success in which |
| 72 // case all the handles in |*handles| are moved from, and false on failure (if | 72 // case all the handles in |*handles| are moved from, and false on failure (if |
| 73 // the handle table is full), in which case it leaves all |handles->at(...)|| | 73 // the handle table is full), in which case it leaves all |handles->at(...)|| |
| 74 // (and all the handles unadded) and |handle_values[...]| untouched. | 74 // (and all the handles unadded) and |handle_values[...]| untouched. |
| 75 bool AddHandleVector(HandleVector* handles, MojoHandle* handle_values); | 75 bool AddHandleVector(HandleVector* handles, MojoHandle* handle_values); |
| 76 | 76 |
| 77 // Replaces the given handle value with an "equivalent" one with the specified |
| 78 // rights not removed. (The handle need not have those rights in the first |
| 79 // place.) |handle_value| should not be |MOJO_HANDLE_INVALID|. |
| 80 MojoResult ReplaceHandleWithReducedRights( |
| 81 MojoHandle handle_value, |
| 82 MojoHandleRights rights_to_remove, |
| 83 MojoHandle* replacement_handle_value); |
| 84 |
| 77 // Tries to mark the given handle values as busy and start transport on them | 85 // Tries to mark the given handle values as busy and start transport on them |
| 78 // (i.e., take their dispatcher locks). The handles to be transported must all | 86 // (i.e., take their dispatcher locks). The handles to be transported must all |
| 79 // have the |MOJO_HANDLE_RIGHT_TRANSFER| right. |transports| must be sized to | 87 // have the |MOJO_HANDLE_RIGHT_TRANSFER| right. |transports| must be sized to |
| 80 // contain |num_handles| elements. On failure, returns them to their original | 88 // contain |num_handles| elements. On failure, returns them to their original |
| 81 // (non-busy, unlocked state). | 89 // (non-busy, unlocked state). |
| 82 MojoResult MarkBusyAndStartTransport( | 90 MojoResult MarkBusyAndStartTransport( |
| 83 MojoHandle disallowed_handle, | 91 MojoHandle disallowed_handle_value, |
| 84 const MojoHandle* handle_values, | 92 const MojoHandle* handle_values, |
| 85 uint32_t num_handles, | 93 uint32_t num_handles, |
| 86 std::vector<HandleTransport>* transports); | 94 std::vector<HandleTransport>* transports); |
| 87 | 95 |
| 88 // Remove the given handle values, which must all be present and which should | 96 // Remove the given handle values, which must all be present and which should |
| 89 // have previously been marked busy by |MarkBusyAndStartTransport()|. | 97 // have previously been marked busy by |MarkBusyAndStartTransport()|. |
| 90 void RemoveBusyHandles(const MojoHandle* handle_values, uint32_t num_handles); | 98 void RemoveBusyHandles(const MojoHandle* handle_values, uint32_t num_handles); |
| 91 | 99 |
| 92 // Restores the given handle values, which must all be present and which | 100 // Restores the given handle values, which must all be present and which |
| 93 // should have previously been marked busy by |MarkBusyAndStartTransport()|, | 101 // should have previously been marked busy by |MarkBusyAndStartTransport()|, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 HandleToEntryMap handle_to_entry_map_; | 140 HandleToEntryMap handle_to_entry_map_; |
| 133 MojoHandle next_handle_value_; // Invariant: never |MOJO_HANDLE_INVALID|. | 141 MojoHandle next_handle_value_; // Invariant: never |MOJO_HANDLE_INVALID|. |
| 134 | 142 |
| 135 MOJO_DISALLOW_COPY_AND_ASSIGN(HandleTable); | 143 MOJO_DISALLOW_COPY_AND_ASSIGN(HandleTable); |
| 136 }; | 144 }; |
| 137 | 145 |
| 138 } // namespace system | 146 } // namespace system |
| 139 } // namespace mojo | 147 } // namespace mojo |
| 140 | 148 |
| 141 #endif // MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ | 149 #endif // MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ |
| OLD | NEW |