| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // convenient for there to be a "GetDispatcher()" that automatically does | 49 // convenient for there to be a "GetDispatcher()" that automatically does |
| 50 // rights-checking.) | 50 // rights-checking.) |
| 51 | 51 |
| 52 // On success, gets the handle for the given handle value (which should not be | 52 // On success, gets the handle for the given handle value (which should not be |
| 53 // |MOJO_HANDLE_INVALID|). On failure, returns an appropriate result (and | 53 // |MOJO_HANDLE_INVALID|). On failure, returns an appropriate result (and |
| 54 // leaves |*handle| alone), namely |MOJO_RESULT_INVALID_ARGUMENT| if there's | 54 // leaves |*handle| alone), namely |MOJO_RESULT_INVALID_ARGUMENT| if there's |
| 55 // no handle for the given handle value or |MOJO_RESULT_BUSY| if the handle is | 55 // no handle for the given handle value or |MOJO_RESULT_BUSY| if the handle is |
| 56 // marked as busy. | 56 // marked as busy. |
| 57 MojoResult GetHandle(MojoHandle handle_value, Handle* handle); | 57 MojoResult GetHandle(MojoHandle handle_value, Handle* handle); |
| 58 | 58 |
| 59 // Like |GetDispatcher()|, but on success also removes the handle value from | 59 // Like |GetHandle()|, but on success also removes the handle value from the |
| 60 // the handle table. | 60 // handle table. |
| 61 MojoResult GetAndRemoveDispatcher(MojoHandle handle_value, | 61 MojoResult GetAndRemoveHandle(MojoHandle handle_value, Handle* handle); |
| 62 util::RefPtr<Dispatcher>* dispatcher); | |
| 63 | 62 |
| 64 // Adds a handle (which must have a dispatcher), returning the handle value | 63 // Adds a handle (which must have a dispatcher), returning the handle value |
| 65 // for it. Returns |MOJO_HANDLE_INVALID| on failure (if the handle table is | 64 // for it. Returns |MOJO_HANDLE_INVALID| on failure (if the handle table is |
| 66 // full). | 65 // full). |
| 67 MojoHandle AddHandle(Handle&& handle); | 66 MojoHandle AddHandle(Handle&& handle); |
| 68 | 67 |
| 69 // Adds a pair of handles (both of which must be valid), returning a pair of | 68 // Adds a pair of handles (both of which must be valid), returning a pair of |
| 70 // handle values for them. On failure (if the handle table is full), the | 69 // handle values for them. On failure (if the handle table is full), the |
| 71 // (first and second) handle values will be |MOJO_HANDLE_INVALID|, and neither | 70 // (first and second) handle values will be |MOJO_HANDLE_INVALID|, and neither |
| 72 // dispatcher will be added. | 71 // dispatcher will be added. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 HandleToEntryMap handle_to_entry_map_; | 142 HandleToEntryMap handle_to_entry_map_; |
| 144 MojoHandle next_handle_value_; // Invariant: never |MOJO_HANDLE_INVALID|. | 143 MojoHandle next_handle_value_; // Invariant: never |MOJO_HANDLE_INVALID|. |
| 145 | 144 |
| 146 MOJO_DISALLOW_COPY_AND_ASSIGN(HandleTable); | 145 MOJO_DISALLOW_COPY_AND_ASSIGN(HandleTable); |
| 147 }; | 146 }; |
| 148 | 147 |
| 149 } // namespace system | 148 } // namespace system |
| 150 } // namespace mojo | 149 } // namespace mojo |
| 151 | 150 |
| 152 #endif // MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ | 151 #endif // MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ |
| OLD | NEW |