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

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

Issue 2052553002: Add Core::ReplaceHandleWithReducedRights(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/core_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 UserPointer<MojoHandleRights> rights) { 179 UserPointer<MojoHandleRights> rights) {
180 Handle h; 180 Handle h;
181 MojoResult result = GetHandle(handle, &h); 181 MojoResult result = GetHandle(handle, &h);
182 if (result != MOJO_RESULT_OK) 182 if (result != MOJO_RESULT_OK)
183 return result; 183 return result;
184 184
185 rights.Put(h.rights); 185 rights.Put(h.rights);
186 return MOJO_RESULT_OK; 186 return MOJO_RESULT_OK;
187 } 187 }
188 188
189 MojoResult Core::ReplaceHandleWithReducedRights(
190 MojoHandle handle,
191 MojoHandleRights rights_to_remove,
192 UserPointer<MojoHandle> replacement_handle) {
193 if (handle == MOJO_HANDLE_INVALID)
194 return MOJO_RESULT_INVALID_ARGUMENT;
195
196 MojoHandle replacement_handle_value = MOJO_HANDLE_INVALID;
197 {
198 MutexLocker locker(&handle_table_mutex_);
199 MojoResult result = handle_table_.ReplaceHandleWithReducedRights(
200 handle, rights_to_remove, &replacement_handle_value);
201 if (result != MOJO_RESULT_OK)
202 return result;
203 }
204 DCHECK_NE(replacement_handle_value, MOJO_HANDLE_INVALID);
205
206 replacement_handle.Put(replacement_handle_value);
207 return MOJO_RESULT_OK;
208 }
209
189 MojoResult Core::DuplicateHandleWithReducedRights( 210 MojoResult Core::DuplicateHandleWithReducedRights(
190 MojoHandle handle, 211 MojoHandle handle,
191 MojoHandleRights rights_to_remove, 212 MojoHandleRights rights_to_remove,
192 UserPointer<MojoHandle> new_handle) { 213 UserPointer<MojoHandle> new_handle) {
193 Handle h; 214 Handle h;
194 MojoResult result = GetHandle(handle, &h); 215 MojoResult result = GetHandle(handle, &h);
195 if (result != MOJO_RESULT_OK) 216 if (result != MOJO_RESULT_OK)
196 return result; 217 return result;
197 218
198 if (!h.has_all_rights(MOJO_HANDLE_RIGHT_DUPLICATE)) 219 if (!h.has_all_rights(MOJO_HANDLE_RIGHT_DUPLICATE))
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 if (signals_states) { 812 if (signals_states) {
792 for (; i < num_handles; i++) 813 for (; i < num_handles; i++)
793 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); 814 signals_states[i] = dispatchers[i]->GetHandleSignalsState();
794 } 815 }
795 816
796 return result; 817 return result;
797 } 818 }
798 819
799 } // namespace system 820 } // namespace system
800 } // namespace mojo 821 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/core_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698