1{%- import "interface_macros.tmpl" as interface_macros %}
2class {{interface.name}}Proxy;
3
4template <typename ImplRefTraits>
5class {{interface.name}}Stub;
6
7class {{interface.name}}RequestValidator;
8{%- if interface|has_callbacks %}
9class {{interface.name}}ResponseValidator;
10{%- endif %}
11
12class {{export_attribute}} {{interface.name}}
13    : public {{interface.name}}InterfaceBase {
14 public:
15  static const char Name_[];
16{%-  if interface.uuid %}
17  static constexpr base::Token Uuid_{ {{interface.uuid[0]}}ULL,
18                                      {{interface.uuid[1]}}ULL };
19{%-  endif %}
20  static constexpr uint32_t Version_ = {{interface.version}};
21  static constexpr bool PassesAssociatedKinds_ = {% if interface|passes_associated_kinds %}true{% else %}false{% endif %};
22  static constexpr bool HasSyncMethods_ = {% if interface|has_sync_methods %}true{% else %}false{% endif %};
23
24  using Proxy_ = {{interface.name}}Proxy;
25
26  template <typename ImplRefTraits>
27  using Stub_ = {{interface.name}}Stub<ImplRefTraits>;
28
29  using RequestValidator_ = {{interface.name}}RequestValidator;
30{%- if interface|has_callbacks %}
31  using ResponseValidator_ = {{interface.name}}ResponseValidator;
32{%- else %}
33  using ResponseValidator_ = mojo::PassThroughFilter;
34{%- endif %}
35
36{#--- Metadata #}
37  enum MethodMinVersions : uint32_t {
38{%- for method in interface.methods %}
39    k{{method.name}}MinVersion = {{method.min_version|default(0, true)}},
40{%- endfor %}
41  };
42
43{#--- Enums #}
44{%- for enum in interface.enums %}
45  using {{enum.name}} = {{enum|get_name_for_kind(flatten_nested_kind=True)}};
46{%- endfor %}
47
48{#--- Constants #}
49{%- for constant in interface.constants %}
50  static {{constant|format_constant_declaration(nested=True)}};
51{%- endfor %}
52
53{#--- Methods #}
54  virtual ~{{interface.name}}() {}
55
56{%- for method in interface.methods %}
57{%    if method.response_parameters != None %}
58{%-     if method.sync %}
59  // Sync method. This signature is used by the client side; the service side
60  // should implement the signature with callback below.
61  virtual bool {{method.name}}({{interface_macros.declare_sync_method_params("", method)}});
62{%-     endif %}
63
64  using {{method.name}}Callback = {{interface_macros.declare_callback(method,
65      for_blink, use_once_callback)}};
66{%-   endif %}
67  virtual void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) = 0;
68{%- endfor %}
69};
70
71{#--- Testing interceptor #}
72class {{export_attribute}} {{interface.name}}InterceptorForTesting : public {{interface.name}} {
73  virtual {{interface.name}}* GetForwardingInterface() = 0;
74
75{%- for method in interface.methods %}
76  void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) override;
77{%- endfor %}
78};
79
80{#--- Async wait helper for testing #}
81class {{export_attribute}} {{interface.name}}AsyncWaiter {
82 public:
83  explicit {{interface.name}}AsyncWaiter({{interface.name}}* proxy);
84  ~{{interface.name}}AsyncWaiter();
85
86{%- for method in interface.methods if method.response_parameters != None %}
87  void {{method.name}}(
88      {{interface_macros.declare_sync_method_params("", method)}});
89{%- endfor %}
90
91 private:
92  {{interface.name}}* const proxy_;
93
94  DISALLOW_COPY_AND_ASSIGN({{interface.name}}AsyncWaiter);
95};
96