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> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "mojo/edk/system/handle.h" | 14 #include "mojo/edk/system/handle.h" |
15 #include "mojo/edk/util/ref_ptr.h" | 15 #include "mojo/edk/util/ref_ptr.h" |
16 #include "mojo/public/c/system/handle.h" | 16 #include "mojo/public/c/system/handle.h" |
17 #include "mojo/public/c/system/result.h" | 17 #include "mojo/public/c/system/result.h" |
18 #include "mojo/public/cpp/system/macros.h" | 18 #include "mojo/public/cpp/system/macros.h" |
19 | 19 |
20 namespace mojo { | 20 namespace mojo { |
21 namespace system { | 21 namespace system { |
22 | 22 |
23 class Core; | 23 class Core; |
24 class Dispatcher; | 24 class Dispatcher; |
25 class DispatcherTransport; | 25 class HandleTransport; |
26 | 26 |
27 using DispatcherVector = std::vector<util::RefPtr<Dispatcher>>; | 27 using DispatcherVector = std::vector<util::RefPtr<Dispatcher>>; |
28 | 28 |
29 // Test-only function (defined/used in embedder/test_embedder.cc). Declared here | 29 // Test-only function (defined/used in embedder/test_embedder.cc). Declared here |
30 // so it can be friended. | 30 // so it can be friended. |
31 namespace internal { | 31 namespace internal { |
32 bool ShutdownCheckNoLeaks(Core*); | 32 bool ShutdownCheckNoLeaks(Core*); |
33 } | 33 } |
34 | 34 |
35 // This class provides the (global) handle table (owned by |Core|), which maps | 35 // This class provides the (global) handle table (owned by |Core|), which maps |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 MojoHandle* handle_values); | 84 MojoHandle* handle_values); |
85 | 85 |
86 // Tries to mark the given handle values as busy and start transport on them | 86 // 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 | 87 // (i.e., take their dispatcher locks); |transports| must be sized to contain |
88 // |num_handles| elements. On failure, returns them to their original | 88 // |num_handles| elements. On failure, returns them to their original |
89 // (non-busy, unlocked state). | 89 // (non-busy, unlocked state). |
90 MojoResult MarkBusyAndStartTransport( | 90 MojoResult MarkBusyAndStartTransport( |
91 MojoHandle disallowed_handle, | 91 MojoHandle disallowed_handle, |
92 const MojoHandle* handle_values, | 92 const MojoHandle* handle_values, |
93 uint32_t num_handles, | 93 uint32_t num_handles, |
94 std::vector<DispatcherTransport>* transports); | 94 std::vector<HandleTransport>* transports); |
95 | 95 |
96 // 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 |
97 // have previously been marked busy by |MarkBusyAndStartTransport()|. | 97 // have previously been marked busy by |MarkBusyAndStartTransport()|. |
98 void RemoveBusyHandles(const MojoHandle* handle_values, uint32_t num_handles); | 98 void RemoveBusyHandles(const MojoHandle* handle_values, uint32_t num_handles); |
99 | 99 |
100 // 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 |
101 // should have previously been marked busy by |MarkBusyAndStartTransport()|, | 101 // should have previously been marked busy by |MarkBusyAndStartTransport()|, |
102 // to a non-busy state. | 102 // to a non-busy state. |
103 void RestoreBusyHandles(const MojoHandle* handle_values, | 103 void RestoreBusyHandles(const MojoHandle* handle_values, |
104 uint32_t num_handles); | 104 uint32_t num_handles); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 HandleToEntryMap handle_to_entry_map_; | 141 HandleToEntryMap handle_to_entry_map_; |
142 MojoHandle next_handle_value_; // Invariant: never |MOJO_HANDLE_INVALID|. | 142 MojoHandle next_handle_value_; // Invariant: never |MOJO_HANDLE_INVALID|. |
143 | 143 |
144 MOJO_DISALLOW_COPY_AND_ASSIGN(HandleTable); | 144 MOJO_DISALLOW_COPY_AND_ASSIGN(HandleTable); |
145 }; | 145 }; |
146 | 146 |
147 } // namespace system | 147 } // namespace system |
148 } // namespace mojo | 148 } // namespace mojo |
149 | 149 |
150 #endif // MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ | 150 #endif // MOJO_EDK_SYSTEM_HANDLE_TABLE_H_ |
OLD | NEW |