Line data Source code
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 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 10 : 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 10 : void setLevel(const String& value) { m_level = value; }
59 :
60 : String getText() { return m_text; }
61 10 : 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 serialize() override { return toValue()->serialize(); }
77 : std::unique_ptr<ConsoleMessage> clone() const;
78 :
79 : template<int STATE>
80 : class ConsoleMessageBuilder {
81 : public:
82 : enum {
83 : NoFieldsSet = 0,
84 : SourceSet = 1 << 1,
85 : LevelSet = 1 << 2,
86 : TextSet = 1 << 3,
87 : AllFieldsSet = (SourceSet | LevelSet | TextSet | 0)};
88 :
89 :
90 : ConsoleMessageBuilder<STATE | SourceSet>& setSource(const String& value)
91 : {
92 : static_assert(!(STATE & SourceSet), "property source should not be set yet");
93 : m_result->setSource(value);
94 : return castState<SourceSet>();
95 : }
96 :
97 : ConsoleMessageBuilder<STATE | LevelSet>& setLevel(const String& value)
98 : {
99 : static_assert(!(STATE & LevelSet), "property level should not be set yet");
100 : m_result->setLevel(value);
101 : return castState<LevelSet>();
102 : }
103 :
104 : ConsoleMessageBuilder<STATE | TextSet>& setText(const String& value)
105 : {
106 : static_assert(!(STATE & TextSet), "property text should not be set yet");
107 : m_result->setText(value);
108 : return castState<TextSet>();
109 : }
110 :
111 : ConsoleMessageBuilder<STATE>& setUrl(const String& value)
112 : {
113 : m_result->setUrl(value);
114 : return *this;
115 : }
116 :
117 : ConsoleMessageBuilder<STATE>& setLine(int value)
118 : {
119 : m_result->setLine(value);
120 : return *this;
121 : }
122 :
123 : ConsoleMessageBuilder<STATE>& setColumn(int value)
124 : {
125 : m_result->setColumn(value);
126 : return *this;
127 : }
128 :
129 : std::unique_ptr<ConsoleMessage> build()
130 : {
131 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
132 : return std::move(m_result);
133 : }
134 :
135 : private:
136 : friend class ConsoleMessage;
137 20 : ConsoleMessageBuilder() : m_result(new ConsoleMessage()) { }
138 :
139 : template<int STEP> ConsoleMessageBuilder<STATE | STEP>& castState()
140 : {
141 : return *reinterpret_cast<ConsoleMessageBuilder<STATE | STEP>*>(this);
142 : }
143 :
144 : std::unique_ptr<protocol::Console::ConsoleMessage> m_result;
145 : };
146 :
147 : static ConsoleMessageBuilder<0> create()
148 : {
149 10 : return ConsoleMessageBuilder<0>();
150 : }
151 :
152 : private:
153 10 : ConsoleMessage()
154 10 : {
155 10 : }
156 :
157 : String m_source;
158 : String m_level;
159 : String m_text;
160 : Maybe<String> m_url;
161 : Maybe<int> m_line;
162 : Maybe<int> m_column;
163 : };
164 :
165 :
166 : class MessageAddedNotification : public Serializable{
167 : PROTOCOL_DISALLOW_COPY(MessageAddedNotification);
168 : public:
169 : static std::unique_ptr<MessageAddedNotification> fromValue(protocol::Value* value, ErrorSupport* errors);
170 :
171 20 : ~MessageAddedNotification() override { }
172 :
173 : protocol::Console::ConsoleMessage* getMessage() { return m_message.get(); }
174 : void setMessage(std::unique_ptr<protocol::Console::ConsoleMessage> value) { m_message = std::move(value); }
175 :
176 : std::unique_ptr<protocol::DictionaryValue> toValue() const;
177 30 : String serialize() override { return toValue()->serialize(); }
178 : std::unique_ptr<MessageAddedNotification> clone() const;
179 :
180 : template<int STATE>
181 : class MessageAddedNotificationBuilder {
182 : public:
183 : enum {
184 : NoFieldsSet = 0,
185 : MessageSet = 1 << 1,
186 : AllFieldsSet = (MessageSet | 0)};
187 :
188 :
189 : MessageAddedNotificationBuilder<STATE | MessageSet>& setMessage(std::unique_ptr<protocol::Console::ConsoleMessage> value)
190 : {
191 : static_assert(!(STATE & MessageSet), "property message should not be set yet");
192 : m_result->setMessage(std::move(value));
193 : return castState<MessageSet>();
194 : }
195 :
196 : std::unique_ptr<MessageAddedNotification> build()
197 : {
198 : static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
199 : return std::move(m_result);
200 : }
201 :
202 : private:
203 : friend class MessageAddedNotification;
204 10 : MessageAddedNotificationBuilder() : m_result(new MessageAddedNotification()) { }
205 :
206 : template<int STEP> MessageAddedNotificationBuilder<STATE | STEP>& castState()
207 : {
208 : return *reinterpret_cast<MessageAddedNotificationBuilder<STATE | STEP>*>(this);
209 : }
210 :
211 : std::unique_ptr<protocol::Console::MessageAddedNotification> m_result;
212 : };
213 :
214 : static MessageAddedNotificationBuilder<0> create()
215 : {
216 : return MessageAddedNotificationBuilder<0>();
217 : }
218 :
219 : private:
220 : MessageAddedNotification()
221 10 : {
222 : }
223 :
224 : std::unique_ptr<protocol::Console::ConsoleMessage> m_message;
225 : };
226 :
227 :
228 : // ------------- Backend interface.
229 :
230 3834 : class Backend {
231 : public:
232 3834 : virtual ~Backend() { }
233 :
234 : virtual DispatchResponse clearMessages() = 0;
235 : virtual DispatchResponse disable() = 0;
236 : virtual DispatchResponse enable() = 0;
237 :
238 : };
239 :
240 : // ------------- Frontend interface.
241 :
242 : class Frontend {
243 : public:
244 3834 : explicit Frontend(FrontendChannel* frontendChannel) : m_frontendChannel(frontendChannel) { }
245 : void messageAdded(std::unique_ptr<protocol::Console::ConsoleMessage> message);
246 :
247 : void flush();
248 : void sendRawNotification(const String&);
249 : private:
250 : FrontendChannel* m_frontendChannel;
251 : };
252 :
253 : // ------------- Dispatcher.
254 :
255 : class Dispatcher {
256 : public:
257 : static void wire(UberDispatcher*, Backend*);
258 :
259 : private:
260 : Dispatcher() { }
261 : };
262 :
263 : // ------------- Metainfo.
264 :
265 : class Metainfo {
266 : public:
267 : using BackendClass = Backend;
268 : using FrontendClass = Frontend;
269 : using DispatcherClass = Dispatcher;
270 : static const char domainName[];
271 : static const char commandPrefix[];
272 : static const char version[];
273 : };
274 :
275 : } // namespace Console
276 : } // namespace v8_inspector
277 : } // namespace protocol
278 :
279 : #endif // !defined(v8_inspector_protocol_Console_h)
|