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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/core.cc
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
index 7780977918dd5afa9547c44bf01141101c80a564..1eff33b1ed96e1112164e3dddc5083d17a4dcc0b 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -186,6 +186,27 @@ MojoResult Core::GetRights(MojoHandle handle,
return MOJO_RESULT_OK;
}
+MojoResult Core::ReplaceHandleWithReducedRights(
+ MojoHandle handle,
+ MojoHandleRights rights_to_remove,
+ UserPointer<MojoHandle> replacement_handle) {
+ if (handle == MOJO_HANDLE_INVALID)
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ MojoHandle replacement_handle_value = MOJO_HANDLE_INVALID;
+ {
+ MutexLocker locker(&handle_table_mutex_);
+ MojoResult result = handle_table_.ReplaceHandleWithReducedRights(
+ handle, rights_to_remove, &replacement_handle_value);
+ if (result != MOJO_RESULT_OK)
+ return result;
+ }
+ DCHECK_NE(replacement_handle_value, MOJO_HANDLE_INVALID);
+
+ replacement_handle.Put(replacement_handle_value);
+ return MOJO_RESULT_OK;
+}
+
MojoResult Core::DuplicateHandleWithReducedRights(
MojoHandle handle,
MojoHandleRights rights_to_remove,
« 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