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

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

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: rebase Created 3 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
Index: mojo/public/cpp/bindings/connector.h
diff --git a/mojo/public/cpp/bindings/connector.h b/mojo/public/cpp/bindings/connector.h
index 01e923679cd6d62ee83c34096c845504737f4168..fdfeb7344d00675dd06c6e8bdf949ddc9e83a9a2 100644
--- a/mojo/public/cpp/bindings/connector.h
+++ b/mojo/public/cpp/bindings/connector.h
@@ -18,7 +18,7 @@
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/sync_handle_watcher.h"
#include "mojo/public/cpp/system/core.h"
-#include "mojo/public/cpp/system/watcher.h"
+#include "mojo/public/cpp/system/simple_watcher.h"
namespace base {
class Lock;
@@ -155,8 +155,14 @@ class MOJO_CPP_BINDINGS_EXPORT Connector
// |tag| must be a const string literal.
void SetWatcherHeapProfilerTag(const char* tag);
+ // Enables support for nested message dispatch so that the Connector can
+ // continue dispatching inbound messages even if one of them spins a nested
+ // message loop. This should be enabled only when needed, as dispatch in this
+ // mode is generally less efficient.
+ void EnableNestedDispatch(bool enabled);
+
private:
- // Callback of mojo::Watcher.
+ // Callback of mojo::SimpleWatcher.
void OnWatcherHandleReady(MojoResult result);
// Callback of SyncHandleWatcher.
void OnSyncHandleWatcherHandleReady(MojoResult result);
@@ -188,7 +194,7 @@ class MOJO_CPP_BINDINGS_EXPORT Connector
MessageReceiver* incoming_receiver_ = nullptr;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
- std::unique_ptr<Watcher> handle_watcher_;
+ std::unique_ptr<SimpleWatcher> handle_watcher_;
bool error_ = false;
bool drop_writes_ = false;
@@ -196,6 +202,8 @@ class MOJO_CPP_BINDINGS_EXPORT Connector
bool paused_ = false;
+ bool nested_dispatch_enabled_ = false;
+
// If sending messages is allowed from multiple threads, |lock_| is used to
// protect modifications to |message_pipe_| and |drop_writes_|.
base::Optional<base::Lock> lock_;

Powered by Google App Engine
This is Rietveld 408576698