Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: mojo/edk/system/core.cc

Issue 1957713003: EDK: Remove Core::GetDispatcher(). (Closed) Base URL: https://github.com/domokit/mojo.git@work789_edk_handle_table_14-x-work788_edk_handle_13.9-x-work787_edk_handle_13.8
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::GetDispatcher(MojoHandle handle,
109 RefPtr<Dispatcher>* dispatcher) {
110 Handle h;
111 MojoResult result = GetHandle(handle, &h);
112 if (result == MOJO_RESULT_OK)
113 *dispatcher = std::move(h.dispatcher);
114 return result;
115 }
116
117 MojoResult Core::GetAndRemoveDispatcher(MojoHandle handle, 108 MojoResult Core::GetAndRemoveDispatcher(MojoHandle handle,
118 RefPtr<Dispatcher>* dispatcher) { 109 RefPtr<Dispatcher>* dispatcher) {
119 if (handle == MOJO_HANDLE_INVALID) 110 if (handle == MOJO_HANDLE_INVALID)
120 return MOJO_RESULT_INVALID_ARGUMENT; 111 return MOJO_RESULT_INVALID_ARGUMENT;
121 112
122 MutexLocker locker(&handle_table_mutex_); 113 MutexLocker locker(&handle_table_mutex_);
123 Handle h; 114 Handle h;
124 MojoResult result = handle_table_.GetAndRemoveHandle(handle, &h); 115 MojoResult result = handle_table_.GetAndRemoveHandle(handle, &h);
125 if (result == MOJO_RESULT_OK) 116 if (result == MOJO_RESULT_OK)
126 *dispatcher = std::move(h.dispatcher); 117 *dispatcher = std::move(h.dispatcher);
127 return result; 118 return result;
128 } 119 }
129 120
130 MojoResult Core::GetDispatcherAndCheckRights( 121 MojoResult Core::GetDispatcherAndCheckRights(
131 MojoHandle handle, 122 MojoHandle handle,
132 MojoHandleRights required_handle_rights, 123 MojoHandleRights required_handle_rights,
133 EntrypointClass entrypoint_class, 124 EntrypointClass entrypoint_class,
134 util::RefPtr<Dispatcher>* dispatcher) { 125 util::RefPtr<Dispatcher>* dispatcher) {
135 if (handle == MOJO_HANDLE_INVALID) 126 if (handle == MOJO_HANDLE_INVALID)
136 return MOJO_RESULT_INVALID_ARGUMENT; 127 return MOJO_RESULT_INVALID_ARGUMENT;
137 128
138 Handle h; 129 Handle h;
139 MojoResult result = GetHandle(handle, &h); 130 MojoResult result = GetHandle(handle, &h);
140 if (result != MOJO_RESULT_OK) 131 if (result != MOJO_RESULT_OK)
141 return result; 132 return result;
142 133
143 if ((h.rights & required_handle_rights) != required_handle_rights) { 134 if (!h.has_all_rights(required_handle_rights)) {
144 return h.dispatcher->SupportsEntrypointClass(entrypoint_class) 135 return h.dispatcher->SupportsEntrypointClass(entrypoint_class)
145 ? MOJO_RESULT_PERMISSION_DENIED 136 ? MOJO_RESULT_PERMISSION_DENIED
146 : MOJO_RESULT_INVALID_ARGUMENT; 137 : MOJO_RESULT_INVALID_ARGUMENT;
147 } 138 }
148 139
149 *dispatcher = std::move(h.dispatcher); 140 *dispatcher = std::move(h.dispatcher);
150 return MOJO_RESULT_OK; 141 return MOJO_RESULT_OK;
151 } 142 }
152 143
153 MojoResult Core::AsyncWait(MojoHandle handle, 144 MojoResult Core::AsyncWait(MojoHandle handle,
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 MojoHandle buffer_handle, 608 MojoHandle buffer_handle,
618 UserPointer<const MojoDuplicateBufferHandleOptions> options, 609 UserPointer<const MojoDuplicateBufferHandleOptions> options,
619 UserPointer<MojoHandle> new_buffer_handle) { 610 UserPointer<MojoHandle> new_buffer_handle) {
620 // TODO(vtl): This is a big ugly and duplicates some code, but the plan is to 611 // TODO(vtl): This is a big ugly and duplicates some code, but the plan is to
621 // remove this method anyway. 612 // remove this method anyway.
622 Handle h; 613 Handle h;
623 MojoResult result = GetHandle(buffer_handle, &h); 614 MojoResult result = GetHandle(buffer_handle, &h);
624 if (result != MOJO_RESULT_OK) 615 if (result != MOJO_RESULT_OK)
625 return result; 616 return result;
626 617
627 if (!(h.rights & MOJO_HANDLE_RIGHT_DUPLICATE)) { 618 if (!h.has_all_rights(MOJO_HANDLE_RIGHT_DUPLICATE)) {
628 return h.dispatcher->SupportsEntrypointClass(EntrypointClass::BUFFER) 619 return h.dispatcher->SupportsEntrypointClass(EntrypointClass::BUFFER)
629 ? MOJO_RESULT_PERMISSION_DENIED 620 ? MOJO_RESULT_PERMISSION_DENIED
630 : MOJO_RESULT_INVALID_ARGUMENT; 621 : MOJO_RESULT_INVALID_ARGUMENT;
631 } 622 }
632 623
633 // Don't verify |options| here; that's the dispatcher's job. 624 // Don't verify |options| here; that's the dispatcher's job.
634 RefPtr<Dispatcher> new_dispatcher; 625 RefPtr<Dispatcher> new_dispatcher;
635 result = h.dispatcher->DuplicateBufferHandle(options, &new_dispatcher); 626 result = h.dispatcher->DuplicateBufferHandle(options, &new_dispatcher);
636 if (result != MOJO_RESULT_OK) 627 if (result != MOJO_RESULT_OK)
637 return result; 628 return result;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 if (signals_states) { 753 if (signals_states) {
763 for (; i < num_handles; i++) 754 for (; i < num_handles; i++)
764 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); 755 signals_states[i] = dispatchers[i]->GetHandleSignalsState();
765 } 756 }
766 757
767 return result; 758 return result;
768 } 759 }
769 760
770 } // namespace system 761 } // namespace system
771 } // namespace mojo 762 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698