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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_h.template

Issue 1702673002: DevTools: migrate remote debugging protocol generators to jinja2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // This file is generated
2
3 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
6
7 #ifndef {{class_name}}_h
8 #define {{class_name}}_h
9
10 #include "platform/inspector_protocol/TypeBuilder.h"
11
12 namespace blink {
13 namespace protocol {
14
15 class FrontendChannel;
16 class DispatcherImpl;
17 using ErrorString = String;
18
19 class PLATFORM_EXPORT Dispatcher: public RefCounted<Dispatcher> {
20 public:
21 static PassRefPtr<Dispatcher> create(FrontendChannel* frontendChannel);
22 virtual ~Dispatcher() { }
23
24 class PLATFORM_EXPORT CallbackBase: public RefCounted<CallbackBase> {
25 public:
26 CallbackBase(PassRefPtr<DispatcherImpl> backendImpl, int sessionId, int id);
27 virtual ~CallbackBase();
28 void sendFailure(const ErrorString&);
29 bool isActive();
30
31 protected:
32 void sendIfActive(PassRefPtr<JSONObject> partialMessage, const ErrorStri ng& invocationError, PassRefPtr<JSONValue> errorData);
33
34 private:
35 void disable() { m_alreadySent = true; }
36
37 RefPtr<DispatcherImpl> m_backendImpl;
38 int m_sessionId;
39 int m_id;
40 bool m_alreadySent;
41
42 friend class DispatcherImpl;
43 };
44
45 {% for domain in api.domains %}
46 class PLATFORM_EXPORT {{domain.domain}}CommandHandler {
47 public:
48 {% for command in domain.commands %}
49 {% if "redirect" in command %}{% continue %}{% endif %}
50 {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %} {% continue %}{% endif %}
51 {% if "async" in command %}
52 class PLATFORM_EXPORT {{command.name | to_title_case}}Callback : public CallbackBase {
53 public:
54 {{command.name | to_title_case}}Callback(PassRefPtr<DispatcherImpl>, int sessionId, int id);
55 void sendSuccess(
56 {%- for parameter in command.returns -%}
57 {%- if "optional" in parameter -%}
58 {{resolve_type(parameter).optional_pass_type}} {{parameter.name} }
59 {%- else -%}
60 {{resolve_type(parameter).pass_type}} {{parameter.name}}
61 {%- endif -%}
62 {%- if not loop.last -%}, {% endif -%}
63 {%- endfor -%}
64 );
65 };
66 {% endif %}
67 virtual void {{command.name}}(ErrorString*
68 {%- for parameter in command.parameters -%}
69 {%- if "optional" in parameter -%}
70 , {{resolve_type(parameter).optional_pass_type}} in_{{parameter.name }}
71 {%- else -%}
72 , {{resolve_type(parameter).pass_type}} in_{{parameter.name}}
73 {%- endif -%}
74 {%- endfor -%}
75 {%- if "async" in command -%}
76 , PassRefPtr<{{command.name | to_title_case}}Callback> callback
77 {%- else -%}
78 {%- for parameter in command.returns -%}
79 {%- if "optional" in parameter -%}
80 , {{resolve_type(parameter).optional_type}}* out_{{parameter.name}}
81 {%- else -%}
82 , {{resolve_type(parameter).type}}* out_{{parameter.name}}
83 {%- endif -%}
84 {%- endfor -%}
85 {%- endif -%}
86 ) = 0;
87 {% endfor %}
88
89 protected:
90 virtual ~{{domain.domain}}CommandHandler() { }
91 };
92 {% endfor %}
93
94 {% for domain in api.domains %}
95 virtual void registerAgent({{domain.domain | to_title_case}}CommandHandler*) = 0;
96 {% endfor %}
97
98 virtual void clearFrontend() = 0;
99
100 enum CommonErrorCode {
101 ParseError = 0,
102 InvalidRequest,
103 MethodNotFound,
104 InvalidParams,
105 InternalError,
106 ServerError,
107 LastEntry,
108 };
109
110 void reportProtocolError(int sessionId, int callId, CommonErrorCode, const S tring& errorMessage) const;
111 virtual void reportProtocolError(int sessionId, int callId, CommonErrorCode, const String& errorMessage, PassRefPtr<JSONValue> data) const = 0;
112 virtual void dispatch(int sessionId, const String& message) = 0;
113 static bool getCommandName(const String& message, String* result);
114 };
115
116 } // namespace protocol
117 } // namespace blink
118
119 using blink::protocol::ErrorString;
120
121 #endif // !defined({{class_name}}_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698