Commit 53f90379 authored by tzik's avatar tzik Committed by Commit Bot

Remove use_once_callback option from Mojo code generator

This CL removes legacy base::Callback support from Mojo code generator,
that is no longer used.

Bug: 714018
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I2928476e357136a7c7bbb57f83509c63fe45b321
Reviewed-on: https://chromium-review.googlesource.com/1152637Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Reviewed-by: default avatarMisha Efimov <mef@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583174}
parent 2dedff94
......@@ -208,7 +208,6 @@ class MojomProcessor(object):
module, args.output_dir, typemap=self._typemap.get(language, {}),
variant=args.variant, bytecode_path=args.bytecode_path,
for_blink=args.for_blink,
use_once_callback=args.use_once_callback,
export_attribute=args.export_attribute,
export_header=args.export_header,
generate_non_variant_code=args.generate_non_variant_code,
......@@ -337,9 +336,6 @@ def main():
generate_parser.add_argument("--for_blink", action="store_true",
help="Use WTF types as generated types for mojo "
"string/array/map.")
generate_parser.add_argument(
"--use_once_callback", action="store_true",
help="Use base::OnceCallback instead of base::RepeatingCallback.")
generate_parser.add_argument(
"--export_attribute", default="",
help="Optional attribute to specify on class declaration to export it "
......
......@@ -307,7 +307,6 @@ class Generator(generator.Generator):
"structs": self.module.structs,
"support_lazy_serialization": self.support_lazy_serialization,
"unions": self.module.unions,
"use_once_callback": self.use_once_callback,
"variant": self.variant,
}
......
......@@ -57,10 +57,9 @@ class {{export_attribute}} {{interface.name}}
virtual bool {{method.name}}({{interface_macros.declare_sync_method_params("", method)}});
{%- endif %}
using {{method.name}}Callback = {{interface_macros.declare_callback(method,
for_blink, use_once_callback)}};
using {{method.name}}Callback = {{interface_macros.declare_callback(method, for_blink)}};
{%- endif %}
virtual void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) = 0;
virtual void {{method.name}}({{interface_macros.declare_request_params("", method)}}) = 0;
{%- endfor %}
};
......@@ -69,7 +68,7 @@ class {{export_attribute}} {{interface.name}}InterceptorForTesting : public {{in
virtual {{interface.name}}* GetForwardingInterface() = 0;
{%- for method in interface.methods %}
void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) override;
void {{method.name}}({{interface_macros.declare_request_params("", method)}}) override;
{%- endfor %}
};
......
......@@ -84,11 +84,7 @@ class {{class_name}}_{{method.name}}_ForwardToCallback
: public mojo::MessageReceiver {
public:
{{class_name}}_{{method.name}}_ForwardToCallback(
{%- if use_once_callback %}
{{class_name}}::{{method.name}}Callback callback
{%- else %}
const {{class_name}}::{{method.name}}Callback& callback
{%- endif %}
) : callback_(std::move(callback)) {
}
bool Accept(mojo::Message* message) override;
......@@ -116,7 +112,7 @@ class {{class_name}}_{{method.name}}_ForwardToCallback
{%- if method|method_supports_lazy_serialization %}
{{interface_macros.define_message_type(
interface, message_typename, message_name, False, method, method.parameters,
params_struct, params_description, use_once_callback)}}
params_struct, params_description)}}
{%- endif %}
{%- if method.sync %}
......@@ -160,7 +156,7 @@ bool {{proxy_name}}::{{method.name}}(
{%- endif %}
void {{proxy_name}}::{{method.name}}(
{{interface_macros.declare_request_params("in_", method, use_once_callback)}}) {
{{interface_macros.declare_request_params("in_", method)}}) {
#if BUILDFLAG(MOJO_TRACE_ENABLED)
TRACE_EVENT0("mojom", "{{namespace_as_string}}::{{class_name}}::{{method.name}}");
#endif
......@@ -222,13 +218,8 @@ class {{class_name}}_{{method.name}}_ProxyToResponder {
std::unique_ptr<{{class_name}}_{{method.name}}_ProxyToResponder> proxy(
new {{class_name}}_{{method.name}}_ProxyToResponder(
request_id, is_sync, std::move(responder)));
{%- if use_once_callback %}
return base::BindOnce(&{{class_name}}_{{method.name}}_ProxyToResponder::Run,
std::move(proxy));
{%- else %}
return base::Bind(&{{class_name}}_{{method.name}}_ProxyToResponder::Run,
base::Passed(&proxy));
{%- endif %}
}
~{{class_name}}_{{method.name}}_ProxyToResponder() {
......@@ -279,8 +270,7 @@ class {{class_name}}_{{method.name}}_ProxyToResponder {
{%- if method|method_supports_lazy_serialization %}
{{interface_macros.define_message_type(
interface, response_message_typename, message_name, True, method,
method.response_parameters, response_params_struct, params_description,
use_once_callback)}}
method.response_parameters, response_params_struct, params_description)}}
{%- endif %}
bool {{class_name}}_{{method.name}}_ForwardToCallback::Accept(
......@@ -604,7 +594,7 @@ bool {{class_name}}ResponseValidator::Accept(mojo::Message* message) {
{#--- Testing interceptor #}
{%- for method in interface.methods %}
void {{interface.name}}InterceptorForTesting::{{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) {
void {{interface.name}}InterceptorForTesting::{{method.name}}({{interface_macros.declare_request_params("", method)}}) {
GetForwardingInterface()->{{method.name}}(
{%- for param in method.parameters -%}
std::move({{param.name}}){%- if not loop.last %}, {% endif %}
......@@ -631,11 +621,7 @@ void {{interface.name}}AsyncWaiter::{{method.name}}(
{%- for param in method.parameters -%}
std::move({{param.name}}),
{%- endfor %}
{%- if use_once_callback %}
base::BindOnce(
{%- else %}
base::Bind(
{%- endif %}
[](base::RunLoop* loop
{%- for param in method.response_parameters -%},
{{param.kind|cpp_wrapper_call_type}}* out_{{param.name}}
......
......@@ -7,12 +7,8 @@
{%- endfor %}
{%- endmacro %}
{%- macro declare_callback(method, for_blink, use_once_callback) -%}
{%- if use_once_callback -%}
{%- macro declare_callback(method, for_blink) -%}
base::OnceCallback<void(
{%- else -%}
base::Callback<void(
{%- endif -%}
{%- for param in method.response_parameters -%}
{{param.kind|cpp_wrapper_param_type}}
{%- if not loop.last %}, {% endif %}
......@@ -20,15 +16,11 @@ base::Callback<void(
)>
{%- endmacro -%}
{%- macro declare_request_params(prefix, method, use_once_callback) -%}
{%- macro declare_request_params(prefix, method) -%}
{{declare_params(prefix, method.parameters)}}
{%- if method.response_parameters != None -%}
{%- if method.parameters %}, {% endif -%}
{%- if use_once_callback -%}
{{method.name}}Callback callback
{%- else -%}
const {{method.name}}Callback& callback
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
......@@ -73,7 +65,7 @@ const {{method.name}}Callback& callback
{%- macro define_message_type(interface, message_typename, message_name,
is_response, method, parameters, params_struct,
params_description, use_once_callback) -%}
params_description) -%}
class {{message_typename}}
: public mojo::internal::UnserializedMessageContext {
public:
......@@ -130,11 +122,7 @@ class {{message_typename}}
{% if not is_response %}
void Dispatch({{interface.name}}* impl
{%- if method.response_parameters != None -%}
{%- if use_once_callback -%}
, {{interface.name}}::{{method.name}}Callback callback
{%- else -%}
, const {{interface.name}}::{{method.name}}Callback& callback
{%- endif -%}
{%- endif -%}) {
impl->{{method.name}}(
{%- for param in parameters -%}
......
......@@ -8,7 +8,7 @@ class {{export_attribute}} {{interface.name}}Proxy
{%- if method.sync %}
bool {{method.name}}({{interface_macros.declare_sync_method_params("", method)}}) final;
{%- endif %}
void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) final;
void {{method.name}}({{interface_macros.declare_request_params("", method)}}) final;
{%- endfor %}
private:
......
......@@ -307,7 +307,6 @@ class Generator(generator.Generator):
"structs": self.module.structs,
"support_lazy_serialization": self.support_lazy_serialization,
"unions": self.module.unions,
"use_once_callback": self.use_once_callback,
"variant": self.variant,
}
......
......@@ -196,14 +196,6 @@ if (enable_mojom_typemapping) {
# The value to use for visibility for the blink variant. If unset,
# |visibility| is used.
#
# use_once_callback (optional)
# If set to true, generated classes will use base::OnceCallback instead of
# base::RepeatingCallback.
# Default value is true.
# TODO(dcheng):
# - Convert everything to use OnceCallback.
# - Remove support for the old mode.
#
# cpp_only (optional)
# If set to true, only the C++ bindings targets will be generated.
#
......@@ -853,10 +845,6 @@ template("mojom") {
}
}
if (!defined(invoker.use_once_callback) || invoker.use_once_callback) {
args += [ "--use_once_callback" ]
}
if (defined(invoker.support_lazy_serialization) &&
invoker.support_lazy_serialization) {
args += [ "--support_lazy_serialization" ]
......
......@@ -207,7 +207,6 @@ class MojomProcessor(object):
module, args.output_dir, typemap=self._typemap.get(language, {}),
variant=args.variant, bytecode_path=args.bytecode_path,
for_blink=args.for_blink,
use_once_callback=args.use_once_callback,
js_bindings_mode=args.js_bindings_mode,
export_attribute=args.export_attribute,
export_header=args.export_header,
......@@ -436,9 +435,6 @@ def main():
generate_parser.add_argument("--for_blink", action="store_true",
help="Use WTF types as generated types for mojo "
"string/array/map.")
generate_parser.add_argument(
"--use_once_callback", action="store_true",
help="Use base::OnceCallback instead of base::RepeatingCallback.")
generate_parser.add_argument(
"--js_bindings_mode", choices=["new", "both", "old"], default="new",
help="This option only affects the JavaScript bindings. The value could "
......
......@@ -160,7 +160,7 @@ class Generator(object):
# Pass |output_dir| to emit files to disk. Omit |output_dir| to echo all
# files to stdout.
def __init__(self, module, output_dir=None, typemap=None, variant=None,
bytecode_path=None, for_blink=False, use_once_callback=False,
bytecode_path=None, for_blink=False,
js_bindings_mode="new", export_attribute=None,
export_header=None, generate_non_variant_code=False,
support_lazy_serialization=False, disallow_native_types=False,
......@@ -172,7 +172,6 @@ class Generator(object):
self.variant = variant
self.bytecode_path = bytecode_path
self.for_blink = for_blink
self.use_once_callback = use_once_callback
self.js_bindings_mode = js_bindings_mode
self.export_attribute = export_attribute
self.export_header = export_header
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment