summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/gpu/BUILD.gn4
-rw-r--r--content/gpu/gpu_child_thread.h2
-rw-r--r--mojo/common/weak_binding_set.h9
-rw-r--r--mojo/public/cpp/bindings/associated_binding.h14
-rw-r--r--mojo/public/cpp/bindings/associated_group.h7
-rw-r--r--mojo/public/cpp/bindings/associated_interface_ptr.h12
-rw-r--r--mojo/public/cpp/bindings/binding.h8
-rw-r--r--mojo/public/cpp/bindings/interface_ptr.h6
-rw-r--r--mojo/public/cpp/bindings/interface_request.h9
-rw-r--r--mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h8
-rw-r--r--mojo/public/cpp/bindings/lib/binding_state.h16
-rw-r--r--mojo/public/cpp/bindings/lib/interface_ptr_state.h18
-rw-r--r--mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl2
-rw-r--r--mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl3
-rw-r--r--mojo/public/tools/bindings/generators/mojom_cpp_generator.py8
15 files changed, 86 insertions, 40 deletions
diff --git a/content/gpu/BUILD.gn b/content/gpu/BUILD.gn
index 74c0142..33a3675 100644
--- a/content/gpu/BUILD.gn
+++ b/content/gpu/BUILD.gn
@@ -49,6 +49,10 @@ source_set("gpu_sources") {
"//ui/gl",
]
+ public_deps = [
+ "//content/common:mojo_bindings",
+ ]
+
if (enable_mojo_media == "gpu") {
deps += [ "//media/mojo/services:application" ]
}
diff --git a/content/gpu/gpu_child_thread.h b/content/gpu/gpu_child_thread.h
index e72c72f..927c2d5 100644
--- a/content/gpu/gpu_child_thread.h
+++ b/content/gpu/gpu_child_thread.h
@@ -19,6 +19,7 @@
#include "content/common/gpu/gpu_channel_manager.h"
#include "content/common/gpu/gpu_config.h"
#include "content/common/gpu/x_util.h"
+#include "content/common/process_control.mojom.h"
#include "gpu/config/gpu_info.h"
#include "mojo/common/weak_binding_set.h"
#include "mojo/public/cpp/bindings/interface_request.h"
@@ -36,7 +37,6 @@ namespace content {
class GpuMemoryBufferFactory;
class GpuProcessControlImpl;
class GpuWatchdogThread;
-class ProcessControl;
// The main thread of the GPU child process. There will only ever be one of
// these per process. It does process initialization and shutdown. It forwards
diff --git a/mojo/common/weak_binding_set.h b/mojo/common/weak_binding_set.h
index 85c8031..c3736ff 100644
--- a/mojo/common/weak_binding_set.h
+++ b/mojo/common/weak_binding_set.h
@@ -21,6 +21,8 @@ class WeakBinding;
template <typename Interface>
class WeakBindingSet {
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
WeakBindingSet() {}
~WeakBindingSet() { CloseAllBindings(); }
@@ -28,7 +30,8 @@ class WeakBindingSet {
error_handler_ = error_handler;
}
- void AddBinding(Interface* impl, InterfaceRequest<Interface> request) {
+ void AddBinding(Interface* impl,
+ InterfaceRequest<GenericInterface> request) {
auto binding = new WeakBinding<Interface>(impl, request.Pass());
binding->set_connection_error_handler([this]() { OnConnectionError(); });
bindings_.push_back(binding->GetWeakPtr());
@@ -68,7 +71,9 @@ class WeakBindingSet {
template <typename Interface>
class WeakBinding {
public:
- WeakBinding(Interface* impl, InterfaceRequest<Interface> request)
+ using GenericInterface = typename Interface::GenericInterface;
+
+ WeakBinding(Interface* impl, InterfaceRequest<GenericInterface> request)
: binding_(impl, request.Pass()),
weak_ptr_factory_(this) {
binding_.set_connection_error_handler([this]() { OnConnectionError(); });
diff --git a/mojo/public/cpp/bindings/associated_binding.h b/mojo/public/cpp/bindings/associated_binding.h
index b6b7cd1..dd40291 100644
--- a/mojo/public/cpp/bindings/associated_binding.h
+++ b/mojo/public/cpp/bindings/associated_binding.h
@@ -21,6 +21,8 @@ namespace mojo {
template <typename Interface>
class AssociatedBinding {
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
// Constructs an incomplete associated binding that will use the
// implementation |impl|. It may be completed with a subsequent call to the
// |Bind| method. Does not take ownership of |impl|, which must outlive this
@@ -34,7 +36,7 @@ class AssociatedBinding {
// |associated_group| to setup the corresponding asssociated interface
// pointer. |impl| must outlive this object.
AssociatedBinding(Interface* impl,
- AssociatedInterfacePtrInfo<Interface>* ptr_info,
+ AssociatedInterfacePtrInfo<GenericInterface>* ptr_info,
AssociatedGroup* associated_group)
: AssociatedBinding(impl) {
Bind(ptr_info, associated_group);
@@ -43,7 +45,7 @@ class AssociatedBinding {
// Constructs a completed associated binding of |impl|. |impl| must outlive
// the binding.
AssociatedBinding(Interface* impl,
- AssociatedInterfaceRequest<Interface> request)
+ AssociatedInterfaceRequest<GenericInterface> request)
: AssociatedBinding(impl) {
Bind(request.Pass());
}
@@ -54,7 +56,7 @@ class AssociatedBinding {
// implementation side. The output |ptr_info| should be passed through the
// message pipe endpoint referred to by |associated_group| to setup the
// corresponding asssociated interface pointer.
- void Bind(AssociatedInterfacePtrInfo<Interface>* ptr_info,
+ void Bind(AssociatedInterfacePtrInfo<GenericInterface>* ptr_info,
AssociatedGroup* associated_group) {
AssociatedInterfaceRequest<Interface> request;
associated_group->CreateAssociatedInterface(AssociatedGroup::WILL_PASS_PTR,
@@ -63,7 +65,7 @@ class AssociatedBinding {
}
// Sets up this object as the implementation side of an associated interface.
- void Bind(AssociatedInterfaceRequest<Interface> request) {
+ void Bind(AssociatedInterfaceRequest<GenericInterface> request) {
internal::ScopedInterfaceEndpointHandle handle =
internal::AssociatedInterfaceRequestHelper::PassHandle(&request);
@@ -95,10 +97,10 @@ class AssociatedBinding {
// Unbinds and returns the associated interface request so it can be
// used in another context, such as on another thread or with a different
// implementation. Puts this object into a state where it can be rebound.
- AssociatedInterfaceRequest<Interface> Unbind() {
+ AssociatedInterfaceRequest<GenericInterface> Unbind() {
DCHECK(endpoint_client_);
- AssociatedInterfaceRequest<Interface> request;
+ AssociatedInterfaceRequest<GenericInterface> request;
internal::AssociatedInterfaceRequestHelper::SetHandle(
&request, endpoint_client_->PassHandle());
diff --git a/mojo/public/cpp/bindings/associated_group.h b/mojo/public/cpp/bindings/associated_group.h
index b6934e0..72aec3d 100644
--- a/mojo/public/cpp/bindings/associated_group.h
+++ b/mojo/public/cpp/bindings/associated_group.h
@@ -44,9 +44,10 @@ class AssociatedGroup {
// no need to wait until |request| is bound to an implementation at the remote
// side.
template <typename T>
- void CreateAssociatedInterface(AssociatedInterfaceConfig config,
- AssociatedInterfacePtrInfo<T>* ptr_info,
- AssociatedInterfaceRequest<T>* request) {
+ void CreateAssociatedInterface(
+ AssociatedInterfaceConfig config,
+ AssociatedInterfacePtrInfo<T>* ptr_info,
+ AssociatedInterfaceRequest<T>* request) {
internal::ScopedInterfaceEndpointHandle local;
internal::ScopedInterfaceEndpointHandle remote;
CreateEndpointHandlePair(&local, &remote);
diff --git a/mojo/public/cpp/bindings/associated_interface_ptr.h b/mojo/public/cpp/bindings/associated_interface_ptr.h
index 15c12ce..9122688 100644
--- a/mojo/public/cpp/bindings/associated_interface_ptr.h
+++ b/mojo/public/cpp/bindings/associated_interface_ptr.h
@@ -22,6 +22,8 @@ class AssociatedInterfacePtr {
DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(AssociatedInterfacePtr)
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
// Constructs an unbound AssociatedInterfacePtr.
AssociatedInterfacePtr() {}
AssociatedInterfacePtr(decltype(nullptr)) {}
@@ -52,7 +54,7 @@ class AssociatedInterfacePtr {
// NOTE: Please see the comments of
// AssociatedGroup.CreateAssociatedInterface() about when you can use this
// object to make calls.
- void Bind(AssociatedInterfacePtrInfo<Interface> info) {
+ void Bind(AssociatedInterfacePtrInfo<GenericInterface> info) {
reset();
bool is_local =
@@ -120,7 +122,7 @@ class AssociatedInterfacePtr {
// It is an error to call PassInterface() while there are pending responses.
// TODO: fix this restriction, it's not always obvious when there is a
// pending response.
- AssociatedInterfacePtrInfo<Interface> PassInterface() {
+ AssociatedInterfacePtrInfo<GenericInterface> PassInterface() {
DCHECK(!internal_state_.has_pending_callbacks());
State state;
internal_state_.Swap(&state);
@@ -173,11 +175,11 @@ class AssociatedInterfacePtr {
// as soon as the request is sent, |ptr| is usable. There is no need to wait
// until the request is bound to an implementation at the remote side.
template <typename Interface>
-AssociatedInterfaceRequest<Interface> GetProxy(
+AssociatedInterfaceRequest<typename Interface::GenericInterface> GetProxy(
AssociatedInterfacePtr<Interface>* ptr,
AssociatedGroup* group) {
- AssociatedInterfaceRequest<Interface> request;
- AssociatedInterfacePtrInfo<Interface> ptr_info;
+ AssociatedInterfaceRequest<typename Interface::GenericInterface> request;
+ AssociatedInterfacePtrInfo<typename Interface::GenericInterface> ptr_info;
group->CreateAssociatedInterface(AssociatedGroup::WILL_PASS_REQUEST,
&ptr_info, &request);
diff --git a/mojo/public/cpp/bindings/binding.h b/mojo/public/cpp/bindings/binding.h
index 09cdb88..a15536c 100644
--- a/mojo/public/cpp/bindings/binding.h
+++ b/mojo/public/cpp/bindings/binding.h
@@ -59,6 +59,8 @@ class AssociatedGroup;
template <typename Interface>
class Binding {
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
// Constructs an incomplete binding that will use the implementation |impl|.
// The binding may be completed with a subsequent call to the |Bind| method.
// Does not take ownership of |impl|, which must outlive the binding.
@@ -92,7 +94,7 @@ class Binding {
// |impl|, which must outlive the binding. See class comment for definition of
// |waiter|.
Binding(Interface* impl,
- InterfaceRequest<Interface> request,
+ InterfaceRequest<GenericInterface> request,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter())
: Binding(impl) {
Bind(request.PassMessagePipe(), waiter);
@@ -132,7 +134,7 @@ class Binding {
// binding it to the previously specified implementation. See class comment
// for definition of |waiter|.
void Bind(
- InterfaceRequest<Interface> request,
+ InterfaceRequest<GenericInterface> request,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) {
Bind(request.PassMessagePipe(), waiter);
}
@@ -186,7 +188,7 @@ class Binding {
// on to associated interface endpoint handles at both sides of the
// message pipe in order to call this method. We need a way to forcefully
// invalidate associated interface endpoint handles.
- InterfaceRequest<Interface> Unbind() {
+ InterfaceRequest<GenericInterface> Unbind() {
CHECK(!HasAssociatedInterfaces());
return internal_state_.Unbind();
}
diff --git a/mojo/public/cpp/bindings/interface_ptr.h b/mojo/public/cpp/bindings/interface_ptr.h
index dbd52e6..51cfc35 100644
--- a/mojo/public/cpp/bindings/interface_ptr.h
+++ b/mojo/public/cpp/bindings/interface_ptr.h
@@ -32,6 +32,8 @@ class InterfacePtr {
DISALLOW_COPY_AND_ASSIGN_WITH_MOVE_FOR_BIND(InterfacePtr)
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
// Constructs an unbound InterfacePtr.
InterfacePtr() {}
InterfacePtr(decltype(nullptr)) {}
@@ -68,7 +70,7 @@ class InterfacePtr {
// has the same effect as reset(). In this case, the InterfacePtr is not
// considered as bound.
void Bind(
- InterfacePtrInfo<Interface> info,
+ InterfacePtrInfo<GenericInterface> info,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) {
reset();
if (info.is_valid())
@@ -157,7 +159,7 @@ class InterfacePtr {
// on to associated interface endpoint handles at both sides of the
// message pipe in order to call this method. We need a way to forcefully
// invalidate associated interface endpoint handles.
- InterfacePtrInfo<Interface> PassInterface() {
+ InterfacePtrInfo<GenericInterface> PassInterface() {
CHECK(!HasAssociatedInterfaces());
CHECK(!internal_state_.has_pending_callbacks());
State state;
diff --git a/mojo/public/cpp/bindings/interface_request.h b/mojo/public/cpp/bindings/interface_request.h
index c139306..2e93e30 100644
--- a/mojo/public/cpp/bindings/interface_request.h
+++ b/mojo/public/cpp/bindings/interface_request.h
@@ -107,10 +107,13 @@ InterfaceRequest<Interface> MakeRequest(ScopedMessagePipeHandle handle) {
// CreateSource(source_request.Pass()); // Create implementation locally.
//
template <typename Interface>
-InterfaceRequest<Interface> GetProxy(InterfacePtr<Interface>* ptr) {
+InterfaceRequest<typename Interface::GenericInterface>
+GetProxy(InterfacePtr<Interface>* ptr) {
MessagePipe pipe;
- ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u));
- return MakeRequest<Interface>(pipe.handle1.Pass());
+ ptr->Bind(InterfacePtrInfo<typename Interface::GenericInterface>(
+ pipe.handle0.Pass(), 0u));
+ return MakeRequest<typename Interface::GenericInterface>(
+ pipe.handle1.Pass());
}
} // namespace mojo
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 2a111ea..00f2de5 100644
--- a/mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h
+++ b/mojo/public/cpp/bindings/lib/associated_interface_ptr_state.h
@@ -24,6 +24,8 @@ namespace internal {
template <typename Interface>
class AssociatedInterfacePtrState {
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
AssociatedInterfacePtrState() : version_(0u) {}
~AssociatedInterfacePtrState() {
@@ -69,7 +71,7 @@ class AssociatedInterfacePtrState {
swap(other->version_, version_);
}
- void Bind(AssociatedInterfacePtrInfo<Interface> info) {
+ void Bind(AssociatedInterfacePtrInfo<GenericInterface> info) {
DCHECK(!endpoint_client_);
DCHECK(!proxy_);
DCHECK_EQ(0u, version_);
@@ -85,12 +87,12 @@ class AssociatedInterfacePtrState {
// After this method is called, the object is in an invalid state and
// shouldn't be reused.
- AssociatedInterfacePtrInfo<Interface> PassInterface() {
+ AssociatedInterfacePtrInfo<GenericInterface> PassInterface() {
ScopedInterfaceEndpointHandle handle = endpoint_client_->PassHandle();
endpoint_client_.reset();
proxy_.reset();
- AssociatedInterfacePtrInfo<Interface> result;
+ AssociatedInterfacePtrInfo<GenericInterface> result;
result.set_version(version_);
AssociatedInterfacePtrInfoHelper::SetHandle(&result, handle.Pass());
return result.Pass();
diff --git a/mojo/public/cpp/bindings/lib/binding_state.h b/mojo/public/cpp/bindings/lib/binding_state.h
index 82b1a32..dea3a6b 100644
--- a/mojo/public/cpp/bindings/lib/binding_state.h
+++ b/mojo/public/cpp/bindings/lib/binding_state.h
@@ -37,6 +37,8 @@ class BindingState;
template <typename Interface>
class BindingState<Interface, false> {
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
explicit BindingState(Interface* impl) : impl_(impl) {
stub_.set_sink(impl_);
}
@@ -81,9 +83,9 @@ class BindingState<Interface, false> {
DestroyRouter();
}
- InterfaceRequest<Interface> Unbind() {
- InterfaceRequest<Interface> request =
- MakeRequest<Interface>(router_->PassMessagePipe());
+ InterfaceRequest<GenericInterface> Unbind() {
+ InterfaceRequest<GenericInterface> request =
+ MakeRequest<GenericInterface>(router_->PassMessagePipe());
DestroyRouter();
return request.Pass();
}
@@ -128,6 +130,8 @@ class BindingState<Interface, false> {
template <typename Interface>
class BindingState<Interface, true> {
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
explicit BindingState(Interface* impl) : impl_(impl) {
stub_.set_sink(impl_);
}
@@ -177,10 +181,10 @@ class BindingState<Interface, true> {
router_ = nullptr;
}
- InterfaceRequest<Interface> Unbind() {
+ InterfaceRequest<GenericInterface> Unbind() {
endpoint_client_.reset();
- InterfaceRequest<Interface> request =
- MakeRequest<Interface>(router_->PassMessagePipe());
+ InterfaceRequest<GenericInterface> request =
+ MakeRequest<GenericInterface>(router_->PassMessagePipe());
router_ = nullptr;
return request.Pass();
}
diff --git a/mojo/public/cpp/bindings/lib/interface_ptr_state.h b/mojo/public/cpp/bindings/lib/interface_ptr_state.h
index 8b8d670..d203031 100644
--- a/mojo/public/cpp/bindings/lib/interface_ptr_state.h
+++ b/mojo/public/cpp/bindings/lib/interface_ptr_state.h
@@ -38,6 +38,8 @@ class InterfacePtrState;
template <typename Interface>
class InterfacePtrState<Interface, false> {
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
InterfacePtrState()
: proxy_(nullptr), router_(nullptr), waiter_(nullptr), version_(0u) {}
@@ -94,7 +96,8 @@ class InterfacePtrState<Interface, false> {
swap(other->version_, version_);
}
- void Bind(InterfacePtrInfo<Interface> info, const MojoAsyncWaiter* waiter) {
+ void Bind(InterfacePtrInfo<GenericInterface> info,
+ const MojoAsyncWaiter* waiter) {
DCHECK(!proxy_);
DCHECK(!router_);
DCHECK(!handle_.is_valid());
@@ -118,8 +121,8 @@ class InterfacePtrState<Interface, false> {
// After this method is called, the object is in an invalid state and
// shouldn't be reused.
- InterfacePtrInfo<Interface> PassInterface() {
- return InterfacePtrInfo<Interface>(
+ InterfacePtrInfo<GenericInterface> PassInterface() {
+ return InterfacePtrInfo<GenericInterface>(
router_ ? router_->PassMessagePipe() : handle_.Pass(), version_);
}
@@ -192,6 +195,8 @@ class InterfacePtrState<Interface, false> {
template <typename Interface>
class InterfacePtrState<Interface, true> {
public:
+ using GenericInterface = typename Interface::GenericInterface;
+
InterfacePtrState() : waiter_(nullptr), version_(0u) {}
~InterfacePtrState() {
@@ -248,7 +253,8 @@ class InterfacePtrState<Interface, true> {
swap(other->version_, version_);
}
- void Bind(InterfacePtrInfo<Interface> info, const MojoAsyncWaiter* waiter) {
+ void Bind(InterfacePtrInfo<GenericInterface> info,
+ const MojoAsyncWaiter* waiter) {
DCHECK(!router_);
DCHECK(!endpoint_client_);
DCHECK(!proxy_);
@@ -275,10 +281,10 @@ class InterfacePtrState<Interface, true> {
// After this method is called, the object is in an invalid state and
// shouldn't be reused.
- InterfacePtrInfo<Interface> PassInterface() {
+ InterfacePtrInfo<GenericInterface> PassInterface() {
endpoint_client_.reset();
proxy_.reset();
- return InterfacePtrInfo<Interface>(
+ return InterfacePtrInfo<GenericInterface>(
router_ ? router_->PassMessagePipe() : handle_.Pass(), version_);
}
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
index e32024f..2115a86 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl
@@ -13,6 +13,8 @@ class {{interface.name}} {
static const uint32_t Version_ = {{interface.version}};
static const bool PassesAssociatedKinds_ = {% if interface|passes_associated_kinds %}true{% else %}false{% endif %};
+ using GenericInterface = {{interface|get_qualified_name_for_kind}};
+
using Proxy_ = {{interface.name}}Proxy;
using Stub_ = {{interface.name}}Stub;
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
index c54668d..a5df160 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/module.h.tmpl
@@ -35,6 +35,9 @@
{%- for import in imports %}
#include "{{import.module.path}}.h"
{%- endfor %}
+{%- if variant %}
+#include "{{module.path}}.h"
+{%- endif %}
{%- for namespace in namespaces_as_array %}
namespace {{namespace}} {
diff --git a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
index 4c63270..5a46d9a 100644
--- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
@@ -67,6 +67,13 @@ def GetNameForKind(kind, internal = False):
parts.append(kind.name)
return "::".join(parts)
+def GetQualifiedNameForKind(kind):
+ # Always start with an empty part to force a leading "::" on output.
+ parts = [""]
+ parts.extend(NamespaceToArray(kind.module.namespace))
+ parts.append(kind.name)
+ return "::".join(parts)
+
def GetCppType(kind):
if mojom.IsArrayKind(kind):
return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind)
@@ -390,6 +397,7 @@ class Generator(generator.Generator):
"get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs,
"get_name_for_kind": GetNameForKind,
"get_pad": pack.GetPad,
+ "get_qualified_name_for_kind": GetQualifiedNameForKind,
"has_callbacks": mojom.HasCallbacks,
"should_inline": ShouldInlineStruct,
"should_inline_union": ShouldInlineUnion,