summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2016-03-22 18:32:18 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-23 01:36:10 +0000
commit506f92fa27652f8e9cd5be3ea75a408f0890e975 (patch)
tree22b3a9e32a514b6f5c352115ce6340ebe9941f1d /mojo
parente73b1ec08b8d1dbde884f58a7a2c6cbbbccfa6ed (diff)
downloadchromium_src-506f92fa27652f8e9cd5be3ea75a408f0890e975.zip
chromium_src-506f92fa27652f8e9cd5be3ea75a408f0890e975.tar.gz
chromium_src-506f92fa27652f8e9cd5be3ea75a408f0890e975.tar.bz2
Make ChannelMojo Send thread-safe
Changes ChannelMojo to write outgoing Receive requests directly to the pipe rather than using its AssociatedInterfacePtr. The associated interface ID is still included in each outgoing message. This lets us mark ChannelMojo::Send as thread-safe, avoiding a thread-hop when sending IPCs through IPC::ChannelProxy. BUG=595082 Review URL: https://codereview.chromium.org/1825543002 Cr-Commit-Position: refs/heads/master@{#382762}
Diffstat (limited to 'mojo')
-rw-r--r--mojo/public/cpp/bindings/associated_interface_ptr.h3
-rw-r--r--mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h6
-rw-r--r--mojo/public/cpp/bindings/lib/interface_endpoint_client.cc5
-rw-r--r--mojo/public/cpp/bindings/lib/interface_endpoint_client.h1
4 files changed, 15 insertions, 0 deletions
diff --git a/mojo/public/cpp/bindings/associated_interface_ptr.h b/mojo/public/cpp/bindings/associated_interface_ptr.h
index d3a848a..48caad6 100644
--- a/mojo/public/cpp/bindings/associated_interface_ptr.h
+++ b/mojo/public/cpp/bindings/associated_interface_ptr.h
@@ -79,6 +79,9 @@ class AssociatedInterfacePtr {
// Returns the version number of the interface that the remote side supports.
uint32_t version() const { return internal_state_.version(); }
+ // Returns the internal interface ID of this associated interface.
+ uint32_t interface_id() const { return internal_state_.interface_id(); }
+
// Queries the max version that the remote side supports. On completion, the
// result will be returned as the input of |callback|. The version number of
// this object will also be updated.
diff --git a/mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h b/mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h
index f792884..1b9e35c 100644
--- a/mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h
+++ b/mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h
@@ -19,6 +19,7 @@
#include "mojo/public/cpp/bindings/lib/interface_id.h"
#include "mojo/public/cpp/bindings/lib/multiplex_router.h"
#include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h"
+#include "mojo/public/cpp/system/message_pipe.h"
namespace mojo {
namespace internal {
@@ -40,6 +41,11 @@ class AssociatedInterfacePtrState {
uint32_t version() const { return version_; }
+ uint32_t interface_id() const {
+ DCHECK(is_bound());
+ return endpoint_client_->interface_id();
+ }
+
void QueryVersion(const Callback<void(uint32_t)>& callback) {
// It is safe to capture |this| because the callback won't be run after this
// object goes away.
diff --git a/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc b/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
index 58bc885..8094ad0 100644
--- a/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
+++ b/mojo/public/cpp/bindings/lib/interface_endpoint_client.cc
@@ -149,6 +149,11 @@ AssociatedGroup* InterfaceEndpointClient::associated_group() {
return associated_group_.get();
}
+uint32_t InterfaceEndpointClient::interface_id() const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ return handle_.id();
+}
+
ScopedInterfaceEndpointHandle InterfaceEndpointClient::PassHandle() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!has_pending_responders());
diff --git a/mojo/public/cpp/bindings/lib/interface_endpoint_client.h b/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
index 12ecbcc..548ca38 100644
--- a/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
+++ b/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
@@ -60,6 +60,7 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
MultiplexRouter* router() const { return handle_.router(); }
AssociatedGroup* associated_group();
+ uint32_t interface_id() const;
// After this call the object is in an invalid state and shouldn't be reused.
ScopedInterfaceEndpointHandle PassHandle();