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

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

Issue 62773003: Mojo: Add BindingsSupportImpl on top of HandleWatcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows fix. Created 7 years, 1 month 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/bindings/lib/connector.cc
diff --git a/mojo/public/bindings/lib/connector.cc b/mojo/public/bindings/lib/connector.cc
index 3bb04f9fff9c969f54cb69fd19b268cbe1c43f68..804b1b2e40cddf414617bc7c53f467f1b0712f7d 100644
--- a/mojo/public/bindings/lib/connector.cc
+++ b/mojo/public/bindings/lib/connector.cc
@@ -20,10 +20,6 @@ Connector::Connector(Handle message_pipe)
}
Connector::~Connector() {
- if (read_callback_.IsPending())
- read_callback_.Cancel();
- if (write_callback_.IsPending())
- write_callback_.Cancel();
}
void Connector::SetIncomingReceiver(MessageReceiver* receiver) {
@@ -51,24 +47,18 @@ void Connector::OnHandleReady(Callback* callback, MojoResult result) {
void Connector::WaitToReadMore() {
read_callback_.SetOwnerToNotify(this);
-
- bool ok = BindingsSupport::Get()->AsyncWait(message_pipe_,
- MOJO_WAIT_FLAG_READABLE,
- MOJO_DEADLINE_INDEFINITE,
- &read_callback_);
- if (!ok)
- error_ = true;
+ read_callback_.SetAsyncWaitID(
+ BindingsSupport::Get()->AsyncWait(message_pipe_,
+ MOJO_WAIT_FLAG_READABLE,
+ &read_callback_));
}
void Connector::WaitToWriteMore() {
write_callback_.SetOwnerToNotify(this);
-
- bool ok = BindingsSupport::Get()->AsyncWait(message_pipe_,
- MOJO_WAIT_FLAG_WRITABLE,
- MOJO_DEADLINE_INDEFINITE,
- &write_callback_);
- if (!ok)
- error_ = true;
+ write_callback_.SetAsyncWaitID(
+ BindingsSupport::Get()->AsyncWait(message_pipe_,
+ MOJO_WAIT_FLAG_WRITABLE,
+ &write_callback_));
}
void Connector::ReadMore() {
@@ -135,12 +125,13 @@ void Connector::WriteMore() {
// ----------------------------------------------------------------------------
Connector::Callback::Callback()
- : owner_(NULL) {
+ : owner_(NULL),
+ async_wait_id_(0) {
}
-void Connector::Callback::Cancel() {
- owner_ = NULL;
- BindingsSupport::Get()->CancelWait(this);
+Connector::Callback::~Callback() {
+ if (owner_)
+ BindingsSupport::Get()->CancelWait(async_wait_id_);
}
void Connector::Callback::SetOwnerToNotify(Connector* owner) {
@@ -148,8 +139,8 @@ void Connector::Callback::SetOwnerToNotify(Connector* owner) {
owner_ = owner;
}
-bool Connector::Callback::IsPending() const {
- return owner_ != NULL;
+void Connector::Callback::SetAsyncWaitID(BindingsSupport::AsyncWaitID id) {
+ async_wait_id_ = id;
}
void Connector::Callback::OnHandleReady(MojoResult result) {

Powered by Google App Engine
This is Rietveld 408576698