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 DispatcherImpl; | 16 class DispatcherImplWeakPtr; |
17 using ErrorString = String; | 17 using ErrorString = String; |
18 | 18 |
19 class PLATFORM_EXPORT Dispatcher: public RefCounted<Dispatcher> { | 19 class PLATFORM_EXPORT Dispatcher { |
20 public: | 20 public: |
21 static PassRefPtr<Dispatcher> create(FrontendChannel* frontendChannel); | 21 static PassOwnPtr<Dispatcher> create(FrontendChannel* frontendChannel); |
22 virtual ~Dispatcher() { } | 22 virtual ~Dispatcher() { } |
23 | 23 |
24 class PLATFORM_EXPORT CallbackBase: public RefCounted<CallbackBase> { | 24 class PLATFORM_EXPORT CallbackBase { |
25 public: | 25 public: |
26 CallbackBase(PassRefPtr<DispatcherImpl> backendImpl, int sessionId, int
id); | 26 CallbackBase(PassOwnPtr<DispatcherImplWeakPtr> backendImpl, int sessionI
d, int id); |
27 virtual ~CallbackBase(); | 27 virtual ~CallbackBase(); |
28 void sendFailure(const ErrorString&); | 28 void sendFailure(const ErrorString&); |
29 bool isActive(); | 29 void dispose(); |
30 | 30 |
31 protected: | 31 protected: |
32 void sendIfActive(PassOwnPtr<protocol::DictionaryValue> partialMessage,
const ErrorString& invocationError); | 32 void sendIfActive(PassOwnPtr<protocol::DictionaryValue> partialMessage,
const ErrorString& invocationError); |
33 | 33 |
34 private: | 34 private: |
35 void disable() { m_alreadySent = true; } | 35 OwnPtr<DispatcherImplWeakPtr> m_backendImpl; |
36 | |
37 RefPtr<DispatcherImpl> m_backendImpl; | |
38 int m_sessionId; | 36 int m_sessionId; |
39 int m_id; | 37 int m_id; |
40 bool m_alreadySent; | |
41 | |
42 friend class DispatcherImpl; | |
43 }; | 38 }; |
44 | 39 |
45 {% for domain in api.domains %} | 40 {% for domain in api.domains %} |
46 class PLATFORM_EXPORT {{domain.domain}}CommandHandler { | 41 class PLATFORM_EXPORT {{domain.domain}}CommandHandler { |
47 public: | 42 public: |
48 {% for command in domain.commands %} | 43 {% for command in domain.commands %} |
49 {% if "redirect" in command %}{% continue %}{% endif %} | 44 {% if "redirect" in command %}{% continue %}{% endif %} |
50 {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}
{% continue %}{% endif %} | 45 {% if ("handlers" in command) and not ("renderer" in command["handlers"]) %}
{% continue %}{% endif %} |
51 {% if "async" in command %} | 46 {% if "async" in command %} |
52 class PLATFORM_EXPORT {{command.name | to_title_case}}Callback : public
CallbackBase { | 47 class PLATFORM_EXPORT {{command.name | to_title_case}}Callback : public
CallbackBase { |
53 public: | 48 public: |
54 {{command.name | to_title_case}}Callback(PassRefPtr<DispatcherImpl>,
int sessionId, int id); | 49 {{command.name | to_title_case}}Callback(PassOwnPtr<DispatcherImplWe
akPtr>, int sessionId, int id); |
55 void sendSuccess( | 50 void sendSuccess( |
56 {%- for parameter in command.returns -%} | 51 {%- for parameter in command.returns -%} |
57 {%- if "optional" in parameter -%} | 52 {%- if "optional" in parameter -%} |
58 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.n
ame}} | 53 const Maybe<{{resolve_type(parameter).raw_type}}>& {{parameter.n
ame}} |
59 {%- else -%} | 54 {%- else -%} |
60 {{resolve_type(parameter).pass_type}} {{parameter.name}} | 55 {{resolve_type(parameter).pass_type}} {{parameter.name}} |
61 {%- endif -%} | 56 {%- endif -%} |
62 {%- if not loop.last -%}, {% endif -%} | 57 {%- if not loop.last -%}, {% endif -%} |
63 {%- endfor -%} | 58 {%- endfor -%} |
64 ); | 59 ); |
65 }; | 60 }; |
66 {% endif %} | 61 {% endif %} |
67 virtual void {{command.name}}(ErrorString* | 62 virtual void {{command.name}}(ErrorString* |
68 {%- for parameter in command.parameters -%} | 63 {%- for parameter in command.parameters -%} |
69 {%- if "optional" in parameter -%} | 64 {%- if "optional" in parameter -%} |
70 , const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.
name}} | 65 , const Maybe<{{resolve_type(parameter).raw_type}}>& in_{{parameter.
name}} |
71 {%- else -%} | 66 {%- else -%} |
72 , {{resolve_type(parameter).pass_type}} in_{{parameter.name}} | 67 , {{resolve_type(parameter).pass_type}} in_{{parameter.name}} |
73 {%- endif -%} | 68 {%- endif -%} |
74 {%- endfor -%} | 69 {%- endfor -%} |
75 {%- if "async" in command -%} | 70 {%- if "async" in command -%} |
76 , PassRefPtr<{{command.name | to_title_case}}Callback> callback | 71 , PassOwnPtr<{{command.name | to_title_case}}Callback> callback |
77 {%- else -%} | 72 {%- else -%} |
78 {%- for parameter in command.returns -%} | 73 {%- for parameter in command.returns -%} |
79 {%- if "optional" in parameter -%} | 74 {%- if "optional" in parameter -%} |
80 , Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}
} | 75 , Maybe<{{resolve_type(parameter).raw_type}}>* out_{{parameter.name}
} |
81 {%- else -%} | 76 {%- else -%} |
82 , {{resolve_type(parameter).type}}* out_{{parameter.name}} | 77 , {{resolve_type(parameter).type}}* out_{{parameter.name}} |
83 {%- endif -%} | 78 {%- endif -%} |
84 {%- endfor -%} | 79 {%- endfor -%} |
85 {%- endif -%} | 80 {%- endif -%} |
86 ) = 0; | 81 ) = 0; |
(...skipping 25 matching lines...) Expand all Loading... |
112 virtual void dispatch(int sessionId, const String& message) = 0; | 107 virtual void dispatch(int sessionId, const String& message) = 0; |
113 static bool getCommandName(const String& message, String* result); | 108 static bool getCommandName(const String& message, String* result); |
114 }; | 109 }; |
115 | 110 |
116 } // namespace protocol | 111 } // namespace protocol |
117 } // namespace blink | 112 } // namespace blink |
118 | 113 |
119 using blink::protocol::ErrorString; | 114 using blink::protocol::ErrorString; |
120 | 115 |
121 #endif // !defined({{class_name}}_h) | 116 #endif // !defined({{class_name}}_h) |
OLD | NEW |