| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |