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

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

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 10 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..5ba5d632c86c1f2431100913ec2a8ba62320a761 100644
--- a/mojo/public/cpp/bindings/connector.h
+++ b/mojo/public/cpp/bindings/connector.h
@@ -15,6 +15,7 @@
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/bindings_export.h"
+#include "mojo/public/cpp/bindings/lib/destruction_tracker.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/sync_handle_watcher.h"
#include "mojo/public/cpp/system/core.h"
@@ -155,6 +156,12 @@ 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.
void OnWatcherHandleReady(MojoResult result);
@@ -196,6 +203,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_;
@@ -211,6 +220,8 @@ class MOJO_CPP_BINDINGS_EXPORT Connector
base::Lock connected_lock_;
bool connected_ = true;
+ DestructionTracker destruction_tracker_;
+
// The tag used to track heap allocations that originated from a Watcher
// notification.
const char* heap_profiler_tag_ = nullptr;

Powered by Google App Engine
This is Rietveld 408576698