Chromium Code Reviews| Index: third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template |
| diff --git a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template |
| index c649009cedf4a874f8bd01c3d89fb7171a5581fc..5fcc0318bdd469c66e11d1eaeee3081b4a3885ca 100644 |
| --- a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template |
| +++ b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template |
| @@ -9,7 +9,9 @@ |
| #include "platform/PlatformExport.h" |
| #include "platform/inspector_protocol/Array.h" |
| +#include "platform/inspector_protocol/BackendCallback.h" |
| #include "platform/inspector_protocol/ErrorSupport.h" |
| +#include "platform/inspector_protocol/FrontendChannel.h" |
| #include "platform/inspector_protocol/Maybe.h" |
| #include "platform/inspector_protocol/Object.h" |
| #include "platform/inspector_protocol/String16.h" |
| @@ -21,11 +23,13 @@ |
| namespace blink { |
| namespace protocol { |
| -{% for domain in api.domains %} |
| +class PLATFORM_EXPORT Frontend; |
| -// ------------- Forward declarations and typedefs. |
| +{% for domain in api.domains %} |
| namespace {{domain.domain}} { |
| + |
| +// ------------- Forward and enum declarations. |
| {% for type in domain.types %} |
| {% if type.type == "object" %} |
| {% if "properties" in type %} |
| @@ -40,32 +44,20 @@ using {{type.id}} = Object; |
| using {{type.id}} = {{resolve_type(type).type}}; |
| {% endif %} |
| {% endfor %} |
| -} // {{domain.domain}} |
| -{% endfor %} |
| - |
| -// ------------- Enum values from types. |
| -{% for domain in api.domains %} |
| {% for type in domain.types %} |
| {% if "enum" in type %} |
| -namespace {{domain.domain}} { |
| namespace {{type.id}}Enum { |
| {% for literal in type.enum %} |
| PLATFORM_EXPORT extern const char* {{ literal | dash_to_camelcase}}; |
| {% endfor %} |
| } // {{type.id}}Enum |
| -} // {{domain.domain}} |
| {% endif %} |
| {% endfor %} |
| -{% endfor %} |
| - |
| -// ------------- Enum values from params. |
| -{% for domain in api.domains %} |
| {% for command in join_arrays(domain, ["commands", "events"]) %} |
| {% for param in join_arrays(command, ["parameters", "returns"]) %} |
| {% if "enum" in param %} |
| -namespace {{domain.domain}} { |
| namespace {{command.name | to_title_case}} { |
| namespace {{param.name | to_title_case}}Enum { |
| {% for literal in param.enum %} |
| @@ -73,16 +65,11 @@ PLATFORM_EXPORT extern const char* {{ literal | dash_to_camelcase}}; |
| {% endfor %} |
| } // {{param.name | to_title_case}}Enum |
| } // {{command.name | to_title_case }} |
| -} // {{domain.domain}} |
| {% endif %} |
| {% endfor %} |
| {% endfor %} |
| -{% endfor %} |
| // ------------- Type and builder declarations. |
| -{% for domain in api.domains %} |
| - |
| -namespace {{domain.domain}} { |
| {% for type in domain.types %} |
| {% if not (type.type == "object") or not ("properties" in type) %}{% continue %}{% endif %} |
| {% set type_def = type_definition(domain.domain + "." + type.id)%} |
| @@ -187,7 +174,79 @@ private: |
| {% endfor %} |
| -} // {{domain.domain}} |
| +// ------------- Backend interface. |
| + |
| +class PLATFORM_EXPORT Backend { |
| +public: |
| + {% for command in domain.commands %} |
| + {% if "redirect" in command %}{% continue %}{% endif %} |
| + {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %} |
| + {% if "async" in command %} |
| + class PLATFORM_EXPORT {{command.name | to_title_case}}Callback : public BackendCallback { |
| + public: |
| + virtual void sendSuccess( |
| + {%- for parameter in command.returns -%} |
| + {%- if "optional" in parameter -%} |
| + const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} |
| + {%- else -%} |
| + {{resolve_type(parameter).pass_type}} {{parameter.name}} |
| + {%- endif -%} |
| + {%- if not loop.last -%}, {% endif -%} |
| + {%- endfor -%} |
| + ) = 0; |
| + }; |
| + {% endif %} |
| + virtual void {{command.name}}(ErrorString* |
| + {%- for parameter in command.parameters -%} |
| + {%- if "optional" in parameter -%} |
| + , const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.name}} |
| + {%- else -%} |
| + , {{resolve_type(parameter).pass_type}} in_{{parameter.name}} |
| + {%- endif -%} |
| + {%- endfor -%} |
| + {%- if "async" in command -%} |
| + , std::unique_ptr<{{command.name | to_title_case}}Callback> callback |
| + {%- else -%} |
| + {%- for parameter in command.returns -%} |
| + {%- if "optional" in parameter -%} |
| + , Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}} |
| + {%- else -%} |
| + , {{resolve_type(parameter).type}}* out_{{parameter.name}} |
| + {%- endif -%} |
| + {%- endfor -%} |
| + {%- endif -%} |
| + ) = 0; |
| + {% endfor %} |
| + |
| +protected: |
| + virtual ~Backend() { } |
| +}; |
| + |
| +// ------------- Frontend interface. |
| + |
| +class PLATFORM_EXPORT Frontend { |
| +public: |
| + static Frontend* from(protocol::Frontend* frontend); |
| + Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { } |
|
dgozman
2016/05/26 20:55:30
explicit
|
| + {% for event in domain.events %} |
| + {% if "handlers" in event and not ("renderer" in event["handlers"]) %}{% continue %}{% endif %} |
| + void {{event.name}}( |
| + {%- for parameter in event.parameters -%} |
| + {%- if "optional" in parameter -%} |
| + const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.name}} = Maybe<{{resolve_type(parameter).raw_type}}>() |
| + {%- else -%} |
| + {{resolve_type(parameter).pass_type}} {{parameter.name}} |
| + {%- endif -%}{%- if not loop.last -%}, {% endif -%} |
| + {%- endfor -%} |
| + ); |
| + {% endfor %} |
| + |
| + void flush() { m_frontendChannel->flushProtocolNotifications(); } |
| +private: |
| + FrontendChannel* m_frontendChannel; |
| +}; |
| + |
| +} // namespace {{domain.domain}} |
| {% endfor %} |
| } // namespace protocol |