blob: 78918ba09698a6545d675cff6e12d661a89e01de [file] [log] [blame]
{%- import "interface_macros.tmpl" as interface_macros %}
class {{interface.name}}Proxy;
template <typename ImplRefTraits>
class {{interface.name}}Stub;
class {{interface.name}}RequestValidator;
{%- if interface|has_callbacks %}
class {{interface.name}}ResponseValidator;
{%- endif %}
class {{export_attribute}} {{interface.name}}
: public {{interface.name}}InterfaceBase {
public:
static const char Name_[];
static constexpr uint32_t Version_ = {{interface.version}};
static constexpr bool PassesAssociatedKinds_ = {% if interface|passes_associated_kinds %}true{% else %}false{% endif %};
static constexpr bool HasSyncMethods_ = {% if interface|has_sync_methods %}true{% else %}false{% endif %};
using Proxy_ = {{interface.name}}Proxy;
template <typename ImplRefTraits>
using Stub_ = {{interface.name}}Stub<ImplRefTraits>;
using RequestValidator_ = {{interface.name}}RequestValidator;
{%- if interface|has_callbacks %}
using ResponseValidator_ = {{interface.name}}ResponseValidator;
{%- else %}
using ResponseValidator_ = mojo::PassThroughFilter;
{%- endif %}
{#--- Metadata #}
enum MethodMinVersions : uint32_t {
{%- for method in interface.methods %}
k{{method.name}}MinVersion = {{method.min_version|default(0, true)}},
{%- endfor %}
};
{#--- Enums #}
{%- for enum in interface.enums %}
using {{enum.name}} = {{enum|get_name_for_kind(flatten_nested_kind=True)}};
{%- endfor %}
{#--- Constants #}
{%- for constant in interface.constants %}
static {{constant|format_constant_declaration(nested=True)}};
{%- endfor %}
{#--- Methods #}
virtual ~{{interface.name}}() {}
{%- for method in interface.methods %}
{% if method.response_parameters != None %}
{%- if method.sync %}
// Sync method. This signature is used by the client side; the service side
// should implement the signature with callback below.
virtual bool {{method.name}}({{interface_macros.declare_sync_method_params("", method)}});
{%- endif %}
using {{method.name}}Callback = {{interface_macros.declare_callback(method, for_blink)}};
{%- endif %}
virtual void {{method.name}}({{interface_macros.declare_request_params("", method)}}) = 0;
{%- endfor %}
};
{#--- Testing interceptor #}
class {{export_attribute}} {{interface.name}}InterceptorForTesting : public {{interface.name}} {
virtual {{interface.name}}* GetForwardingInterface() = 0;
{%- for method in interface.methods %}
void {{method.name}}({{interface_macros.declare_request_params("", method)}}) override;
{%- endfor %}
};
{#--- Async wait helper for testing #}
class {{export_attribute}} {{interface.name}}AsyncWaiter {
public:
explicit {{interface.name}}AsyncWaiter({{interface.name}}* proxy);
~{{interface.name}}AsyncWaiter();
{%- for method in interface.methods if method.response_parameters != None %}
void {{method.name}}(
{{interface_macros.declare_sync_method_params("", method)}});
{%- endfor %}
private:
{{interface.name}}* const proxy_;
DISALLOW_COPY_AND_ASSIGN({{interface.name}}AsyncWaiter);
};