Line data Source code
1 : // This file is generated by TypeBuilder_h.template.
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 v8_inspector_protocol_Console_h
8 : #define v8_inspector_protocol_Console_h
9 :
10 : #include "src/inspector/protocol/Protocol.h"
11 : // For each imported domain we generate a ValueConversions struct instead of a full domain definition
12 : // and include Domain::API version from there.
13 : #include "src/inspector/protocol/Runtime.h"
14 :
15 : namespace v8_inspector {
16 : namespace protocol {
17 : namespace Console {
18 :
19 : // ------------- Forward and enum declarations.
20 : class ConsoleMessage;
21 : class MessageAddedNotification;
22 :
23 : // ------------- Type and builder declarations.
24 :
25 : class ConsoleMessage : public Serializable{
26 : PROTOCOL_DISALLOW_COPY(ConsoleMessage);
27 : public:
28 : static std::unique_ptr<ConsoleMessage> fromValue(protocol::Value* value, ErrorSupport* errors);
29 :
30 30 : ~ConsoleMessage() override { }
31 :
32 : struct SourceEnum {
33 : static const char* Xml;
34 : static const char* Javascript;
35 : static const char* Network;
36 : static const char* ConsoleApi;
37 : static const char* Storage;
38 : static const char* Appcache;
39 : static const char* Rendering;
40 : static const char* Security;
41 : static const char* Other;
42 : static const char* Deprecation;
43 : static const char* Worker;
44 : }; // SourceEnum
45 :
46 : String getSource() { return m_source; }
47 : void setSource(const String& value) { m_source = value; }
48 :
49 : struct LevelEnum {
50 : static const char* Log;
51 : static const char* Warning;
52 : static const char* Error;
53 : static const char* Debug;
54 : static const char* Info;
55 : }; // LevelEnum
56 :
57 : String getLevel() { return m_level; }
58 : void setLevel(const String& value) { m_level = value; }
59 :
60 : String getText() { return m_text; }
61 : void setText(const String& value) { m_text = value; }
62 :
63 : bool hasUrl() { return m_url.isJust(); }
64 : String getUrl(const String& defaultValue) { return m_url.isJust() ? m_url.fromJust() : defaultValue; }
65 20 : void setUrl(const String& value) { m_url = value; }
66 :
67 : bool hasLine() { return m_line.isJust(); }
68 : int getLine(int defaultValue) { return m_line.isJust() ? m_line.fromJust() : defaultValue; }
69 : void setLine(int value) { m_line = value; }
70 :
71 : bool hasColumn() { return m_column.isJust(); }
72 : int getColumn(int defaultValue) { return m_column.isJust() ? m_column.fromJust() : defaultValue; }
73 : void setColumn(int value) { m_column = value; }
74 :
75 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
76 0 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
77 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
78 : String toJSON() const { return toValue()->toJSONString(); }
79 : std::unique_ptr<ConsoleMessage> clone() const;
80 :
81 : template<int STATE>
82 : class ConsoleMessageBuilder {
83 : public:
84 : enum {
85 : NoFieldsSet = 0,
86 : SourceSet = 1 << 1,
87 : LevelSet = 1 << 2,
88 : TextSet = 1 << 3,
89 : AllFieldsSet = (SourceSet | LevelSet | TextSet | 0)};
90 :
91 :
92 : ConsoleMessageBuilder<STATE | SourceSet>& setSource(const String& value)
93 : {
94 : static_assert(!(STATE & SourceSet), "property source should not be set yet");
95 : m_result->setSource(value);
96 : return castState<SourceSet>();
97 : }
98 :
99 : ConsoleMessageBuilder<STATE | LevelSet>& setLevel(const String& value)
100 : {
101 : static_assert(!(STATE & LevelSet), "property level should not be set yet");
102 : m_result->setLevel(value);
103 : return castState<LevelSet>();
104 : }
105 :
106 : ConsoleMessageBuilder<STATE | TextSet>& setText(const String& value)
107 : {
108 : static_assert(!(STATE & TextSet), "property text should not be set yet");
109 : m_result->setText(value);
110 : return castState<TextSet>();
111 : }
112 :
113 : ConsoleMessageBuilder<STATE>& setUrl(const String& value)
114 : {
115 : m_result->setUrl(value);
116 : return *this;
117 : }
118 :
119 : ConsoleMessageBuilder<STATE>& setLine(int value)
120 : {
121 : m_result->setLine(value);
122 : return *this;
123 : }
124 :
125 : ConsoleMessageBuilder<STATE>& setColumn(int value)
126 : {
127 : m_result->setColumn(value);
128 : return *this;
129 : }
130 :
131 : std::unique_ptr<ConsoleMessage> build()
132 : {
133 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
134 : return std::move(m_result);
135 : }
136 :
137 : private:
138 : friend class ConsoleMessage;
139 20 : ConsoleMessageBuilder() : m_result(new ConsoleMessage()) { }
140 :
141 : template<int STEP> ConsoleMessageBuilder<STATE | STEP>& castState()
142 : {
143 : return *reinterpret_cast<ConsoleMessageBuilder<STATE | STEP>*>(this);
144 : }
145 :
146 : std::unique_ptr<protocol::Console::ConsoleMessage> m_result;
147 : };
148 :
149 : static ConsoleMessageBuilder<0> create()
150 : {
151 10 : return ConsoleMessageBuilder<0>();
152 : }
153 :
154 : private:
155 : ConsoleMessage()
156 10 : {
157 : }
158 :
159 : String m_source;
160 : String m_level;
161 : String m_text;
162 : Maybe<String> m_url;
163 : Maybe<int> m_line;
164 : Maybe<int> m_column;
165 : };
166 :
167 :
168 : class MessageAddedNotification : public Serializable{
169 : PROTOCOL_DISALLOW_COPY(MessageAddedNotification);
170 : public:
171 : static std::unique_ptr<MessageAddedNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
172 :
173 20 : ~MessageAddedNotification() override { }
174 :
175 : protocol::Console::ConsoleMessage* getMessage() { return m_message.get(); }
176 : void setMessage(std::unique_ptr<protocol::Console::ConsoleMessage> value) { m_message = std::move(value); }
177 :
178 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
179 30 : String serializeToJSON() override { return toValue()->serializeToJSON(); }
180 0 : std::vector<uint8_t> serializeToBinary() override { return toValue()->serializeToBinary(); }
181 : String toJSON() const { return toValue()->toJSONString(); }
182 : std::unique_ptr<MessageAddedNotification> clone() const;
183 :
184 : template<int STATE>
185 : class MessageAddedNotificationBuilder {
186 : public:
187 : enum {
188 : NoFieldsSet = 0,
189 : MessageSet = 1 << 1,
190 : AllFieldsSet = (MessageSet | 0)};
191 :
192 :
193 : MessageAddedNotificationBuilder<STATE | MessageSet>& setMessage(std::unique_ptr<protocol::Console::ConsoleMessage> value)
194 : {
195 : static_assert(!(STATE & MessageSet), "property message should not be set yet");
196 : m_result->setMessage(std::move(value));
197 : return castState<MessageSet>();
198 : }
199 :
200 : std::unique_ptr<MessageAddedNotification> build()
201 : {
202 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
203 : return std::move(m_result);
204 : }
205 :
206 : private:
207 : friend class MessageAddedNotification;
208 10 : MessageAddedNotificationBuilder() : m_result(new MessageAddedNotification()) { }
209 :
210 : template<int STEP> MessageAddedNotificationBuilder<STATE | STEP>& castState()
211 : {
212 : return *reinterpret_cast<MessageAddedNotificationBuilder<STATE | STEP>*>(this);
213 : }
214 :
215 : std::unique_ptr<protocol::Console::MessageAddedNotification> m_result;
216 : };
217 :
218 : static MessageAddedNotificationBuilder<0> create()
219 : {
220 : return MessageAddedNotificationBuilder<0>();
221 : }
222 :
223 : private:
224 : MessageAddedNotification()
225 10 : {
226 : }
227 :
228 : std::unique_ptr<protocol::Console::ConsoleMessage> m_message;
229 : };
230 :
231 :
232 : // ------------- Backend interface.
233 :
234 3832 : class Backend {
235 : public:
236 3832 : virtual ~Backend() { }
237 :
238 : virtual DispatchResponse clearMessages() = 0;
239 : virtual DispatchResponse disable() = 0;
240 : virtual DispatchResponse enable() = 0;
241 :
242 : };
243 :
244 : // ------------- Frontend interface.
245 :
246 : class Frontend {
247 : public:
248 3832 : explicit Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
249 : void messageAdded(std::unique_ptr<protocol::Console::ConsoleMessage> message);
250 :
251 : void flush();
252 : void sendRawNotification(String);
253 : void sendRawNotification(std::vector<uint8_t>);
254 : private:
255 : FrontendChannel* m_frontendChannel;
256 : };
257 :
258 : // ------------- Dispatcher.
259 :
260 : class Dispatcher {
261 : public:
262 : static void wire(UberDispatcher*, Backend*);
263 :
264 : private:
265 : Dispatcher() { }
266 : };
267 :
268 : // ------------- Metainfo.
269 :
270 : class Metainfo {
271 : public:
272 : using BackendClass = Backend;
273 : using FrontendClass = Frontend;
274 : using DispatcherClass = Dispatcher;
275 : static const char domainName[];
276 : static const char commandPrefix[];
277 : static const char version[];
278 : };
279 :
280 : } // namespace Console
281 : } // namespace v8_inspector
282 : } // namespace protocol
283 :
284 : #endif // !defined(v8_inspector_protocol_Console_h)
|