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

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

Issue 1832193002: Mojo C++ bindings: refactor SyncHandleWatcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « mojo/public/cpp/bindings/BUILD.gn ('k') | mojo/public/cpp/bindings/lib/connector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « mojo/public/cpp/bindings/BUILD.gn ('k') | mojo/public/cpp/bindings/lib/connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698