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

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

Issue 2608163003: Change single-interface mojo bindings to use SequencedTaskRunner. (Closed)
Patch Set: Created 3 years, 11 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/lib/multiplex_router.h
diff --git a/mojo/public/cpp/bindings/lib/multiplex_router.h b/mojo/public/cpp/bindings/lib/multiplex_router.h
index c1e02984401bf5e6671e9793fc5e4f680da7190a..b378f2df3c9ad0c99acbcd32b01ec19aa749c35d 100644
--- a/mojo/public/cpp/bindings/lib/multiplex_router.h
+++ b/mojo/public/cpp/bindings/lib/multiplex_router.h
@@ -17,9 +17,9 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "base/single_thread_task_runner.h"
+#include "base/sequence_checker.h"
+#include "base/sequenced_task_runner.h"
#include "base/synchronization/lock.h"
-#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/associated_group_controller.h"
#include "mojo/public/cpp/bindings/bindings_export.h"
#include "mojo/public/cpp/bindings/connector.h"
@@ -32,7 +32,7 @@
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
namespace base {
-class SingleThreadTaskRunner;
+class SequencedTaskRunner;
}
namespace mojo {
@@ -75,7 +75,7 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
MultiplexRouter(ScopedMessagePipeHandle message_pipe,
Config config,
bool set_interface_id_namespace_bit,
- scoped_refptr<base::SingleThreadTaskRunner> runner);
+ scoped_refptr<base::SequencedTaskRunner> runner);
// Sets the master interface name for this router. Only used when reporting
// message header or control message validation errors.
@@ -98,7 +98,7 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
InterfaceEndpointController* AttachEndpointClient(
const ScopedInterfaceEndpointHandle& handle,
InterfaceEndpointClient* endpoint_client,
- scoped_refptr<base::SingleThreadTaskRunner> runner) override;
+ scoped_refptr<base::SequencedTaskRunner> runner) override;
void DetachEndpointClient(
const ScopedInterfaceEndpointHandle& handle) override;
void RaiseError() override;
@@ -113,14 +113,14 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
// Extracts the underlying message pipe.
ScopedMessagePipeHandle PassMessagePipe() {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
DCHECK(!HasAssociatedEndpoints());
return connector_.PassMessagePipe();
}
// Blocks the current thread until the first incoming message, or |deadline|.
bool WaitForIncomingMessage(MojoDeadline deadline) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
return connector_.WaitForIncomingMessage(deadline);
}
@@ -138,13 +138,13 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
// Is the router bound to a message pipe handle?
bool is_valid() const {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
return connector_.is_valid();
}
// TODO(yzshen): consider removing this getter.
MessagePipeHandle handle() const {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
return connector_.handle();
}
@@ -192,7 +192,7 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
// of this object, if direct calls are allowed, the caller needs to hold on to
// a ref outside of |lock_| before calling this method.
void ProcessTasks(ClientCallBehavior client_call_behavior,
- base::SingleThreadTaskRunner* current_task_runner);
+ base::SequencedTaskRunner* current_task_runner);
// Processes the first queued sync message for the endpoint corresponding to
// |id|; returns whether there are more sync messages for that endpoint in the
@@ -203,16 +203,14 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
bool ProcessFirstSyncMessageForEndpoint(InterfaceId id);
// Returns true to indicate that |task|/|message| has been processed.
- bool ProcessNotifyErrorTask(
- Task* task,
- ClientCallBehavior client_call_behavior,
- base::SingleThreadTaskRunner* current_task_runner);
- bool ProcessIncomingMessage(
- Message* message,
- ClientCallBehavior client_call_behavior,
- base::SingleThreadTaskRunner* current_task_runner);
-
- void MaybePostToProcessTasks(base::SingleThreadTaskRunner* task_runner);
+ bool ProcessNotifyErrorTask(Task* task,
+ ClientCallBehavior client_call_behavior,
+ base::SequencedTaskRunner* current_task_runner);
+ bool ProcessIncomingMessage(Message* message,
+ ClientCallBehavior client_call_behavior,
+ base::SequencedTaskRunner* current_task_runner);
+
+ void MaybePostToProcessTasks(base::SequencedTaskRunner* task_runner);
void LockAndCallProcessTasks();
// Updates the state of |endpoint|. If both the endpoint and its peer have
@@ -232,7 +230,7 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
// comments of kInterfaceIdNamespaceMask.
const bool set_interface_id_namespace_bit_;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ scoped_refptr<base::SequencedTaskRunner> task_runner_;
// Owned by |filters_| below.
MessageHeaderValidator* header_validator_;
@@ -240,7 +238,7 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
FilterChain filters_;
Connector connector_;
- base::ThreadChecker thread_checker_;
+ base::SequenceChecker sequence_checker_;
// Protects the following members.
// Sets to nullptr in Config::SINGLE_INTERFACE* mode.
@@ -258,7 +256,7 @@ class MOJO_CPP_BINDINGS_EXPORT MultiplexRouter
std::map<InterfaceId, std::deque<Task*>> sync_message_tasks_;
bool posted_to_process_tasks_;
- scoped_refptr<base::SingleThreadTaskRunner> posted_to_task_runner_;
+ scoped_refptr<base::SequencedTaskRunner> posted_to_task_runner_;
bool encountered_error_;
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_ptr_state.h ('k') | mojo/public/cpp/bindings/lib/multiplex_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698