Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1627)

Unified Diff: third_party/inspector_protocol/templates/TypeBuilder_cpp.template

Issue 2522583002: Roll third_party/inspector_protocol to 4ad35c45aca9834b67ec2cb152c816ea1b7ceb48 (Closed)
Patch Set: addressed comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/inspector_protocol/templates/TypeBuilder_cpp.template
diff --git a/third_party/inspector_protocol/templates/TypeBuilder_cpp.template b/third_party/inspector_protocol/templates/TypeBuilder_cpp.template
index b63a0e880ddc502d68ca0be325907cf8d33750f2..885e9a6828388e26b4222ecad94785ca87eee6eb 100644
--- a/third_party/inspector_protocol/templates/TypeBuilder_cpp.template
+++ b/third_party/inspector_protocol/templates/TypeBuilder_cpp.template
@@ -75,7 +75,7 @@ std::unique_ptr<{{type.id}}> {{type.id}}::parse(protocol::Value* value, ErrorSup
return result;
}
-std::unique_ptr<protocol::DictionaryValue> {{type.id}}::serialize() const
+std::unique_ptr<protocol::DictionaryValue> {{type.id}}::serializeValue() const
{
std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
{% for property in type.properties %}
@@ -92,13 +92,13 @@ std::unique_ptr<protocol::DictionaryValue> {{type.id}}::serialize() const
std::unique_ptr<{{type.id}}> {{type.id}}::clone() const
{
ErrorSupport errors;
- return parse(serialize().get(), &errors);
+ return parse(serializeValue().get(), &errors);
}
{% if type.exported %}
{{config.exported.string_out}} {{type.id}}::toJSONString() const
{
- String json = serialize()->toJSONString();
+ String json = serializeValue()->toJSONString();
return {{config.exported.to_string_out % "json"}};
}
@@ -156,20 +156,26 @@ void Frontend::{{event.name | to_method_case}}(
{%- endif %} {{parameter.name}}{%- if not loop.last -%}, {% endif -%}
{% endfor -%})
{
- std::unique_ptr<protocol::DictionaryValue> jsonMessage = DictionaryValue::create();
- jsonMessage->setString("method", "{{domain.domain}}.{{event.name}}");
- std::unique_ptr<protocol::DictionaryValue> paramsObject = DictionaryValue::create();
- {% for parameter in event.parameters %}
- {% if "optional" in parameter %}
+ if (!m_frontendChannel)
+ return;
+ {% if event.parameters %}
+ std::unique_ptr<{{event.name | to_title_case}}Notification> messageData = {{event.name | to_title_case}}Notification::{{"create" | to_method_case}}()
+ {% for parameter in event.parameters %}
+ {% if not "optional" in parameter %}
+ .{{"set" | to_method_case}}{{parameter.name | to_title_case}}({{resolve_type(parameter).to_pass_type % parameter.name}})
+ {% endif %}
+ {% endfor %}
+ .{{ "build" | to_method_case }}();
+ {% for parameter in event.parameters %}
+ {% if "optional" in parameter %}
if ({{parameter.name}}.isJust())
- paramsObject->setValue("{{parameter.name}}", ValueConversions<{{resolve_type(parameter).raw_type}}>::serialize({{parameter.name}}.fromJust()));
+ messageData->{{"set" | to_method_case}}{{parameter.name | to_title_case}}(std::move({{parameter.name}}).takeJust());
+ {% endif %}
+ {% endfor %}
+ m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("{{domain.domain}}.{{event.name}}", std::move(messageData)));
{% else %}
- paramsObject->setValue("{{parameter.name}}", ValueConversions<{{resolve_type(parameter).raw_type}}>::serialize({{resolve_type(parameter).to_raw_type % parameter.name}}));
+ m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("{{domain.domain}}.{{event.name}}"));
{% endif %}
- {% endfor %}
- jsonMessage->setObject("params", std::move(paramsObject));
- if (m_frontendChannel)
- m_frontendChannel->sendProtocolNotification(jsonMessage->toJSONString());
}
{% endfor %}
@@ -178,9 +184,28 @@ void Frontend::flush()
m_frontendChannel->flushProtocolNotifications();
}
+namespace {
+
+class RawNotification : public Serializable {
dgozman 2016/11/22 19:39:24 Move this out of template as well.
kozy 2016/11/22 21:01:27 Done.
+public:
+ explicit RawNotification(const String& notification)
+ : m_notification(notification)
+ {
+ }
+
+ String serialize() override {
+ return m_notification;
+ }
+
+private:
+ String m_notification;
+};
+
+} // namespace
+
void Frontend::sendRawNotification(const String& notification)
{
- m_frontendChannel->sendProtocolNotification(notification);
+ m_frontendChannel->sendProtocolNotification(std::unique_ptr<Serializable>(new RawNotification(notification)));
}
// --------------------- Dispatcher.

Powered by Google App Engine
This is Rietveld 408576698