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

Unified Diff: mojo/edk/system/core.cc

Issue 1949283002: EDK: Replace HandleTable::GetAndRemoveDispatcher() with GetAndRemoveHandle(). (Closed) Base URL: https://github.com/domokit/mojo.git@work789_edk_handle_13.3-x-work788_edk_handle_13.2
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/handle.h » ('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 039158563d838f88c9bf39c84d138ae9e1259fda..1c89dd21b58b18a62130e4ce6334f9ac18f1400e 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -98,26 +98,30 @@ MojoHandle Core::AddHandle(Handle&& handle) {
return handle_table_.AddHandle(std::move(handle));
}
-MojoResult Core::GetDispatcher(MojoHandle handle_value,
+MojoResult Core::GetDispatcher(MojoHandle handle,
RefPtr<Dispatcher>* dispatcher) {
- if (handle_value == MOJO_HANDLE_INVALID)
+ if (handle == MOJO_HANDLE_INVALID)
return MOJO_RESULT_INVALID_ARGUMENT;
MutexLocker locker(&handle_table_mutex_);
- Handle handle;
- MojoResult rv = handle_table_.GetHandle(handle_value, &handle);
+ Handle h;
+ MojoResult rv = handle_table_.GetHandle(handle, &h);
if (rv == MOJO_RESULT_OK)
- *dispatcher = std::move(handle.dispatcher);
+ *dispatcher = std::move(h.dispatcher);
return rv;
}
-MojoResult Core::GetAndRemoveDispatcher(MojoHandle handle_value,
+MojoResult Core::GetAndRemoveDispatcher(MojoHandle handle,
RefPtr<Dispatcher>* dispatcher) {
- if (handle_value == MOJO_HANDLE_INVALID)
+ if (handle == MOJO_HANDLE_INVALID)
return MOJO_RESULT_INVALID_ARGUMENT;
MutexLocker locker(&handle_table_mutex_);
- return handle_table_.GetAndRemoveDispatcher(handle_value, dispatcher);
+ Handle h;
+ MojoResult rv = handle_table_.GetAndRemoveHandle(handle, &h);
+ if (rv == MOJO_RESULT_OK)
+ *dispatcher = std::move(h.dispatcher);
+ return rv;
}
MojoResult Core::AsyncWait(MojoHandle handle,
@@ -143,11 +147,10 @@ MojoResult Core::Close(MojoHandle handle) {
if (handle == MOJO_HANDLE_INVALID)
return MOJO_RESULT_INVALID_ARGUMENT;
- RefPtr<Dispatcher> dispatcher;
+ Handle h;
{
MutexLocker locker(&handle_table_mutex_);
- MojoResult result =
- handle_table_.GetAndRemoveDispatcher(handle, &dispatcher);
+ MojoResult result = handle_table_.GetAndRemoveHandle(handle, &h);
if (result != MOJO_RESULT_OK)
return result;
}
@@ -156,7 +159,7 @@ MojoResult Core::Close(MojoHandle handle) {
// Note: This is done outside of |handle_table_mutex_|. As a result, there's a
// race condition that the dispatcher must handle; see the comment in
// |Dispatcher| in dispatcher.h.
- return dispatcher->Close();
+ return h.dispatcher->Close();
}
MojoResult Core::Wait(MojoHandle handle,
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698