| 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 // full). | 67 // full). |
| 68 MojoHandle AddHandle(Handle&& handle); | 68 MojoHandle AddHandle(Handle&& handle); |
| 69 | 69 |
| 70 // Adds a pair of handles (both of which must be valid), returning a pair of | 70 // Adds a pair of handles (both of which must be valid), returning a pair of |
| 71 // handle values for them. On failure (if the handle table is full), the | 71 // handle values for them. On failure (if the handle table is full), the |
| 72 // (first and second) handle values will be |MOJO_HANDLE_INVALID|, and neither | 72 // (first and second) handle values will be |MOJO_HANDLE_INVALID|, and neither |
| 73 // dispatcher will be added. | 73 // dispatcher will be added. |
| 74 std::pair<MojoHandle, MojoHandle> AddHandlePair(Handle&& handle0, | 74 std::pair<MojoHandle, MojoHandle> AddHandlePair(Handle&& handle0, |
| 75 Handle&& handle1); | 75 Handle&& handle1); |
| 76 | 76 |
| 77 // Adds the given vector of dispatchers (of size at most | 77 // Adds the given vector of handles (of size at most |
| 78 // |kMaxMessageNumHandles|). |handle_values| must point to an array of size at | 78 // |kMaxMessageNumHandles|). |handle_values| must point to an array of size at |
| 79 // least |dispatchers.size()|. Unlike the other |AddDispatcher...()| | 79 // least |handles->size()|. Unlike the other |AddHandle...()| functions, some |
| 80 // functions, some of the dispatchers may be invalid (null). Returns true on | 80 // of the handles may be invalid ("null"). Returns true on success in which |
| 81 // success and false on failure (if the handle table is full), in which case | 81 // case all the handles in |*handles| are moved from, and false on failure (if |
| 82 // it leaves |handle_values[...]| untouched (and all dispatchers unadded). | 82 // the handle table is full), in which case it leaves all |handles->at(...)|| |
| 83 // (and all the handles unadded) and |handle_values[...]| untouched. |
| 84 bool AddHandleVector(HandleVector* handles, MojoHandle* handle_values); |
| 85 // TODO(vtl): Delete this version (use |AddHandleVector()| instead). |
| 83 bool AddDispatcherVector(const DispatcherVector& dispatchers, | 86 bool AddDispatcherVector(const DispatcherVector& dispatchers, |
| 84 MojoHandle* handle_values); | 87 MojoHandle* handle_values); |
| 85 | 88 |
| 86 // Tries to mark the given handle values as busy and start transport on them | 89 // Tries to mark the given handle values as busy and start transport on them |
| 87 // (i.e., take their dispatcher locks); |transports| must be sized to contain | 90 // (i.e., take their dispatcher locks); |transports| must be sized to contain |
| 88 // |num_handles| elements. On failure, returns them to their original | 91 // |num_handles| elements. On failure, returns them to their original |
| 89 // (non-busy, unlocked state). | 92 // (non-busy, unlocked state). |
| 90 MojoResult MarkBusyAndStartTransport( | 93 MojoResult MarkBusyAndStartTransport( |
| 91 MojoHandle disallowed_handle, | 94 MojoHandle disallowed_handle, |
| 92 const MojoHandle* handle_values, | 95 const MojoHandle* handle_values, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 HandleToEntryMap handle_to_entry_map_; | 144 HandleToEntryMap handle_to_entry_map_; |
| 142 MojoHandle next_handle_value_; // Invariant: never |MOJO_HANDLE_INVALID|. | 145 MojoHandle next_handle_value_; // Invariant: never |MOJO_HANDLE_INVALID|. |
| 143 | 146 |
| 144 MOJO_DISALLOW_COPY_AND_ASSIGN(HandleTable); | 147 MOJO_DISALLOW_COPY_AND_ASSIGN(HandleTable); |
| 145 }; | 148 }; |
| 146 | 149 |
| 147 } // namespace system | 150 } // namespace system |
| 148 } // namespace mojo | 151 } // namespace mojo |
| 149 | 152 |
| 150 #endif // MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ | 153 #endif // MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ |
| OLD | NEW |