OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "mojo/edk/system/core.h" | 5 #include "mojo/edk/system/core.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 MojoResult Core::GetHandle(MojoHandle handle, Handle* h) { | 100 MojoResult Core::GetHandle(MojoHandle handle, Handle* h) { |
101 if (handle == MOJO_HANDLE_INVALID) | 101 if (handle == MOJO_HANDLE_INVALID) |
102 return MOJO_RESULT_INVALID_ARGUMENT; | 102 return MOJO_RESULT_INVALID_ARGUMENT; |
103 | 103 |
104 MutexLocker locker(&handle_table_mutex_); | 104 MutexLocker locker(&handle_table_mutex_); |
105 return handle_table_.GetHandle(handle, h); | 105 return handle_table_.GetHandle(handle, h); |
106 } | 106 } |
107 | 107 |
108 MojoResult Core::GetAndRemoveDispatcher(MojoHandle handle, | 108 MojoResult Core::GetAndRemoveHandle(MojoHandle handle, Handle* h) { |
109 RefPtr<Dispatcher>* dispatcher) { | |
110 if (handle == MOJO_HANDLE_INVALID) | 109 if (handle == MOJO_HANDLE_INVALID) |
111 return MOJO_RESULT_INVALID_ARGUMENT; | 110 return MOJO_RESULT_INVALID_ARGUMENT; |
112 | 111 |
113 MutexLocker locker(&handle_table_mutex_); | 112 MutexLocker locker(&handle_table_mutex_); |
114 Handle h; | 113 return handle_table_.GetAndRemoveHandle(handle, h); |
115 MojoResult result = handle_table_.GetAndRemoveHandle(handle, &h); | |
116 if (result == MOJO_RESULT_OK) | |
117 *dispatcher = std::move(h.dispatcher); | |
118 return result; | |
119 } | 114 } |
120 | 115 |
121 MojoResult Core::GetDispatcherAndCheckRights( | 116 MojoResult Core::GetDispatcherAndCheckRights( |
122 MojoHandle handle, | 117 MojoHandle handle, |
123 MojoHandleRights required_handle_rights, | 118 MojoHandleRights required_handle_rights, |
124 EntrypointClass entrypoint_class, | 119 EntrypointClass entrypoint_class, |
125 util::RefPtr<Dispatcher>* dispatcher) { | 120 util::RefPtr<Dispatcher>* dispatcher) { |
126 if (handle == MOJO_HANDLE_INVALID) | 121 if (handle == MOJO_HANDLE_INVALID) |
127 return MOJO_RESULT_INVALID_ARGUMENT; | 122 return MOJO_RESULT_INVALID_ARGUMENT; |
128 | 123 |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 if (signals_states) { | 748 if (signals_states) { |
754 for (; i < num_handles; i++) | 749 for (; i < num_handles; i++) |
755 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); | 750 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); |
756 } | 751 } |
757 | 752 |
758 return result; | 753 return result; |
759 } | 754 } |
760 | 755 |
761 } // namespace system | 756 } // namespace system |
762 } // namespace mojo | 757 } // namespace mojo |
OLD | NEW |