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

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

Issue 409943003: Makes HandleWatcher block until no longer waiting on pipe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more java fixes Created 6 years, 5 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
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 170c4d71aa30296ecef64b3efe2af494f3506955..6665ff9442a1d078d3554358215ff5a4c424cb4f 100644
--- a/mojo/public/cpp/bindings/lib/connector.cc
+++ b/mojo/public/cpp/bindings/lib/connector.cc
@@ -34,19 +34,16 @@ Connector::~Connector() {
if (destroyed_flag_)
*destroyed_flag_ = true;
- if (async_wait_id_)
- waiter_->CancelWait(async_wait_id_);
+ CancelWait();
}
void Connector::CloseMessagePipe() {
+ CancelWait();
Close(message_pipe_.Pass());
}
ScopedMessagePipeHandle Connector::PassMessagePipe() {
- if (async_wait_id_) {
- waiter_->CancelWait(async_wait_id_);
- async_wait_id_ = 0;
- }
+ CancelWait();
return message_pipe_.Pass();
}
@@ -136,6 +133,7 @@ void Connector::OnHandleReady(MojoResult result) {
}
void Connector::WaitToReadMore() {
+ MOJO_DCHECK(!async_wait_id_);
async_wait_id_ = waiter_->AsyncWait(message_pipe_.get().value(),
MOJO_HANDLE_SIGNAL_READABLE,
MOJO_DEADLINE_INDEFINITE,
@@ -190,6 +188,14 @@ void Connector::ReadAllAvailableMessages() {
}
}
+void Connector::CancelWait() {
+ if (!async_wait_id_)
+ return;
+
+ waiter_->CancelWait(async_wait_id_);
+ async_wait_id_ = 0;
+}
+
void Connector::NotifyError() {
error_ = true;
// The error handler might destroyed |this|. Also, after an error, all method

Powered by Google App Engine
This is Rietveld 408576698