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