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

Unified Diff: mojo/public/cpp/bindings/lib/connector.cc

Issue 1576603002: Makes bindings work with nested message loops (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment 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 | « no previous file | mojo/public/cpp/bindings/lib/message.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/connector.cc
diff --git a/mojo/public/cpp/bindings/lib/connector.cc b/mojo/public/cpp/bindings/lib/connector.cc
index 854a80cd740c18568c93eaa6ac899e04fce4dd74..ceccaa9a109128d0d64d13c82165702beccec1aa 100644
--- a/mojo/public/cpp/bindings/lib/connector.cc
+++ b/mojo/public/cpp/bindings/lib/connector.cc
@@ -231,16 +231,28 @@ bool Connector::ReadSingleMessage(MojoResult* read_result) {
bool* previous_destroyed_flag = destroyed_flag_;
destroyed_flag_ = &was_destroyed_during_dispatch;
- MojoResult rv = ReadAndDispatchMessage(
- message_pipe_.get(), incoming_receiver_, &receiver_result);
- if (read_result)
- *read_result = rv;
+ Message message;
+ const MojoResult rv = ReadMessage(message_pipe_.get(), &message);
+ *read_result = rv;
+
+ if (rv == MOJO_RESULT_OK) {
+ // Dispatching the message may spin in a nested message loop. To ensure we
+ // continue dispatching messages when this happens start listening for
+ // messagse now.
+ if (!async_wait_id_) {
+ // TODO: Need to evaluate the perf impact of this.
+ WaitToReadMore();
+ }
+ receiver_result =
+ incoming_receiver_ && incoming_receiver_->Accept(&message);
+ }
if (was_destroyed_during_dispatch) {
if (previous_destroyed_flag)
*previous_destroyed_flag = true; // Propagate flag.
return false;
}
+
destroyed_flag_ = previous_destroyed_flag;
if (rv == MOJO_RESULT_SHOULD_WAIT)
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698