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

Unified Diff: mojo/message_pump/message_pump_mojo.cc

Issue 1573383002: Couple of small cleanups to MessagePumpMojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/message_pump/message_pump_mojo.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/message_pump/message_pump_mojo.cc
diff --git a/mojo/message_pump/message_pump_mojo.cc b/mojo/message_pump/message_pump_mojo.cc
index 3f60dd7116d9744411263ad6452563e148ee0990..112b37ec3352668e2fe3379b7e3147e847b810eb 100644
--- a/mojo/message_pump/message_pump_mojo.cc
+++ b/mojo/message_pump/message_pump_mojo.cc
@@ -295,7 +295,7 @@ bool MessagePumpMojo::ProcessReadyHandles() {
// EDK staying alive. So quit manually to avoid this thread hanging.
Quit();
} else {
- RemoveInvalidHandle(handle_results[i], handle);
+ SignalHandleError(handle, handle_results[i]);
}
break;
case MOJO_RESULT_OK:
@@ -319,23 +319,6 @@ bool MessagePumpMojo::ProcessReadyHandles() {
return true;
}
-void MessagePumpMojo::RemoveInvalidHandle(MojoResult result, Handle handle) {
- // TODO(sky): deal with control pipe going bad.
- CHECK(result == MOJO_RESULT_FAILED_PRECONDITION ||
- result == MOJO_RESULT_CANCELLED ||
- result == MOJO_RESULT_DEADLINE_EXCEEDED);
- // Indicates the control pipe went bad.
- CHECK_NE(handle.value(), read_handle_.get().value());
-
- auto it = handlers_.find(handle);
- CHECK(it != handlers_.end());
- MessagePumpMojoHandler* handler = it->second.handler;
- RemoveHandler(handle);
- WillSignalHandler();
- handler->OnHandleError(handle, result);
- DidSignalHandler();
-}
-
bool MessagePumpMojo::RemoveExpiredHandles() {
bool removed = false;
// Notify and remove any handlers whose time has expired. First, iterate over
@@ -358,11 +341,7 @@ bool MessagePumpMojo::RemoveExpiredHandles() {
// Don't need to check deadline again since it can't change if id hasn't
// changed.
if (it != handlers_.end() && it->second.id == pair.second) {
- MessagePumpMojoHandler* handler = it->second.handler;
- RemoveHandler(pair.first);
- WillSignalHandler();
- handler->OnHandleError(pair.first, MOJO_RESULT_DEADLINE_EXCEEDED);
- DidSignalHandler();
+ SignalHandleError(pair.first, MOJO_RESULT_DEADLINE_EXCEEDED);
removed = true;
}
}
@@ -398,9 +377,23 @@ MojoDeadline MessagePumpMojo::GetDeadlineForWait(
}
void MessagePumpMojo::SignalHandleReady(Handle handle) {
- DCHECK(handlers_.find(handle) != handlers_.end());
+ auto it = handlers_.find(handle);
+ DCHECK(it != handlers_.end());
+ MessagePumpMojoHandler* handler = it->second.handler;
+
+ WillSignalHandler();
+ handler->OnHandleReady(handle);
+ DidSignalHandler();
+}
+
+void MessagePumpMojo::SignalHandleError(Handle handle, MojoResult result) {
+ auto it = handlers_.find(handle);
+ DCHECK(it != handlers_.end());
+ MessagePumpMojoHandler* handler = it->second.handler;
+
+ RemoveHandler(handle);
WillSignalHandler();
- handlers_[handle].handler->OnHandleReady(handle);
+ handler->OnHandleError(handle, result);
DidSignalHandler();
}
« no previous file with comments | « mojo/message_pump/message_pump_mojo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698