| Index: mojo/public/cpp/bindings/lib/connector.h
|
| diff --git a/mojo/public/cpp/bindings/lib/connector.h b/mojo/public/cpp/bindings/lib/connector.h
|
| index e00936c111644ee98674f741ebe58e58e09b5181..13235b2ee253dfe1b3acc05c218d15d677713d1c 100644
|
| --- a/mojo/public/cpp/bindings/lib/connector.h
|
| +++ b/mojo/public/cpp/bindings/lib/connector.h
|
| @@ -10,6 +10,7 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "mojo/public/cpp/bindings/callback.h"
|
| +#include "mojo/public/cpp/bindings/lib/sync_handle_watcher.h"
|
| #include "mojo/public/cpp/bindings/message.h"
|
| #include "mojo/public/cpp/system/core.h"
|
| #include "mojo/public/cpp/system/watcher.h"
|
| @@ -119,20 +120,18 @@ class Connector : public MessageReceiver {
|
| return message_pipe_.get();
|
| }
|
|
|
| - // Requests to register |message_pipe_| with SyncHandleWatcher whenever this
|
| - // instance is expecting incoming messages.
|
| - //
|
| - // Please note that UnregisterSyncHandleWatch() needs to be called as many
|
| - // times as successful RegisterSyncHandleWatch() calls in order to cancel the
|
| - // effect.
|
| - bool RegisterSyncHandleWatch();
|
| - void UnregisterSyncHandleWatch();
|
| -
|
| - // Watches all handles registered with SyncHandleWatcher on the same thread.
|
| - // The method returns true when |*should_stop| is set to true; returns false
|
| - // when any failure occurs during the watch, including |message_pipe_| is
|
| - // closed.
|
| - bool RunSyncHandleWatch(const bool* should_stop);
|
| + // Allows |message_pipe_| be watched while others perform sync handle watching
|
| + // on the same thread. Please see comments of
|
| + // SyncHandleWatcher::AllowWokenUpBySyncWatchOnSameThread().
|
| + void AllowWokenUpBySyncWatchOnSameThread();
|
| +
|
| + // Watches |message_pipe_| (as well as other handles registered to be watched
|
| + // together) synchronously.
|
| + // This method:
|
| + // - returns true when |should_stop| is set to true;
|
| + // - return false when any error occurs, including |message_pipe_| being
|
| + // closed.
|
| + bool SyncWatch(const bool* should_stop);
|
|
|
| // Whether currently the control flow is inside the sync handle watcher
|
| // callback.
|
| @@ -164,6 +163,8 @@ class Connector : public MessageReceiver {
|
| // Cancels any calls made to |waiter_|.
|
| void CancelWait();
|
|
|
| + void EnsureSyncWatcherExists();
|
| +
|
| Closure connection_error_handler_;
|
|
|
| ScopedMessagePipeHandle message_pipe_;
|
| @@ -181,14 +182,11 @@ class Connector : public MessageReceiver {
|
| // protect modifications to |message_pipe_| and |drop_writes_|.
|
| scoped_ptr<base::Lock> lock_;
|
|
|
| - // If non-zero, |message_pipe_| should be registered with SyncHandleWatcher.
|
| - size_t register_sync_handle_watch_count_;
|
| - // Whether |message_pipe_| has been registered with SyncHandleWatcher.
|
| - bool registered_with_sync_handle_watcher_;
|
| + scoped_ptr<SyncHandleWatcher> sync_watcher_;
|
| + bool allow_woken_up_by_others_;
|
| // If non-zero, currently the control flow is inside the sync handle watcher
|
| // callback.
|
| size_t sync_handle_watcher_callback_count_;
|
| - scoped_refptr<base::RefCountedData<bool>> should_stop_sync_handle_watch_;
|
|
|
| base::ThreadChecker thread_checker_;
|
|
|
|
|