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

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

Issue 69283002: Revert "Mojo: Add BindingsSupportImpl on top of HandleWatcher" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « mojo/public/bindings/lib/connector.h ('k') | mojo/public/tests/simple_bindings_support.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/lib/connector.cc
diff --git a/mojo/public/bindings/lib/connector.cc b/mojo/public/bindings/lib/connector.cc
index 31855368b5e8eba6d9828ca873e4cdb9498f26b5..f72bca36ab7104e9c5e8649be2d50378111b9356 100644
--- a/mojo/public/bindings/lib/connector.cc
+++ b/mojo/public/bindings/lib/connector.cc
@@ -20,6 +20,10 @@ 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) {
@@ -54,18 +58,24 @@ void Connector::OnHandleReady(Callback* callback, MojoResult result) {
void Connector::WaitToReadMore() {
read_callback_.SetOwnerToNotify(this);
- read_callback_.SetAsyncWaitID(
- BindingsSupport::Get()->AsyncWait(message_pipe_,
- MOJO_WAIT_FLAG_READABLE,
- &read_callback_));
+
+ bool ok = BindingsSupport::Get()->AsyncWait(message_pipe_,
+ MOJO_WAIT_FLAG_READABLE,
+ MOJO_DEADLINE_INDEFINITE,
+ &read_callback_);
+ if (!ok)
+ error_ = true;
}
void Connector::WaitToWriteMore() {
write_callback_.SetOwnerToNotify(this);
- write_callback_.SetAsyncWaitID(
- BindingsSupport::Get()->AsyncWait(message_pipe_,
- MOJO_WAIT_FLAG_WRITABLE,
- &write_callback_));
+
+ bool ok = BindingsSupport::Get()->AsyncWait(message_pipe_,
+ MOJO_WAIT_FLAG_WRITABLE,
+ MOJO_DEADLINE_INDEFINITE,
+ &write_callback_);
+ if (!ok)
+ error_ = true;
}
void Connector::ReadMore() {
@@ -130,7 +140,7 @@ void Connector::WriteOne(Message* message, bool* wait_to_write) {
MojoResult rv = WriteMessage(message_pipe_,
message->data,
message->data->header.num_bytes,
- &message->handles[0],
+ message->handles.data(),
static_cast<uint32_t>(message->handles.size()),
MOJO_WRITE_MESSAGE_FLAG_NONE);
if (rv == MOJO_RESULT_OK) {
@@ -145,13 +155,12 @@ void Connector::WriteOne(Message* message, bool* wait_to_write) {
// ----------------------------------------------------------------------------
Connector::Callback::Callback()
- : owner_(NULL),
- async_wait_id_(0) {
+ : owner_(NULL) {
}
-Connector::Callback::~Callback() {
- if (owner_)
- BindingsSupport::Get()->CancelWait(async_wait_id_);
+void Connector::Callback::Cancel() {
+ owner_ = NULL;
+ BindingsSupport::Get()->CancelWait(this);
}
void Connector::Callback::SetOwnerToNotify(Connector* owner) {
@@ -159,8 +168,8 @@ void Connector::Callback::SetOwnerToNotify(Connector* owner) {
owner_ = owner;
}
-void Connector::Callback::SetAsyncWaitID(BindingsSupport::AsyncWaitID id) {
- async_wait_id_ = id;
+bool Connector::Callback::IsPending() const {
+ return owner_ != NULL;
}
void Connector::Callback::OnHandleReady(MojoResult result) {
« no previous file with comments | « mojo/public/bindings/lib/connector.h ('k') | mojo/public/tests/simple_bindings_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698