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

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

Issue 2750373002: Revert of Mojo: Armed Watchers (Closed)
Patch Set: Created 3 years, 9 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/public/cpp/bindings/lib/binding_state.cc ('k') | mojo/public/cpp/bindings/lib/interface_ptr_state.h » ('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 ff9867a27c5004b6c216698c3027964ef205321f..4426defa934cd0362ecc2eec712730a55dbf04a9 100644
--- a/mojo/public/cpp/bindings/lib/connector.cc
+++ b/mojo/public/cpp/bindings/lib/connector.cc
@@ -188,12 +188,6 @@
}
}
-void Connector::EnableNestedDispatch(bool enabled) {
- nested_dispatch_enabled_ = enabled;
- handle_watcher_.reset();
- WaitToReadMore();
-}
-
void Connector::OnWatcherHandleReady(MojoResult result) {
OnHandleReadyInternal(result);
}
@@ -217,7 +211,6 @@
HandleError(result != MOJO_RESULT_FAILED_PRECONDITION, false);
return;
}
-
ReadAllAvailableMessages();
// At this point, this object might have been deleted. Return.
}
@@ -226,11 +219,10 @@
CHECK(!paused_);
DCHECK(!handle_watcher_);
- handle_watcher_.reset(new SimpleWatcher(
- FROM_HERE, SimpleWatcher::ArmingPolicy::MANUAL, task_runner_));
+ handle_watcher_.reset(new Watcher(FROM_HERE, task_runner_));
if (heap_profiler_tag_)
handle_watcher_->set_heap_profiler_tag(heap_profiler_tag_);
- MojoResult rv = handle_watcher_->Watch(
+ MojoResult rv = handle_watcher_->Start(
message_pipe_.get(), MOJO_HANDLE_SIGNAL_READABLE,
base::Bind(&Connector::OnWatcherHandleReady, base::Unretained(this)));
@@ -240,8 +232,6 @@
task_runner_->PostTask(
FROM_HERE,
base::Bind(&Connector::OnWatcherHandleReady, weak_self_, rv));
- } else {
- handle_watcher_->ArmOrNotify();
}
if (allow_woken_up_by_others_) {
@@ -263,13 +253,6 @@
const MojoResult rv = ReadMessage(message_pipe_.get(), &message);
*read_result = rv;
- if (nested_dispatch_enabled_) {
- // When supporting nested dispatch, we have to rearm the Watcher immediately
- // after reading each message (i.e. before dispatch) to ensure that the next
- // inbound message can trigger OnHandleReady on the nested loop.
- handle_watcher_->ArmOrNotify();
- }
-
if (rv == MOJO_RESULT_OK) {
receiver_result =
incoming_receiver_ && incoming_receiver_->Accept(&message);
@@ -295,36 +278,19 @@
void Connector::ReadAllAvailableMessages() {
while (!error_) {
- base::WeakPtr<Connector> weak_self = weak_self_;
MojoResult rv;
- // May delete |this.|
- if (!ReadSingleMessage(&rv))
+ if (!ReadSingleMessage(&rv)) {
+ // Return immediately without touching any members. |this| may have been
+ // destroyed.
return;
-
- if (!weak_self || paused_)
+ }
+
+ if (paused_)
return;
- DCHECK(rv == MOJO_RESULT_OK || rv == MOJO_RESULT_SHOULD_WAIT);
-
- if (rv == MOJO_RESULT_SHOULD_WAIT) {
- // Attempt to re-arm the Watcher.
- MojoResult ready_result;
- MojoResult arm_result = handle_watcher_->Arm(&ready_result);
- if (arm_result == MOJO_RESULT_OK)
- return;
-
- // The watcher is already ready to notify again.
- DCHECK_EQ(MOJO_RESULT_FAILED_PRECONDITION, arm_result);
-
- if (ready_result == MOJO_RESULT_FAILED_PRECONDITION) {
- HandleError(false, false);
- return;
- }
-
- // There's more to read now, so we'll just keep looping.
- DCHECK_EQ(MOJO_RESULT_OK, ready_result);
- }
+ if (rv == MOJO_RESULT_SHOULD_WAIT)
+ break;
}
}
« no previous file with comments | « mojo/public/cpp/bindings/lib/binding_state.cc ('k') | mojo/public/cpp/bindings/lib/interface_ptr_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698