Index: mojo/public/bindings/lib/connector.cc |
diff --git a/mojo/public/bindings/lib/connector.cc b/mojo/public/bindings/lib/connector.cc |
index f72bca36ab7104e9c5e8649be2d50378111b9356..31855368b5e8eba6d9828ca873e4cdb9498f26b5 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) { |
@@ -58,24 +54,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() { |
@@ -140,7 +130,7 @@ void Connector::WriteOne(Message* message, bool* wait_to_write) { |
MojoResult rv = WriteMessage(message_pipe_, |
message->data, |
message->data->header.num_bytes, |
- message->handles.data(), |
+ &message->handles[0], |
static_cast<uint32_t>(message->handles.size()), |
MOJO_WRITE_MESSAGE_FLAG_NONE); |
if (rv == MOJO_RESULT_OK) { |
@@ -155,12 +145,13 @@ void Connector::WriteOne(Message* message, bool* wait_to_write) { |
// ---------------------------------------------------------------------------- |
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) { |
@@ -168,8 +159,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) { |