OLD | NEW |
1 // This file is generated | 1 // This file is generated |
2 | 2 |
3 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 4 // Use of this source code is governed by a BSD-style license that can be |
5 // found in the LICENSE file. | 5 // found in the LICENSE file. |
6 | 6 |
7 #ifndef {{class_name}}_h | 7 #ifndef {{class_name}}_h |
8 #define {{class_name}}_h | 8 #define {{class_name}}_h |
9 | 9 |
10 #include "platform/inspector_protocol/TypeBuilder.h" | 10 #include "platform/inspector_protocol/TypeBuilder.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 namespace protocol { | 13 namespace protocol { |
14 | 14 |
15 class FrontendChannel; | 15 class FrontendChannel; |
16 class DispatcherImplWeakPtr; | 16 class BackendImplWeakPtr; |
17 | 17 |
18 class PLATFORM_EXPORT Dispatcher { | 18 class PLATFORM_EXPORT Backend { |
19 public: | 19 public: |
20 static PassOwnPtr<Dispatcher> create(FrontendChannel* frontendChannel); | |
21 virtual ~Dispatcher() { } | |
22 | |
23 class PLATFORM_EXPORT CallbackBase { | 20 class PLATFORM_EXPORT CallbackBase { |
24 public: | 21 public: |
25 CallbackBase(PassOwnPtr<DispatcherImplWeakPtr> backendImpl, int sessionI
d, int id); | 22 virtual ~CallbackBase() { } |
26 virtual ~CallbackBase(); | 23 virtual void sendFailure(const ErrorString&) = 0; |
27 void sendFailure(const ErrorString&); | 24 }; |
28 void dispose(); | 25 {% for domain in api.domains %} |
29 | 26 |
30 protected: | 27 class PLATFORM_EXPORT {{domain.domain}} { |
31 void sendIfActive(PassOwnPtr<protocol::DictionaryValue> partialMessage,
const ErrorString& invocationError); | |
32 | |
33 private: | |
34 OwnPtr<DispatcherImplWeakPtr> m_backendImpl; | |
35 int m_sessionId; | |
36 int m_id; | |
37 }; | |
38 | |
39 {% for domain in api.domains %} | |
40 class PLATFORM_EXPORT {{domain.domain}}CommandHandler { | |
41 public: | 28 public: |
42 {% for command in domain.commands %} | 29 {% for command in domain.commands %} |
43 {% if "redirect" in command %}{% continue %}{% endif %} | 30 {% if "redirect" in command %}{% continue %}{% endif %} |
44 {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}
{% continue %}{% endif %} | 31 {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}
{% continue %}{% endif %} |
45 {% if "async" in command %} | 32 {% if "async" in command %} |
46 class PLATFORM_EXPORT {{command.name | to_title_case}}Callback : public
CallbackBase { | 33 class PLATFORM_EXPORT {{command.name | to_title_case}}Callback : public
CallbackBase { |
47 public: | 34 public: |
48 {{command.name | to_title_case}}Callback(PassOwnPtr<DispatcherImplWe
akPtr>, int sessionId, int id); | 35 virtual void sendSuccess( |
49 void sendSuccess( | |
50 {%- for parameter in command.returns -%} | 36 {%- for parameter in command.returns -%} |
51 {%- if "optional" in parameter -%} | 37 {%- if "optional" in parameter -%} |
52 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.n
ame}} | 38 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.n
ame}} |
53 {%- else -%} | 39 {%- else -%} |
54 {{resolve_type(parameter).pass_type}} {{parameter.name}} | 40 {{resolve_type(parameter).pass_type}} {{parameter.name}} |
55 {%- endif -%} | 41 {%- endif -%} |
56 {%- if not loop.last -%}, {% endif -%} | 42 {%- if not loop.last -%}, {% endif -%} |
57 {%- endfor -%} | 43 {%- endfor -%} |
58 ); | 44 ) = 0; |
59 }; | 45 }; |
60 {% endif %} | 46 {% endif %} |
61 virtual void {{command.name}}(ErrorString* | 47 virtual void {{command.name}}(ErrorString* |
62 {%- for parameter in command.parameters -%} | 48 {%- for parameter in command.parameters -%} |
63 {%- if "optional" in parameter -%} | 49 {%- if "optional" in parameter -%} |
64 , const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.
name}} | 50 , const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.
name}} |
65 {%- else -%} | 51 {%- else -%} |
66 , {{resolve_type(parameter).pass_type}} in_{{parameter.name}} | 52 , {{resolve_type(parameter).pass_type}} in_{{parameter.name}} |
67 {%- endif -%} | 53 {%- endif -%} |
68 {%- endfor -%} | 54 {%- endfor -%} |
69 {%- if "async" in command -%} | 55 {%- if "async" in command -%} |
70 , PassOwnPtr<{{command.name | to_title_case}}Callback> callback | 56 , PassOwnPtr<{{command.name | to_title_case}}Callback> callback |
71 {%- else -%} | 57 {%- else -%} |
72 {%- for parameter in command.returns -%} | 58 {%- for parameter in command.returns -%} |
73 {%- if "optional" in parameter -%} | 59 {%- if "optional" in parameter -%} |
74 , Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}
} | 60 , Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}
} |
75 {%- else -%} | 61 {%- else -%} |
76 , {{resolve_type(parameter).type}}* out_{{parameter.name}} | 62 , {{resolve_type(parameter).type}}* out_{{parameter.name}} |
77 {%- endif -%} | 63 {%- endif -%} |
78 {%- endfor -%} | 64 {%- endfor -%} |
79 {%- endif -%} | 65 {%- endif -%} |
80 ) = 0; | 66 ) = 0; |
81 {% endfor %} | 67 {% endfor %} |
82 | 68 |
83 protected: | 69 protected: |
84 virtual ~{{domain.domain}}CommandHandler() { } | 70 virtual ~{{domain.domain}}() { } |
85 }; | 71 }; |
86 {% endfor %} | 72 {% endfor %} |
87 | |
88 {% for domain in api.domains %} | |
89 virtual void registerAgent({{domain.domain | to_title_case}}CommandHandler*)
= 0; | |
90 {% endfor %} | |
91 | |
92 virtual void clearFrontend() = 0; | |
93 | |
94 enum CommonErrorCode { | |
95 ParseError = 0, | |
96 InvalidRequest, | |
97 MethodNotFound, | |
98 InvalidParams, | |
99 InternalError, | |
100 ServerError, | |
101 LastEntry, | |
102 }; | |
103 | |
104 void reportProtocolError(int sessionId, int callId, CommonErrorCode, const S
tring16& errorMessage) const; | |
105 virtual void reportProtocolError(int sessionId, int callId, CommonErrorCode,
const String16& errorMessage, ErrorSupport*) const = 0; | |
106 virtual void dispatch(int sessionId, const String16& message) = 0; | |
107 static bool getCommandName(const String16& message, String16* result); | |
108 }; | 73 }; |
109 | 74 |
110 } // namespace protocol | 75 } // namespace protocol |
111 } // namespace blink | 76 } // namespace blink |
112 | 77 |
113 #endif // !defined({{class_name}}_h) | 78 #endif // !defined({{class_name}}_h) |
OLD | NEW |