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 : #include "src/inspector/protocol/Debugger.h"
8 :
9 : #include "src/inspector/protocol/Protocol.h"
10 :
11 : namespace v8_inspector {
12 : namespace protocol {
13 : namespace Debugger {
14 :
15 : // ------------- Enum values from types.
16 :
17 : const char Metainfo::domainName[] = "Debugger";
18 : const char Metainfo::commandPrefix[] = "Debugger.";
19 : const char Metainfo::version[] = "1.2";
20 :
21 4471 : std::unique_ptr<Location> Location::fromValue(protocol::Value* value, ErrorSupport* errors)
22 : {
23 4471 : if (!value || value->type() != protocol::Value::TypeObject) {
24 5 : errors->addError("object expected");
25 : return nullptr;
26 : }
27 :
28 2233 : std::unique_ptr<Location> result(new Location());
29 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
30 2233 : errors->push();
31 4466 : protocol::Value* scriptIdValue = object->get("scriptId");
32 2233 : errors->setName("scriptId");
33 4466 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
34 4466 : protocol::Value* lineNumberValue = object->get("lineNumber");
35 2233 : errors->setName("lineNumber");
36 2233 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
37 4466 : protocol::Value* columnNumberValue = object->get("columnNumber");
38 2233 : if (columnNumberValue) {
39 2023 : errors->setName("columnNumber");
40 2023 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
41 : }
42 2233 : errors->pop();
43 2233 : if (errors->hasErrors())
44 : return nullptr;
45 : return result;
46 : }
47 :
48 427505 : std::unique_ptr<protocol::DictionaryValue> Location::toValue() const
49 : {
50 427505 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
51 2137525 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
52 2137525 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
53 427505 : if (m_columnNumber.isJust())
54 1710020 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber.fromJust()));
55 427505 : return result;
56 : }
57 :
58 0 : std::unique_ptr<Location> Location::clone() const
59 : {
60 0 : ErrorSupport errors;
61 0 : return fromValue(toValue().get(), &errors);
62 : }
63 :
64 190 : std::unique_ptr<ScriptPosition> ScriptPosition::fromValue(protocol::Value* value, ErrorSupport* errors)
65 : {
66 190 : if (!value || value->type() != protocol::Value::TypeObject) {
67 0 : errors->addError("object expected");
68 : return nullptr;
69 : }
70 :
71 95 : std::unique_ptr<ScriptPosition> result(new ScriptPosition());
72 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
73 95 : errors->push();
74 190 : protocol::Value* lineNumberValue = object->get("lineNumber");
75 95 : errors->setName("lineNumber");
76 95 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
77 190 : protocol::Value* columnNumberValue = object->get("columnNumber");
78 95 : errors->setName("columnNumber");
79 95 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
80 95 : errors->pop();
81 95 : if (errors->hasErrors())
82 : return nullptr;
83 : return result;
84 : }
85 :
86 0 : std::unique_ptr<protocol::DictionaryValue> ScriptPosition::toValue() const
87 : {
88 0 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
89 0 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
90 0 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber));
91 0 : return result;
92 : }
93 :
94 0 : std::unique_ptr<ScriptPosition> ScriptPosition::clone() const
95 : {
96 0 : ErrorSupport errors;
97 0 : return fromValue(toValue().get(), &errors);
98 : }
99 :
100 0 : std::unique_ptr<CallFrame> CallFrame::fromValue(protocol::Value* value, ErrorSupport* errors)
101 : {
102 0 : if (!value || value->type() != protocol::Value::TypeObject) {
103 0 : errors->addError("object expected");
104 : return nullptr;
105 : }
106 :
107 0 : std::unique_ptr<CallFrame> result(new CallFrame());
108 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
109 0 : errors->push();
110 0 : protocol::Value* callFrameIdValue = object->get("callFrameId");
111 0 : errors->setName("callFrameId");
112 0 : result->m_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
113 0 : protocol::Value* functionNameValue = object->get("functionName");
114 0 : errors->setName("functionName");
115 0 : result->m_functionName = ValueConversions<String>::fromValue(functionNameValue, errors);
116 0 : protocol::Value* functionLocationValue = object->get("functionLocation");
117 0 : if (functionLocationValue) {
118 0 : errors->setName("functionLocation");
119 0 : result->m_functionLocation = ValueConversions<protocol::Debugger::Location>::fromValue(functionLocationValue, errors);
120 : }
121 0 : protocol::Value* locationValue = object->get("location");
122 0 : errors->setName("location");
123 0 : result->m_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
124 0 : protocol::Value* urlValue = object->get("url");
125 0 : errors->setName("url");
126 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
127 0 : protocol::Value* scopeChainValue = object->get("scopeChain");
128 0 : errors->setName("scopeChain");
129 0 : result->m_scopeChain = ValueConversions<protocol::Array<protocol::Debugger::Scope>>::fromValue(scopeChainValue, errors);
130 0 : protocol::Value* thisValue = object->get("this");
131 0 : errors->setName("this");
132 0 : result->m_this = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(thisValue, errors);
133 0 : protocol::Value* returnValueValue = object->get("returnValue");
134 0 : if (returnValueValue) {
135 0 : errors->setName("returnValue");
136 0 : result->m_returnValue = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(returnValueValue, errors);
137 : }
138 0 : errors->pop();
139 0 : if (errors->hasErrors())
140 : return nullptr;
141 : return result;
142 : }
143 :
144 124940 : std::unique_ptr<protocol::DictionaryValue> CallFrame::toValue() const
145 : {
146 124940 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
147 624700 : result->setValue("callFrameId", ValueConversions<String>::toValue(m_callFrameId));
148 624700 : result->setValue("functionName", ValueConversions<String>::toValue(m_functionName));
149 124940 : if (m_functionLocation.isJust())
150 498176 : result->setValue("functionLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_functionLocation.fromJust()));
151 499760 : result->setValue("location", ValueConversions<protocol::Debugger::Location>::toValue(m_location.get()));
152 624700 : result->setValue("url", ValueConversions<String>::toValue(m_url));
153 499760 : result->setValue("scopeChain", ValueConversions<protocol::Array<protocol::Debugger::Scope>>::toValue(m_scopeChain.get()));
154 499760 : result->setValue("this", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_this.get()));
155 124940 : if (m_returnValue.isJust())
156 21996 : result->setValue("returnValue", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_returnValue.fromJust()));
157 124940 : return result;
158 : }
159 :
160 0 : std::unique_ptr<CallFrame> CallFrame::clone() const
161 : {
162 0 : ErrorSupport errors;
163 0 : return fromValue(toValue().get(), &errors);
164 : }
165 :
166 : const char* Scope::TypeEnum::Global = "global";
167 : const char* Scope::TypeEnum::Local = "local";
168 : const char* Scope::TypeEnum::With = "with";
169 : const char* Scope::TypeEnum::Closure = "closure";
170 : const char* Scope::TypeEnum::Catch = "catch";
171 : const char* Scope::TypeEnum::Block = "block";
172 : const char* Scope::TypeEnum::Script = "script";
173 : const char* Scope::TypeEnum::Eval = "eval";
174 : const char* Scope::TypeEnum::Module = "module";
175 :
176 0 : std::unique_ptr<Scope> Scope::fromValue(protocol::Value* value, ErrorSupport* errors)
177 : {
178 0 : if (!value || value->type() != protocol::Value::TypeObject) {
179 0 : errors->addError("object expected");
180 : return nullptr;
181 : }
182 :
183 0 : std::unique_ptr<Scope> result(new Scope());
184 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
185 0 : errors->push();
186 0 : protocol::Value* typeValue = object->get("type");
187 0 : errors->setName("type");
188 0 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
189 0 : protocol::Value* objectValue = object->get("object");
190 0 : errors->setName("object");
191 0 : result->m_object = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(objectValue, errors);
192 0 : protocol::Value* nameValue = object->get("name");
193 0 : if (nameValue) {
194 0 : errors->setName("name");
195 0 : result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
196 : }
197 0 : protocol::Value* startLocationValue = object->get("startLocation");
198 0 : if (startLocationValue) {
199 0 : errors->setName("startLocation");
200 0 : result->m_startLocation = ValueConversions<protocol::Debugger::Location>::fromValue(startLocationValue, errors);
201 : }
202 0 : protocol::Value* endLocationValue = object->get("endLocation");
203 0 : if (endLocationValue) {
204 0 : errors->setName("endLocation");
205 0 : result->m_endLocation = ValueConversions<protocol::Debugger::Location>::fromValue(endLocationValue, errors);
206 : }
207 0 : errors->pop();
208 0 : if (errors->hasErrors())
209 : return nullptr;
210 : return result;
211 : }
212 :
213 326019 : std::unique_ptr<protocol::DictionaryValue> Scope::toValue() const
214 : {
215 326019 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
216 1630095 : result->setValue("type", ValueConversions<String>::toValue(m_type));
217 1304076 : result->setValue("object", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_object.get()));
218 326019 : if (m_name.isJust())
219 390045 : result->setValue("name", ValueConversions<String>::toValue(m_name.fromJust()));
220 326019 : if (m_startLocation.isJust())
221 352288 : result->setValue("startLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_startLocation.fromJust()));
222 326019 : if (m_endLocation.isJust())
223 352288 : result->setValue("endLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_endLocation.fromJust()));
224 326019 : return result;
225 : }
226 :
227 0 : std::unique_ptr<Scope> Scope::clone() const
228 : {
229 0 : ErrorSupport errors;
230 0 : return fromValue(toValue().get(), &errors);
231 : }
232 :
233 0 : std::unique_ptr<SearchMatch> SearchMatch::fromValue(protocol::Value* value, ErrorSupport* errors)
234 : {
235 0 : if (!value || value->type() != protocol::Value::TypeObject) {
236 0 : errors->addError("object expected");
237 : return nullptr;
238 : }
239 :
240 0 : std::unique_ptr<SearchMatch> result(new SearchMatch());
241 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
242 0 : errors->push();
243 0 : protocol::Value* lineNumberValue = object->get("lineNumber");
244 0 : errors->setName("lineNumber");
245 0 : result->m_lineNumber = ValueConversions<double>::fromValue(lineNumberValue, errors);
246 0 : protocol::Value* lineContentValue = object->get("lineContent");
247 0 : errors->setName("lineContent");
248 0 : result->m_lineContent = ValueConversions<String>::fromValue(lineContentValue, errors);
249 0 : errors->pop();
250 0 : if (errors->hasErrors())
251 : return nullptr;
252 : return result;
253 : }
254 :
255 0 : std::unique_ptr<protocol::DictionaryValue> SearchMatch::toValue() const
256 : {
257 0 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
258 0 : result->setValue("lineNumber", ValueConversions<double>::toValue(m_lineNumber));
259 0 : result->setValue("lineContent", ValueConversions<String>::toValue(m_lineContent));
260 0 : return result;
261 : }
262 :
263 0 : std::unique_ptr<SearchMatch> SearchMatch::clone() const
264 : {
265 0 : ErrorSupport errors;
266 0 : return fromValue(toValue().get(), &errors);
267 : }
268 :
269 0 : std::unique_ptr<StringBuffer> SearchMatch::toJSONString() const
270 : {
271 0 : String json = toValue()->serialize();
272 0 : return StringBufferImpl::adopt(json);
273 : }
274 :
275 : // static
276 0 : std::unique_ptr<API::SearchMatch> API::SearchMatch::fromJSONString(const StringView& json)
277 : {
278 0 : ErrorSupport errors;
279 0 : std::unique_ptr<Value> value = StringUtil::parseJSON(json);
280 0 : if (!value)
281 : return nullptr;
282 0 : return protocol::Debugger::SearchMatch::fromValue(value.get(), &errors);
283 : }
284 :
285 : const char* BreakLocation::TypeEnum::DebuggerStatement = "debuggerStatement";
286 : const char* BreakLocation::TypeEnum::Call = "call";
287 : const char* BreakLocation::TypeEnum::Return = "return";
288 :
289 0 : std::unique_ptr<BreakLocation> BreakLocation::fromValue(protocol::Value* value, ErrorSupport* errors)
290 : {
291 0 : if (!value || value->type() != protocol::Value::TypeObject) {
292 0 : errors->addError("object expected");
293 : return nullptr;
294 : }
295 :
296 0 : std::unique_ptr<BreakLocation> result(new BreakLocation());
297 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
298 0 : errors->push();
299 0 : protocol::Value* scriptIdValue = object->get("scriptId");
300 0 : errors->setName("scriptId");
301 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
302 0 : protocol::Value* lineNumberValue = object->get("lineNumber");
303 0 : errors->setName("lineNumber");
304 0 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
305 0 : protocol::Value* columnNumberValue = object->get("columnNumber");
306 0 : if (columnNumberValue) {
307 0 : errors->setName("columnNumber");
308 0 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
309 : }
310 0 : protocol::Value* typeValue = object->get("type");
311 0 : if (typeValue) {
312 0 : errors->setName("type");
313 0 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
314 : }
315 0 : errors->pop();
316 0 : if (errors->hasErrors())
317 : return nullptr;
318 : return result;
319 : }
320 :
321 3035 : std::unique_ptr<protocol::DictionaryValue> BreakLocation::toValue() const
322 : {
323 3035 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
324 15175 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
325 15175 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
326 3035 : if (m_columnNumber.isJust())
327 12140 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber.fromJust()));
328 3035 : if (m_type.isJust())
329 8825 : result->setValue("type", ValueConversions<String>::toValue(m_type.fromJust()));
330 3035 : return result;
331 : }
332 :
333 0 : std::unique_ptr<BreakLocation> BreakLocation::clone() const
334 : {
335 0 : ErrorSupport errors;
336 0 : return fromValue(toValue().get(), &errors);
337 : }
338 :
339 0 : std::unique_ptr<ScriptParsedNotification> ScriptParsedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
340 : {
341 0 : if (!value || value->type() != protocol::Value::TypeObject) {
342 0 : errors->addError("object expected");
343 : return nullptr;
344 : }
345 :
346 0 : std::unique_ptr<ScriptParsedNotification> result(new ScriptParsedNotification());
347 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
348 0 : errors->push();
349 0 : protocol::Value* scriptIdValue = object->get("scriptId");
350 0 : errors->setName("scriptId");
351 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
352 0 : protocol::Value* urlValue = object->get("url");
353 0 : errors->setName("url");
354 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
355 0 : protocol::Value* startLineValue = object->get("startLine");
356 0 : errors->setName("startLine");
357 0 : result->m_startLine = ValueConversions<int>::fromValue(startLineValue, errors);
358 0 : protocol::Value* startColumnValue = object->get("startColumn");
359 0 : errors->setName("startColumn");
360 0 : result->m_startColumn = ValueConversions<int>::fromValue(startColumnValue, errors);
361 0 : protocol::Value* endLineValue = object->get("endLine");
362 0 : errors->setName("endLine");
363 0 : result->m_endLine = ValueConversions<int>::fromValue(endLineValue, errors);
364 0 : protocol::Value* endColumnValue = object->get("endColumn");
365 0 : errors->setName("endColumn");
366 0 : result->m_endColumn = ValueConversions<int>::fromValue(endColumnValue, errors);
367 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
368 0 : errors->setName("executionContextId");
369 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
370 0 : protocol::Value* hashValue = object->get("hash");
371 0 : errors->setName("hash");
372 0 : result->m_hash = ValueConversions<String>::fromValue(hashValue, errors);
373 0 : protocol::Value* executionContextAuxDataValue = object->get("executionContextAuxData");
374 0 : if (executionContextAuxDataValue) {
375 0 : errors->setName("executionContextAuxData");
376 0 : result->m_executionContextAuxData = ValueConversions<protocol::DictionaryValue>::fromValue(executionContextAuxDataValue, errors);
377 : }
378 0 : protocol::Value* isLiveEditValue = object->get("isLiveEdit");
379 0 : if (isLiveEditValue) {
380 0 : errors->setName("isLiveEdit");
381 0 : result->m_isLiveEdit = ValueConversions<bool>::fromValue(isLiveEditValue, errors);
382 : }
383 0 : protocol::Value* sourceMapURLValue = object->get("sourceMapURL");
384 0 : if (sourceMapURLValue) {
385 0 : errors->setName("sourceMapURL");
386 0 : result->m_sourceMapURL = ValueConversions<String>::fromValue(sourceMapURLValue, errors);
387 : }
388 0 : protocol::Value* hasSourceURLValue = object->get("hasSourceURL");
389 0 : if (hasSourceURLValue) {
390 0 : errors->setName("hasSourceURL");
391 0 : result->m_hasSourceURL = ValueConversions<bool>::fromValue(hasSourceURLValue, errors);
392 : }
393 0 : protocol::Value* isModuleValue = object->get("isModule");
394 0 : if (isModuleValue) {
395 0 : errors->setName("isModule");
396 0 : result->m_isModule = ValueConversions<bool>::fromValue(isModuleValue, errors);
397 : }
398 0 : protocol::Value* lengthValue = object->get("length");
399 0 : if (lengthValue) {
400 0 : errors->setName("length");
401 0 : result->m_length = ValueConversions<int>::fromValue(lengthValue, errors);
402 : }
403 0 : protocol::Value* stackTraceValue = object->get("stackTrace");
404 0 : if (stackTraceValue) {
405 0 : errors->setName("stackTrace");
406 0 : result->m_stackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(stackTraceValue, errors);
407 : }
408 0 : errors->pop();
409 0 : if (errors->hasErrors())
410 : return nullptr;
411 : return result;
412 : }
413 :
414 25838 : std::unique_ptr<protocol::DictionaryValue> ScriptParsedNotification::toValue() const
415 : {
416 25838 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
417 129190 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
418 129190 : result->setValue("url", ValueConversions<String>::toValue(m_url));
419 129190 : result->setValue("startLine", ValueConversions<int>::toValue(m_startLine));
420 129190 : result->setValue("startColumn", ValueConversions<int>::toValue(m_startColumn));
421 129190 : result->setValue("endLine", ValueConversions<int>::toValue(m_endLine));
422 103352 : result->setValue("endColumn", ValueConversions<int>::toValue(m_endColumn));
423 129190 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
424 129190 : result->setValue("hash", ValueConversions<String>::toValue(m_hash));
425 25838 : if (m_executionContextAuxData.isJust())
426 0 : result->setValue("executionContextAuxData", ValueConversions<protocol::DictionaryValue>::toValue(m_executionContextAuxData.fromJust()));
427 25838 : if (m_isLiveEdit.isJust())
428 103352 : result->setValue("isLiveEdit", ValueConversions<bool>::toValue(m_isLiveEdit.fromJust()));
429 25838 : if (m_sourceMapURL.isJust())
430 129190 : result->setValue("sourceMapURL", ValueConversions<String>::toValue(m_sourceMapURL.fromJust()));
431 25838 : if (m_hasSourceURL.isJust())
432 103352 : result->setValue("hasSourceURL", ValueConversions<bool>::toValue(m_hasSourceURL.fromJust()));
433 25838 : if (m_isModule.isJust())
434 103352 : result->setValue("isModule", ValueConversions<bool>::toValue(m_isModule.fromJust()));
435 25838 : if (m_length.isJust())
436 103352 : result->setValue("length", ValueConversions<int>::toValue(m_length.fromJust()));
437 25838 : if (m_stackTrace.isJust())
438 86788 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_stackTrace.fromJust()));
439 25838 : return result;
440 : }
441 :
442 0 : std::unique_ptr<ScriptParsedNotification> ScriptParsedNotification::clone() const
443 : {
444 0 : ErrorSupport errors;
445 0 : return fromValue(toValue().get(), &errors);
446 : }
447 :
448 0 : std::unique_ptr<ScriptFailedToParseNotification> ScriptFailedToParseNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
449 : {
450 0 : if (!value || value->type() != protocol::Value::TypeObject) {
451 0 : errors->addError("object expected");
452 : return nullptr;
453 : }
454 :
455 0 : std::unique_ptr<ScriptFailedToParseNotification> result(new ScriptFailedToParseNotification());
456 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
457 0 : errors->push();
458 0 : protocol::Value* scriptIdValue = object->get("scriptId");
459 0 : errors->setName("scriptId");
460 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
461 0 : protocol::Value* urlValue = object->get("url");
462 0 : errors->setName("url");
463 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
464 0 : protocol::Value* startLineValue = object->get("startLine");
465 0 : errors->setName("startLine");
466 0 : result->m_startLine = ValueConversions<int>::fromValue(startLineValue, errors);
467 0 : protocol::Value* startColumnValue = object->get("startColumn");
468 0 : errors->setName("startColumn");
469 0 : result->m_startColumn = ValueConversions<int>::fromValue(startColumnValue, errors);
470 0 : protocol::Value* endLineValue = object->get("endLine");
471 0 : errors->setName("endLine");
472 0 : result->m_endLine = ValueConversions<int>::fromValue(endLineValue, errors);
473 0 : protocol::Value* endColumnValue = object->get("endColumn");
474 0 : errors->setName("endColumn");
475 0 : result->m_endColumn = ValueConversions<int>::fromValue(endColumnValue, errors);
476 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
477 0 : errors->setName("executionContextId");
478 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
479 0 : protocol::Value* hashValue = object->get("hash");
480 0 : errors->setName("hash");
481 0 : result->m_hash = ValueConversions<String>::fromValue(hashValue, errors);
482 0 : protocol::Value* executionContextAuxDataValue = object->get("executionContextAuxData");
483 0 : if (executionContextAuxDataValue) {
484 0 : errors->setName("executionContextAuxData");
485 0 : result->m_executionContextAuxData = ValueConversions<protocol::DictionaryValue>::fromValue(executionContextAuxDataValue, errors);
486 : }
487 0 : protocol::Value* sourceMapURLValue = object->get("sourceMapURL");
488 0 : if (sourceMapURLValue) {
489 0 : errors->setName("sourceMapURL");
490 0 : result->m_sourceMapURL = ValueConversions<String>::fromValue(sourceMapURLValue, errors);
491 : }
492 0 : protocol::Value* hasSourceURLValue = object->get("hasSourceURL");
493 0 : if (hasSourceURLValue) {
494 0 : errors->setName("hasSourceURL");
495 0 : result->m_hasSourceURL = ValueConversions<bool>::fromValue(hasSourceURLValue, errors);
496 : }
497 0 : protocol::Value* isModuleValue = object->get("isModule");
498 0 : if (isModuleValue) {
499 0 : errors->setName("isModule");
500 0 : result->m_isModule = ValueConversions<bool>::fromValue(isModuleValue, errors);
501 : }
502 0 : protocol::Value* lengthValue = object->get("length");
503 0 : if (lengthValue) {
504 0 : errors->setName("length");
505 0 : result->m_length = ValueConversions<int>::fromValue(lengthValue, errors);
506 : }
507 0 : protocol::Value* stackTraceValue = object->get("stackTrace");
508 0 : if (stackTraceValue) {
509 0 : errors->setName("stackTrace");
510 0 : result->m_stackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(stackTraceValue, errors);
511 : }
512 0 : errors->pop();
513 0 : if (errors->hasErrors())
514 : return nullptr;
515 : return result;
516 : }
517 :
518 132 : std::unique_ptr<protocol::DictionaryValue> ScriptFailedToParseNotification::toValue() const
519 : {
520 132 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
521 660 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
522 660 : result->setValue("url", ValueConversions<String>::toValue(m_url));
523 660 : result->setValue("startLine", ValueConversions<int>::toValue(m_startLine));
524 660 : result->setValue("startColumn", ValueConversions<int>::toValue(m_startColumn));
525 660 : result->setValue("endLine", ValueConversions<int>::toValue(m_endLine));
526 660 : result->setValue("endColumn", ValueConversions<int>::toValue(m_endColumn));
527 660 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
528 660 : result->setValue("hash", ValueConversions<String>::toValue(m_hash));
529 132 : if (m_executionContextAuxData.isJust())
530 0 : result->setValue("executionContextAuxData", ValueConversions<protocol::DictionaryValue>::toValue(m_executionContextAuxData.fromJust()));
531 132 : if (m_sourceMapURL.isJust())
532 660 : result->setValue("sourceMapURL", ValueConversions<String>::toValue(m_sourceMapURL.fromJust()));
533 132 : if (m_hasSourceURL.isJust())
534 528 : result->setValue("hasSourceURL", ValueConversions<bool>::toValue(m_hasSourceURL.fromJust()));
535 132 : if (m_isModule.isJust())
536 528 : result->setValue("isModule", ValueConversions<bool>::toValue(m_isModule.fromJust()));
537 132 : if (m_length.isJust())
538 528 : result->setValue("length", ValueConversions<int>::toValue(m_length.fromJust()));
539 132 : if (m_stackTrace.isJust())
540 388 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_stackTrace.fromJust()));
541 132 : return result;
542 : }
543 :
544 0 : std::unique_ptr<ScriptFailedToParseNotification> ScriptFailedToParseNotification::clone() const
545 : {
546 0 : ErrorSupport errors;
547 0 : return fromValue(toValue().get(), &errors);
548 : }
549 :
550 0 : std::unique_ptr<BreakpointResolvedNotification> BreakpointResolvedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
551 : {
552 0 : if (!value || value->type() != protocol::Value::TypeObject) {
553 0 : errors->addError("object expected");
554 : return nullptr;
555 : }
556 :
557 0 : std::unique_ptr<BreakpointResolvedNotification> result(new BreakpointResolvedNotification());
558 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
559 0 : errors->push();
560 0 : protocol::Value* breakpointIdValue = object->get("breakpointId");
561 0 : errors->setName("breakpointId");
562 0 : result->m_breakpointId = ValueConversions<String>::fromValue(breakpointIdValue, errors);
563 0 : protocol::Value* locationValue = object->get("location");
564 0 : errors->setName("location");
565 0 : result->m_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
566 0 : errors->pop();
567 0 : if (errors->hasErrors())
568 : return nullptr;
569 : return result;
570 : }
571 :
572 45 : std::unique_ptr<protocol::DictionaryValue> BreakpointResolvedNotification::toValue() const
573 : {
574 45 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
575 225 : result->setValue("breakpointId", ValueConversions<String>::toValue(m_breakpointId));
576 180 : result->setValue("location", ValueConversions<protocol::Debugger::Location>::toValue(m_location.get()));
577 45 : return result;
578 : }
579 :
580 0 : std::unique_ptr<BreakpointResolvedNotification> BreakpointResolvedNotification::clone() const
581 : {
582 0 : ErrorSupport errors;
583 0 : return fromValue(toValue().get(), &errors);
584 : }
585 :
586 : const char* PausedNotification::ReasonEnum::XHR = "XHR";
587 : const char* PausedNotification::ReasonEnum::DOM = "DOM";
588 : const char* PausedNotification::ReasonEnum::EventListener = "EventListener";
589 : const char* PausedNotification::ReasonEnum::Exception = "exception";
590 : const char* PausedNotification::ReasonEnum::Assert = "assert";
591 : const char* PausedNotification::ReasonEnum::DebugCommand = "debugCommand";
592 : const char* PausedNotification::ReasonEnum::PromiseRejection = "promiseRejection";
593 : const char* PausedNotification::ReasonEnum::OOM = "OOM";
594 : const char* PausedNotification::ReasonEnum::Other = "other";
595 : const char* PausedNotification::ReasonEnum::Ambiguous = "ambiguous";
596 :
597 0 : std::unique_ptr<PausedNotification> PausedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
598 : {
599 0 : if (!value || value->type() != protocol::Value::TypeObject) {
600 0 : errors->addError("object expected");
601 : return nullptr;
602 : }
603 :
604 0 : std::unique_ptr<PausedNotification> result(new PausedNotification());
605 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
606 0 : errors->push();
607 0 : protocol::Value* callFramesValue = object->get("callFrames");
608 0 : errors->setName("callFrames");
609 0 : result->m_callFrames = ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::fromValue(callFramesValue, errors);
610 0 : protocol::Value* reasonValue = object->get("reason");
611 0 : errors->setName("reason");
612 0 : result->m_reason = ValueConversions<String>::fromValue(reasonValue, errors);
613 0 : protocol::Value* dataValue = object->get("data");
614 0 : if (dataValue) {
615 0 : errors->setName("data");
616 0 : result->m_data = ValueConversions<protocol::DictionaryValue>::fromValue(dataValue, errors);
617 : }
618 0 : protocol::Value* hitBreakpointsValue = object->get("hitBreakpoints");
619 0 : if (hitBreakpointsValue) {
620 0 : errors->setName("hitBreakpoints");
621 0 : result->m_hitBreakpoints = ValueConversions<protocol::Array<String>>::fromValue(hitBreakpointsValue, errors);
622 : }
623 0 : protocol::Value* asyncStackTraceValue = object->get("asyncStackTrace");
624 0 : if (asyncStackTraceValue) {
625 0 : errors->setName("asyncStackTrace");
626 0 : result->m_asyncStackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(asyncStackTraceValue, errors);
627 : }
628 0 : errors->pop();
629 0 : if (errors->hasErrors())
630 : return nullptr;
631 : return result;
632 : }
633 :
634 49820 : std::unique_ptr<protocol::DictionaryValue> PausedNotification::toValue() const
635 : {
636 49820 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
637 199280 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(m_callFrames.get()));
638 249100 : result->setValue("reason", ValueConversions<String>::toValue(m_reason));
639 49820 : if (m_data.isJust())
640 7204 : result->setValue("data", ValueConversions<protocol::DictionaryValue>::toValue(m_data.fromJust()));
641 49820 : if (m_hitBreakpoints.isJust())
642 199280 : result->setValue("hitBreakpoints", ValueConversions<protocol::Array<String>>::toValue(m_hitBreakpoints.fromJust()));
643 49820 : if (m_asyncStackTrace.isJust())
644 1300 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_asyncStackTrace.fromJust()));
645 49820 : return result;
646 : }
647 :
648 0 : std::unique_ptr<PausedNotification> PausedNotification::clone() const
649 : {
650 0 : ErrorSupport errors;
651 0 : return fromValue(toValue().get(), &errors);
652 : }
653 :
654 : // ------------- Enum values from params.
655 :
656 :
657 : namespace ContinueToLocation {
658 : namespace TargetCallFramesEnum {
659 : const char* Any = "any";
660 : const char* Current = "current";
661 : } // namespace TargetCallFramesEnum
662 : } // namespace ContinueToLocation
663 :
664 : namespace SetPauseOnExceptions {
665 : namespace StateEnum {
666 : const char* None = "none";
667 : const char* Uncaught = "uncaught";
668 : const char* All = "all";
669 : } // namespace StateEnum
670 : } // namespace SetPauseOnExceptions
671 :
672 : namespace Paused {
673 : namespace ReasonEnum {
674 : const char* XHR = "XHR";
675 : const char* DOM = "DOM";
676 : const char* EventListener = "EventListener";
677 : const char* Exception = "exception";
678 : const char* Assert = "assert";
679 : const char* DebugCommand = "debugCommand";
680 : const char* PromiseRejection = "promiseRejection";
681 : const char* OOM = "OOM";
682 : const char* Other = "other";
683 : const char* Ambiguous = "ambiguous";
684 : } // namespace ReasonEnum
685 : } // namespace Paused
686 :
687 : namespace API {
688 : namespace Paused {
689 : namespace ReasonEnum {
690 : const char* XHR = "XHR";
691 : const char* DOM = "DOM";
692 : const char* EventListener = "EventListener";
693 : const char* Exception = "exception";
694 : const char* Assert = "assert";
695 : const char* DebugCommand = "debugCommand";
696 : const char* PromiseRejection = "promiseRejection";
697 : const char* OOM = "OOM";
698 : const char* Other = "other";
699 : const char* Ambiguous = "ambiguous";
700 : } // namespace ReasonEnum
701 : } // namespace Paused
702 : } // namespace API
703 :
704 : // ------------- Frontend notifications.
705 :
706 25838 : void Frontend::scriptParsed(const String& scriptId, const String& url, int startLine, int startColumn, int endLine, int endColumn, int executionContextId, const String& hash, Maybe<protocol::DictionaryValue> executionContextAuxData, Maybe<bool> isLiveEdit, Maybe<String> sourceMapURL, Maybe<bool> hasSourceURL, Maybe<bool> isModule, Maybe<int> length, Maybe<protocol::Runtime::StackTrace> stackTrace)
707 : {
708 25838 : if (!m_frontendChannel)
709 25838 : return;
710 : std::unique_ptr<ScriptParsedNotification> messageData = ScriptParsedNotification::create()
711 25838 : .setScriptId(scriptId)
712 : .setUrl(url)
713 : .setStartLine(startLine)
714 : .setStartColumn(startColumn)
715 : .setEndLine(endLine)
716 : .setEndColumn(endColumn)
717 : .setExecutionContextId(executionContextId)
718 : .setHash(hash)
719 : .build();
720 25838 : if (executionContextAuxData.isJust())
721 : messageData->setExecutionContextAuxData(std::move(executionContextAuxData).takeJust());
722 25838 : if (isLiveEdit.isJust())
723 25838 : messageData->setIsLiveEdit(std::move(isLiveEdit).takeJust());
724 25838 : if (sourceMapURL.isJust())
725 51676 : messageData->setSourceMapURL(std::move(sourceMapURL).takeJust());
726 25838 : if (hasSourceURL.isJust())
727 25838 : messageData->setHasSourceURL(std::move(hasSourceURL).takeJust());
728 25838 : if (isModule.isJust())
729 25838 : messageData->setIsModule(std::move(isModule).takeJust());
730 25838 : if (length.isJust())
731 25838 : messageData->setLength(std::move(length).takeJust());
732 25838 : if (stackTrace.isJust())
733 : messageData->setStackTrace(std::move(stackTrace).takeJust());
734 180866 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.scriptParsed", std::move(messageData)));
735 : }
736 :
737 132 : void Frontend::scriptFailedToParse(const String& scriptId, const String& url, int startLine, int startColumn, int endLine, int endColumn, int executionContextId, const String& hash, Maybe<protocol::DictionaryValue> executionContextAuxData, Maybe<String> sourceMapURL, Maybe<bool> hasSourceURL, Maybe<bool> isModule, Maybe<int> length, Maybe<protocol::Runtime::StackTrace> stackTrace)
738 : {
739 132 : if (!m_frontendChannel)
740 132 : return;
741 : std::unique_ptr<ScriptFailedToParseNotification> messageData = ScriptFailedToParseNotification::create()
742 132 : .setScriptId(scriptId)
743 : .setUrl(url)
744 : .setStartLine(startLine)
745 : .setStartColumn(startColumn)
746 : .setEndLine(endLine)
747 : .setEndColumn(endColumn)
748 : .setExecutionContextId(executionContextId)
749 : .setHash(hash)
750 : .build();
751 132 : if (executionContextAuxData.isJust())
752 : messageData->setExecutionContextAuxData(std::move(executionContextAuxData).takeJust());
753 132 : if (sourceMapURL.isJust())
754 264 : messageData->setSourceMapURL(std::move(sourceMapURL).takeJust());
755 132 : if (hasSourceURL.isJust())
756 132 : messageData->setHasSourceURL(std::move(hasSourceURL).takeJust());
757 132 : if (isModule.isJust())
758 132 : messageData->setIsModule(std::move(isModule).takeJust());
759 132 : if (length.isJust())
760 132 : messageData->setLength(std::move(length).takeJust());
761 132 : if (stackTrace.isJust())
762 : messageData->setStackTrace(std::move(stackTrace).takeJust());
763 924 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.scriptFailedToParse", std::move(messageData)));
764 : }
765 :
766 45 : void Frontend::breakpointResolved(const String& breakpointId, std::unique_ptr<protocol::Debugger::Location> location)
767 : {
768 45 : if (!m_frontendChannel)
769 45 : return;
770 : std::unique_ptr<BreakpointResolvedNotification> messageData = BreakpointResolvedNotification::create()
771 45 : .setBreakpointId(breakpointId)
772 : .setLocation(std::move(location))
773 : .build();
774 315 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.breakpointResolved", std::move(messageData)));
775 : }
776 :
777 49820 : void Frontend::paused(std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>> callFrames, const String& reason, Maybe<protocol::DictionaryValue> data, Maybe<protocol::Array<String>> hitBreakpoints, Maybe<protocol::Runtime::StackTrace> asyncStackTrace)
778 : {
779 49820 : if (!m_frontendChannel)
780 49820 : return;
781 : std::unique_ptr<PausedNotification> messageData = PausedNotification::create()
782 49820 : .setCallFrames(std::move(callFrames))
783 : .setReason(reason)
784 : .build();
785 49820 : if (data.isJust())
786 : messageData->setData(std::move(data).takeJust());
787 49820 : if (hitBreakpoints.isJust())
788 : messageData->setHitBreakpoints(std::move(hitBreakpoints).takeJust());
789 49820 : if (asyncStackTrace.isJust())
790 : messageData->setAsyncStackTrace(std::move(asyncStackTrace).takeJust());
791 348740 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.paused", std::move(messageData)));
792 : }
793 :
794 49679 : void Frontend::resumed()
795 : {
796 49679 : if (!m_frontendChannel)
797 49679 : return;
798 347753 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.resumed"));
799 : }
800 :
801 0 : void Frontend::flush()
802 : {
803 0 : m_frontendChannel->flushProtocolNotifications();
804 0 : }
805 :
806 0 : void Frontend::sendRawNotification(const String& notification)
807 : {
808 0 : m_frontendChannel->sendProtocolNotification(InternalRawNotification::create(notification));
809 0 : }
810 :
811 : // --------------------- Dispatcher.
812 :
813 : class DispatcherImpl : public protocol::DispatcherBase {
814 : public:
815 3406 : DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend, bool fallThroughForNotFound)
816 : : DispatcherBase(frontendChannel)
817 : , m_backend(backend)
818 10218 : , m_fallThroughForNotFound(fallThroughForNotFound) {
819 10218 : m_dispatchMap["Debugger.enable"] = &DispatcherImpl::enable;
820 10218 : m_dispatchMap["Debugger.disable"] = &DispatcherImpl::disable;
821 10218 : m_dispatchMap["Debugger.setBreakpointsActive"] = &DispatcherImpl::setBreakpointsActive;
822 10218 : m_dispatchMap["Debugger.setSkipAllPauses"] = &DispatcherImpl::setSkipAllPauses;
823 10218 : m_dispatchMap["Debugger.setBreakpointByUrl"] = &DispatcherImpl::setBreakpointByUrl;
824 10218 : m_dispatchMap["Debugger.setBreakpoint"] = &DispatcherImpl::setBreakpoint;
825 10218 : m_dispatchMap["Debugger.removeBreakpoint"] = &DispatcherImpl::removeBreakpoint;
826 10218 : m_dispatchMap["Debugger.getPossibleBreakpoints"] = &DispatcherImpl::getPossibleBreakpoints;
827 10218 : m_dispatchMap["Debugger.continueToLocation"] = &DispatcherImpl::continueToLocation;
828 10218 : m_dispatchMap["Debugger.stepOver"] = &DispatcherImpl::stepOver;
829 10218 : m_dispatchMap["Debugger.stepInto"] = &DispatcherImpl::stepInto;
830 10218 : m_dispatchMap["Debugger.stepOut"] = &DispatcherImpl::stepOut;
831 10218 : m_dispatchMap["Debugger.pause"] = &DispatcherImpl::pause;
832 10218 : m_dispatchMap["Debugger.scheduleStepIntoAsync"] = &DispatcherImpl::scheduleStepIntoAsync;
833 10218 : m_dispatchMap["Debugger.resume"] = &DispatcherImpl::resume;
834 10218 : m_dispatchMap["Debugger.searchInContent"] = &DispatcherImpl::searchInContent;
835 10218 : m_dispatchMap["Debugger.setScriptSource"] = &DispatcherImpl::setScriptSource;
836 10218 : m_dispatchMap["Debugger.restartFrame"] = &DispatcherImpl::restartFrame;
837 10218 : m_dispatchMap["Debugger.getScriptSource"] = &DispatcherImpl::getScriptSource;
838 10218 : m_dispatchMap["Debugger.setPauseOnExceptions"] = &DispatcherImpl::setPauseOnExceptions;
839 10218 : m_dispatchMap["Debugger.evaluateOnCallFrame"] = &DispatcherImpl::evaluateOnCallFrame;
840 10218 : m_dispatchMap["Debugger.setVariableValue"] = &DispatcherImpl::setVariableValue;
841 10218 : m_dispatchMap["Debugger.setAsyncCallStackDepth"] = &DispatcherImpl::setAsyncCallStackDepth;
842 10218 : m_dispatchMap["Debugger.setBlackboxPatterns"] = &DispatcherImpl::setBlackboxPatterns;
843 10218 : m_dispatchMap["Debugger.setBlackboxedRanges"] = &DispatcherImpl::setBlackboxedRanges;
844 3406 : }
845 10218 : ~DispatcherImpl() override { }
846 : DispatchResponse::Status dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) override;
847 : HashMap<String, String>& redirects() { return m_redirects; }
848 :
849 : protected:
850 : using CallHandler = DispatchResponse::Status (DispatcherImpl::*)(int callId, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
851 : using DispatchMap = protocol::HashMap<String, CallHandler>;
852 : DispatchMap m_dispatchMap;
853 : HashMap<String, String> m_redirects;
854 :
855 : DispatchResponse::Status enable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
856 : DispatchResponse::Status disable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
857 : DispatchResponse::Status setBreakpointsActive(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
858 : DispatchResponse::Status setSkipAllPauses(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
859 : DispatchResponse::Status setBreakpointByUrl(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
860 : DispatchResponse::Status setBreakpoint(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
861 : DispatchResponse::Status removeBreakpoint(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
862 : DispatchResponse::Status getPossibleBreakpoints(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
863 : DispatchResponse::Status continueToLocation(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
864 : DispatchResponse::Status stepOver(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
865 : DispatchResponse::Status stepInto(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
866 : DispatchResponse::Status stepOut(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
867 : DispatchResponse::Status pause(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
868 : DispatchResponse::Status scheduleStepIntoAsync(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
869 : DispatchResponse::Status resume(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
870 : DispatchResponse::Status searchInContent(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
871 : DispatchResponse::Status setScriptSource(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
872 : DispatchResponse::Status restartFrame(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
873 : DispatchResponse::Status getScriptSource(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
874 : DispatchResponse::Status setPauseOnExceptions(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
875 : DispatchResponse::Status evaluateOnCallFrame(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
876 : DispatchResponse::Status setVariableValue(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
877 : DispatchResponse::Status setAsyncCallStackDepth(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
878 : DispatchResponse::Status setBlackboxPatterns(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
879 : DispatchResponse::Status setBlackboxedRanges(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
880 :
881 : Backend* m_backend;
882 : bool m_fallThroughForNotFound;
883 : };
884 :
885 64586 : DispatchResponse::Status DispatcherImpl::dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject)
886 : {
887 : protocol::HashMap<String, CallHandler>::iterator it = m_dispatchMap.find(method);
888 64586 : if (it == m_dispatchMap.end()) {
889 0 : if (m_fallThroughForNotFound)
890 : return DispatchResponse::kFallThrough;
891 0 : reportProtocolError(callId, DispatchResponse::kMethodNotFound, "'" + method + "' wasn't found", nullptr);
892 0 : return DispatchResponse::kError;
893 : }
894 :
895 64586 : protocol::ErrorSupport errors;
896 193758 : return (this->*(it->second))(callId, std::move(messageObject), &errors);
897 : }
898 :
899 :
900 3130 : DispatchResponse::Status DispatcherImpl::enable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
901 : {
902 :
903 3130 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
904 3130 : DispatchResponse response = m_backend->enable();
905 3130 : if (response.status() == DispatchResponse::kFallThrough)
906 : return response.status();
907 3130 : if (weak->get())
908 3130 : weak->get()->sendResponse(callId, response);
909 3130 : return response.status();
910 : }
911 :
912 1092 : DispatchResponse::Status DispatcherImpl::disable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
913 : {
914 :
915 1092 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
916 1092 : DispatchResponse response = m_backend->disable();
917 1092 : if (response.status() == DispatchResponse::kFallThrough)
918 : return response.status();
919 1092 : if (weak->get())
920 1092 : weak->get()->sendResponse(callId, response);
921 1092 : return response.status();
922 : }
923 :
924 138 : DispatchResponse::Status DispatcherImpl::setBreakpointsActive(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
925 : {
926 : // Prepare input parameters.
927 414 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
928 138 : errors->push();
929 276 : protocol::Value* activeValue = object ? object->get("active") : nullptr;
930 138 : errors->setName("active");
931 138 : bool in_active = ValueConversions<bool>::fromValue(activeValue, errors);
932 138 : errors->pop();
933 138 : if (errors->hasErrors()) {
934 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
935 0 : return DispatchResponse::kError;
936 : }
937 :
938 138 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
939 138 : DispatchResponse response = m_backend->setBreakpointsActive(in_active);
940 138 : if (response.status() == DispatchResponse::kFallThrough)
941 : return response.status();
942 138 : if (weak->get())
943 138 : weak->get()->sendResponse(callId, response);
944 138 : return response.status();
945 : }
946 :
947 35 : DispatchResponse::Status DispatcherImpl::setSkipAllPauses(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
948 : {
949 : // Prepare input parameters.
950 105 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
951 35 : errors->push();
952 70 : protocol::Value* skipValue = object ? object->get("skip") : nullptr;
953 35 : errors->setName("skip");
954 35 : bool in_skip = ValueConversions<bool>::fromValue(skipValue, errors);
955 35 : errors->pop();
956 35 : if (errors->hasErrors()) {
957 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
958 0 : return DispatchResponse::kError;
959 : }
960 :
961 35 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
962 35 : DispatchResponse response = m_backend->setSkipAllPauses(in_skip);
963 35 : if (response.status() == DispatchResponse::kFallThrough)
964 : return response.status();
965 35 : if (weak->get())
966 35 : weak->get()->sendResponse(callId, response);
967 35 : return response.status();
968 : }
969 :
970 135 : DispatchResponse::Status DispatcherImpl::setBreakpointByUrl(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
971 : {
972 : // Prepare input parameters.
973 405 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
974 135 : errors->push();
975 270 : protocol::Value* lineNumberValue = object ? object->get("lineNumber") : nullptr;
976 135 : errors->setName("lineNumber");
977 135 : int in_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
978 270 : protocol::Value* urlValue = object ? object->get("url") : nullptr;
979 : Maybe<String> in_url;
980 135 : if (urlValue) {
981 125 : errors->setName("url");
982 250 : in_url = ValueConversions<String>::fromValue(urlValue, errors);
983 : }
984 270 : protocol::Value* urlRegexValue = object ? object->get("urlRegex") : nullptr;
985 : Maybe<String> in_urlRegex;
986 135 : if (urlRegexValue) {
987 0 : errors->setName("urlRegex");
988 0 : in_urlRegex = ValueConversions<String>::fromValue(urlRegexValue, errors);
989 : }
990 270 : protocol::Value* scriptHashValue = object ? object->get("scriptHash") : nullptr;
991 : Maybe<String> in_scriptHash;
992 135 : if (scriptHashValue) {
993 10 : errors->setName("scriptHash");
994 20 : in_scriptHash = ValueConversions<String>::fromValue(scriptHashValue, errors);
995 : }
996 270 : protocol::Value* columnNumberValue = object ? object->get("columnNumber") : nullptr;
997 : Maybe<int> in_columnNumber;
998 135 : if (columnNumberValue) {
999 60 : errors->setName("columnNumber");
1000 60 : in_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
1001 : }
1002 270 : protocol::Value* conditionValue = object ? object->get("condition") : nullptr;
1003 : Maybe<String> in_condition;
1004 135 : if (conditionValue) {
1005 10 : errors->setName("condition");
1006 20 : in_condition = ValueConversions<String>::fromValue(conditionValue, errors);
1007 : }
1008 135 : errors->pop();
1009 135 : if (errors->hasErrors()) {
1010 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1011 0 : return DispatchResponse::kError;
1012 : }
1013 : // Declare output parameters.
1014 135 : String out_breakpointId;
1015 135 : std::unique_ptr<protocol::Array<protocol::Debugger::Location>> out_locations;
1016 :
1017 135 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1018 810 : DispatchResponse response = m_backend->setBreakpointByUrl(in_lineNumber, std::move(in_url), std::move(in_urlRegex), std::move(in_scriptHash), std::move(in_columnNumber), std::move(in_condition), &out_breakpointId, &out_locations);
1019 135 : if (response.status() == DispatchResponse::kFallThrough)
1020 : return response.status();
1021 135 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1022 135 : if (response.status() == DispatchResponse::kSuccess) {
1023 540 : result->setValue("breakpointId", ValueConversions<String>::toValue(out_breakpointId));
1024 540 : result->setValue("locations", ValueConversions<protocol::Array<protocol::Debugger::Location>>::toValue(out_locations.get()));
1025 : }
1026 135 : if (weak->get())
1027 270 : weak->get()->sendResponse(callId, response, std::move(result));
1028 135 : return response.status();
1029 : }
1030 :
1031 1808 : DispatchResponse::Status DispatcherImpl::setBreakpoint(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1032 : {
1033 : // Prepare input parameters.
1034 5424 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1035 1808 : errors->push();
1036 3616 : protocol::Value* locationValue = object ? object->get("location") : nullptr;
1037 1808 : errors->setName("location");
1038 : std::unique_ptr<protocol::Debugger::Location> in_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
1039 3616 : protocol::Value* conditionValue = object ? object->get("condition") : nullptr;
1040 : Maybe<String> in_condition;
1041 1808 : if (conditionValue) {
1042 180 : errors->setName("condition");
1043 360 : in_condition = ValueConversions<String>::fromValue(conditionValue, errors);
1044 : }
1045 1808 : errors->pop();
1046 1808 : if (errors->hasErrors()) {
1047 10 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1048 5 : return DispatchResponse::kError;
1049 : }
1050 : // Declare output parameters.
1051 1803 : String out_breakpointId;
1052 1803 : std::unique_ptr<protocol::Debugger::Location> out_actualLocation;
1053 :
1054 1803 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1055 7212 : DispatchResponse response = m_backend->setBreakpoint(std::move(in_location), std::move(in_condition), &out_breakpointId, &out_actualLocation);
1056 1803 : if (response.status() == DispatchResponse::kFallThrough)
1057 : return response.status();
1058 1803 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1059 1803 : if (response.status() == DispatchResponse::kSuccess) {
1060 6636 : result->setValue("breakpointId", ValueConversions<String>::toValue(out_breakpointId));
1061 6636 : result->setValue("actualLocation", ValueConversions<protocol::Debugger::Location>::toValue(out_actualLocation.get()));
1062 : }
1063 1803 : if (weak->get())
1064 3606 : weak->get()->sendResponse(callId, response, std::move(result));
1065 1803 : return response.status();
1066 : }
1067 :
1068 574 : DispatchResponse::Status DispatcherImpl::removeBreakpoint(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1069 : {
1070 : // Prepare input parameters.
1071 1722 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1072 574 : errors->push();
1073 1148 : protocol::Value* breakpointIdValue = object ? object->get("breakpointId") : nullptr;
1074 574 : errors->setName("breakpointId");
1075 574 : String in_breakpointId = ValueConversions<String>::fromValue(breakpointIdValue, errors);
1076 574 : errors->pop();
1077 574 : if (errors->hasErrors()) {
1078 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1079 0 : return DispatchResponse::kError;
1080 : }
1081 :
1082 574 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1083 574 : DispatchResponse response = m_backend->removeBreakpoint(in_breakpointId);
1084 574 : if (response.status() == DispatchResponse::kFallThrough)
1085 : return response.status();
1086 574 : if (weak->get())
1087 574 : weak->get()->sendResponse(callId, response);
1088 574 : return response.status();
1089 : }
1090 :
1091 260 : DispatchResponse::Status DispatcherImpl::getPossibleBreakpoints(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1092 : {
1093 : // Prepare input parameters.
1094 780 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1095 260 : errors->push();
1096 520 : protocol::Value* startValue = object ? object->get("start") : nullptr;
1097 260 : errors->setName("start");
1098 : std::unique_ptr<protocol::Debugger::Location> in_start = ValueConversions<protocol::Debugger::Location>::fromValue(startValue, errors);
1099 520 : protocol::Value* endValue = object ? object->get("end") : nullptr;
1100 : Maybe<protocol::Debugger::Location> in_end;
1101 260 : if (endValue) {
1102 110 : errors->setName("end");
1103 110 : in_end = ValueConversions<protocol::Debugger::Location>::fromValue(endValue, errors);
1104 : }
1105 520 : protocol::Value* restrictToFunctionValue = object ? object->get("restrictToFunction") : nullptr;
1106 : Maybe<bool> in_restrictToFunction;
1107 260 : if (restrictToFunctionValue) {
1108 0 : errors->setName("restrictToFunction");
1109 0 : in_restrictToFunction = ValueConversions<bool>::fromValue(restrictToFunctionValue, errors);
1110 : }
1111 260 : errors->pop();
1112 260 : if (errors->hasErrors()) {
1113 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1114 0 : return DispatchResponse::kError;
1115 : }
1116 : // Declare output parameters.
1117 260 : std::unique_ptr<protocol::Array<protocol::Debugger::BreakLocation>> out_locations;
1118 :
1119 260 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1120 1040 : DispatchResponse response = m_backend->getPossibleBreakpoints(std::move(in_start), std::move(in_end), std::move(in_restrictToFunction), &out_locations);
1121 260 : if (response.status() == DispatchResponse::kFallThrough)
1122 : return response.status();
1123 260 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1124 260 : if (response.status() == DispatchResponse::kSuccess) {
1125 1000 : result->setValue("locations", ValueConversions<protocol::Array<protocol::Debugger::BreakLocation>>::toValue(out_locations.get()));
1126 : }
1127 260 : if (weak->get())
1128 520 : weak->get()->sendResponse(callId, response, std::move(result));
1129 260 : return response.status();
1130 : }
1131 :
1132 60 : DispatchResponse::Status DispatcherImpl::continueToLocation(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1133 : {
1134 : // Prepare input parameters.
1135 180 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1136 60 : errors->push();
1137 120 : protocol::Value* locationValue = object ? object->get("location") : nullptr;
1138 60 : errors->setName("location");
1139 : std::unique_ptr<protocol::Debugger::Location> in_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
1140 120 : protocol::Value* targetCallFramesValue = object ? object->get("targetCallFrames") : nullptr;
1141 : Maybe<String> in_targetCallFrames;
1142 60 : if (targetCallFramesValue) {
1143 30 : errors->setName("targetCallFrames");
1144 60 : in_targetCallFrames = ValueConversions<String>::fromValue(targetCallFramesValue, errors);
1145 : }
1146 60 : errors->pop();
1147 60 : if (errors->hasErrors()) {
1148 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1149 0 : return DispatchResponse::kError;
1150 : }
1151 :
1152 60 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1153 240 : DispatchResponse response = m_backend->continueToLocation(std::move(in_location), std::move(in_targetCallFrames));
1154 60 : if (response.status() == DispatchResponse::kFallThrough)
1155 : return response.status();
1156 60 : if (weak->get())
1157 60 : weak->get()->sendResponse(callId, response);
1158 60 : return response.status();
1159 : }
1160 :
1161 7494 : DispatchResponse::Status DispatcherImpl::stepOver(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1162 : {
1163 :
1164 7494 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1165 7494 : DispatchResponse response = m_backend->stepOver();
1166 7494 : if (response.status() == DispatchResponse::kFallThrough)
1167 : return response.status();
1168 7494 : if (weak->get())
1169 7494 : weak->get()->sendResponse(callId, response);
1170 7494 : return response.status();
1171 : }
1172 :
1173 31737 : DispatchResponse::Status DispatcherImpl::stepInto(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1174 : {
1175 :
1176 31737 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1177 31737 : DispatchResponse response = m_backend->stepInto();
1178 31737 : if (response.status() == DispatchResponse::kFallThrough)
1179 : return response.status();
1180 31737 : if (weak->get())
1181 31737 : weak->get()->sendResponse(callId, response);
1182 31737 : return response.status();
1183 : }
1184 :
1185 445 : DispatchResponse::Status DispatcherImpl::stepOut(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1186 : {
1187 :
1188 445 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1189 445 : DispatchResponse response = m_backend->stepOut();
1190 445 : if (response.status() == DispatchResponse::kFallThrough)
1191 : return response.status();
1192 445 : if (weak->get())
1193 445 : weak->get()->sendResponse(callId, response);
1194 445 : return response.status();
1195 : }
1196 :
1197 195 : DispatchResponse::Status DispatcherImpl::pause(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1198 : {
1199 :
1200 195 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1201 195 : DispatchResponse response = m_backend->pause();
1202 195 : if (response.status() == DispatchResponse::kFallThrough)
1203 : return response.status();
1204 195 : if (weak->get())
1205 195 : weak->get()->sendResponse(callId, response);
1206 195 : return response.status();
1207 : }
1208 :
1209 150 : class ScheduleStepIntoAsyncCallbackImpl : public Backend::ScheduleStepIntoAsyncCallback, public DispatcherBase::Callback {
1210 : public:
1211 75 : ScheduleStepIntoAsyncCallbackImpl(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId, int callbackId)
1212 150 : : DispatcherBase::Callback(std::move(backendImpl), callId, callbackId) { }
1213 :
1214 60 : void sendSuccess() override
1215 : {
1216 60 : std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
1217 240 : sendIfActive(std::move(resultObject), DispatchResponse::OK());
1218 60 : }
1219 :
1220 0 : void fallThrough() override
1221 : {
1222 0 : fallThroughIfActive();
1223 0 : }
1224 :
1225 15 : void sendFailure(const DispatchResponse& response) override
1226 : {
1227 : DCHECK(response.status() == DispatchResponse::kError);
1228 30 : sendIfActive(nullptr, response);
1229 15 : }
1230 : };
1231 :
1232 75 : DispatchResponse::Status DispatcherImpl::scheduleStepIntoAsync(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1233 : {
1234 :
1235 75 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1236 150 : std::unique_ptr<ScheduleStepIntoAsyncCallbackImpl> callback(new ScheduleStepIntoAsyncCallbackImpl(weakPtr(), callId, nextCallbackId()));
1237 225 : m_backend->scheduleStepIntoAsync(std::move(callback));
1238 150 : return (weak->get() && weak->get()->lastCallbackFallThrough()) ? DispatchResponse::kFallThrough : DispatchResponse::kAsync;
1239 : }
1240 :
1241 1625 : DispatchResponse::Status DispatcherImpl::resume(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1242 : {
1243 :
1244 1625 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1245 1625 : DispatchResponse response = m_backend->resume();
1246 1625 : if (response.status() == DispatchResponse::kFallThrough)
1247 : return response.status();
1248 1625 : if (weak->get())
1249 1625 : weak->get()->sendResponse(callId, response);
1250 1625 : return response.status();
1251 : }
1252 :
1253 0 : DispatchResponse::Status DispatcherImpl::searchInContent(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1254 : {
1255 : // Prepare input parameters.
1256 0 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1257 0 : errors->push();
1258 0 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1259 0 : errors->setName("scriptId");
1260 0 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1261 0 : protocol::Value* queryValue = object ? object->get("query") : nullptr;
1262 0 : errors->setName("query");
1263 0 : String in_query = ValueConversions<String>::fromValue(queryValue, errors);
1264 0 : protocol::Value* caseSensitiveValue = object ? object->get("caseSensitive") : nullptr;
1265 : Maybe<bool> in_caseSensitive;
1266 0 : if (caseSensitiveValue) {
1267 0 : errors->setName("caseSensitive");
1268 0 : in_caseSensitive = ValueConversions<bool>::fromValue(caseSensitiveValue, errors);
1269 : }
1270 0 : protocol::Value* isRegexValue = object ? object->get("isRegex") : nullptr;
1271 : Maybe<bool> in_isRegex;
1272 0 : if (isRegexValue) {
1273 0 : errors->setName("isRegex");
1274 0 : in_isRegex = ValueConversions<bool>::fromValue(isRegexValue, errors);
1275 : }
1276 0 : errors->pop();
1277 0 : if (errors->hasErrors()) {
1278 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1279 0 : return DispatchResponse::kError;
1280 : }
1281 : // Declare output parameters.
1282 0 : std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>> out_result;
1283 :
1284 0 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1285 0 : DispatchResponse response = m_backend->searchInContent(in_scriptId, in_query, std::move(in_caseSensitive), std::move(in_isRegex), &out_result);
1286 0 : if (response.status() == DispatchResponse::kFallThrough)
1287 : return response.status();
1288 0 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1289 0 : if (response.status() == DispatchResponse::kSuccess) {
1290 0 : result->setValue("result", ValueConversions<protocol::Array<protocol::Debugger::SearchMatch>>::toValue(out_result.get()));
1291 : }
1292 0 : if (weak->get())
1293 0 : weak->get()->sendResponse(callId, response, std::move(result));
1294 0 : return response.status();
1295 : }
1296 :
1297 54 : DispatchResponse::Status DispatcherImpl::setScriptSource(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1298 : {
1299 : // Prepare input parameters.
1300 162 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1301 54 : errors->push();
1302 108 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1303 54 : errors->setName("scriptId");
1304 54 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1305 108 : protocol::Value* scriptSourceValue = object ? object->get("scriptSource") : nullptr;
1306 54 : errors->setName("scriptSource");
1307 54 : String in_scriptSource = ValueConversions<String>::fromValue(scriptSourceValue, errors);
1308 108 : protocol::Value* dryRunValue = object ? object->get("dryRun") : nullptr;
1309 : Maybe<bool> in_dryRun;
1310 54 : if (dryRunValue) {
1311 0 : errors->setName("dryRun");
1312 0 : in_dryRun = ValueConversions<bool>::fromValue(dryRunValue, errors);
1313 : }
1314 54 : errors->pop();
1315 54 : if (errors->hasErrors()) {
1316 18 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1317 9 : return DispatchResponse::kError;
1318 : }
1319 : // Declare output parameters.
1320 : Maybe<protocol::Array<protocol::Debugger::CallFrame>> out_callFrames;
1321 : Maybe<bool> out_stackChanged;
1322 : Maybe<protocol::Runtime::StackTrace> out_asyncStackTrace;
1323 : Maybe<protocol::Runtime::ExceptionDetails> out_exceptionDetails;
1324 :
1325 45 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1326 90 : DispatchResponse response = m_backend->setScriptSource(in_scriptId, in_scriptSource, std::move(in_dryRun), &out_callFrames, &out_stackChanged, &out_asyncStackTrace, &out_exceptionDetails);
1327 45 : if (response.status() == DispatchResponse::kFallThrough)
1328 : return response.status();
1329 45 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1330 45 : if (response.status() == DispatchResponse::kSuccess) {
1331 35 : if (out_callFrames.isJust())
1332 100 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(out_callFrames.fromJust()));
1333 35 : if (out_stackChanged.isJust())
1334 125 : result->setValue("stackChanged", ValueConversions<bool>::toValue(out_stackChanged.fromJust()));
1335 35 : if (out_asyncStackTrace.isJust())
1336 0 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(out_asyncStackTrace.fromJust()));
1337 35 : if (out_exceptionDetails.isJust())
1338 40 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(out_exceptionDetails.fromJust()));
1339 : }
1340 45 : if (weak->get())
1341 90 : weak->get()->sendResponse(callId, response, std::move(result));
1342 45 : return response.status();
1343 : }
1344 :
1345 104 : DispatchResponse::Status DispatcherImpl::restartFrame(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1346 : {
1347 : // Prepare input parameters.
1348 312 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1349 104 : errors->push();
1350 208 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1351 104 : errors->setName("callFrameId");
1352 104 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1353 104 : errors->pop();
1354 104 : if (errors->hasErrors()) {
1355 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1356 0 : return DispatchResponse::kError;
1357 : }
1358 : // Declare output parameters.
1359 104 : std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>> out_callFrames;
1360 : Maybe<protocol::Runtime::StackTrace> out_asyncStackTrace;
1361 :
1362 104 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1363 104 : DispatchResponse response = m_backend->restartFrame(in_callFrameId, &out_callFrames, &out_asyncStackTrace);
1364 104 : if (response.status() == DispatchResponse::kFallThrough)
1365 : return response.status();
1366 104 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1367 104 : if (response.status() == DispatchResponse::kSuccess) {
1368 396 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(out_callFrames.get()));
1369 99 : if (out_asyncStackTrace.isJust())
1370 0 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(out_asyncStackTrace.fromJust()));
1371 : }
1372 104 : if (weak->get())
1373 208 : weak->get()->sendResponse(callId, response, std::move(result));
1374 104 : return response.status();
1375 : }
1376 :
1377 895 : DispatchResponse::Status DispatcherImpl::getScriptSource(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1378 : {
1379 : // Prepare input parameters.
1380 2685 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1381 895 : errors->push();
1382 1790 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1383 895 : errors->setName("scriptId");
1384 895 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1385 895 : errors->pop();
1386 895 : if (errors->hasErrors()) {
1387 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1388 0 : return DispatchResponse::kError;
1389 : }
1390 : // Declare output parameters.
1391 895 : String out_scriptSource;
1392 :
1393 895 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1394 895 : DispatchResponse response = m_backend->getScriptSource(in_scriptId, &out_scriptSource);
1395 895 : if (response.status() == DispatchResponse::kFallThrough)
1396 : return response.status();
1397 895 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1398 895 : if (response.status() == DispatchResponse::kSuccess) {
1399 3580 : result->setValue("scriptSource", ValueConversions<String>::toValue(out_scriptSource));
1400 : }
1401 895 : if (weak->get())
1402 1790 : weak->get()->sendResponse(callId, response, std::move(result));
1403 895 : return response.status();
1404 : }
1405 :
1406 4619 : DispatchResponse::Status DispatcherImpl::setPauseOnExceptions(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1407 : {
1408 : // Prepare input parameters.
1409 13857 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1410 4619 : errors->push();
1411 9238 : protocol::Value* stateValue = object ? object->get("state") : nullptr;
1412 4619 : errors->setName("state");
1413 4619 : String in_state = ValueConversions<String>::fromValue(stateValue, errors);
1414 4619 : errors->pop();
1415 4619 : if (errors->hasErrors()) {
1416 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1417 0 : return DispatchResponse::kError;
1418 : }
1419 :
1420 4619 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1421 4619 : DispatchResponse response = m_backend->setPauseOnExceptions(in_state);
1422 4619 : if (response.status() == DispatchResponse::kFallThrough)
1423 : return response.status();
1424 4619 : if (weak->get())
1425 4619 : weak->get()->sendResponse(callId, response);
1426 4619 : return response.status();
1427 : }
1428 :
1429 9558 : DispatchResponse::Status DispatcherImpl::evaluateOnCallFrame(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1430 : {
1431 : // Prepare input parameters.
1432 28674 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1433 9558 : errors->push();
1434 19116 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1435 9558 : errors->setName("callFrameId");
1436 9558 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1437 19116 : protocol::Value* expressionValue = object ? object->get("expression") : nullptr;
1438 9558 : errors->setName("expression");
1439 9558 : String in_expression = ValueConversions<String>::fromValue(expressionValue, errors);
1440 19116 : protocol::Value* objectGroupValue = object ? object->get("objectGroup") : nullptr;
1441 : Maybe<String> in_objectGroup;
1442 9558 : if (objectGroupValue) {
1443 0 : errors->setName("objectGroup");
1444 0 : in_objectGroup = ValueConversions<String>::fromValue(objectGroupValue, errors);
1445 : }
1446 19116 : protocol::Value* includeCommandLineAPIValue = object ? object->get("includeCommandLineAPI") : nullptr;
1447 : Maybe<bool> in_includeCommandLineAPI;
1448 9558 : if (includeCommandLineAPIValue) {
1449 0 : errors->setName("includeCommandLineAPI");
1450 0 : in_includeCommandLineAPI = ValueConversions<bool>::fromValue(includeCommandLineAPIValue, errors);
1451 : }
1452 19116 : protocol::Value* silentValue = object ? object->get("silent") : nullptr;
1453 : Maybe<bool> in_silent;
1454 9558 : if (silentValue) {
1455 0 : errors->setName("silent");
1456 0 : in_silent = ValueConversions<bool>::fromValue(silentValue, errors);
1457 : }
1458 19116 : protocol::Value* returnByValueValue = object ? object->get("returnByValue") : nullptr;
1459 : Maybe<bool> in_returnByValue;
1460 9558 : if (returnByValueValue) {
1461 0 : errors->setName("returnByValue");
1462 0 : in_returnByValue = ValueConversions<bool>::fromValue(returnByValueValue, errors);
1463 : }
1464 19116 : protocol::Value* generatePreviewValue = object ? object->get("generatePreview") : nullptr;
1465 : Maybe<bool> in_generatePreview;
1466 9558 : if (generatePreviewValue) {
1467 0 : errors->setName("generatePreview");
1468 0 : in_generatePreview = ValueConversions<bool>::fromValue(generatePreviewValue, errors);
1469 : }
1470 19116 : protocol::Value* throwOnSideEffectValue = object ? object->get("throwOnSideEffect") : nullptr;
1471 : Maybe<bool> in_throwOnSideEffect;
1472 9558 : if (throwOnSideEffectValue) {
1473 9053 : errors->setName("throwOnSideEffect");
1474 9053 : in_throwOnSideEffect = ValueConversions<bool>::fromValue(throwOnSideEffectValue, errors);
1475 : }
1476 9558 : errors->pop();
1477 9558 : if (errors->hasErrors()) {
1478 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1479 0 : return DispatchResponse::kError;
1480 : }
1481 : // Declare output parameters.
1482 9558 : std::unique_ptr<protocol::Runtime::RemoteObject> out_result;
1483 : Maybe<protocol::Runtime::ExceptionDetails> out_exceptionDetails;
1484 :
1485 9558 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1486 28674 : DispatchResponse response = m_backend->evaluateOnCallFrame(in_callFrameId, in_expression, std::move(in_objectGroup), std::move(in_includeCommandLineAPI), std::move(in_silent), std::move(in_returnByValue), std::move(in_generatePreview), std::move(in_throwOnSideEffect), &out_result, &out_exceptionDetails);
1487 9558 : if (response.status() == DispatchResponse::kFallThrough)
1488 : return response.status();
1489 9558 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1490 9558 : if (response.status() == DispatchResponse::kSuccess) {
1491 38192 : result->setValue("result", ValueConversions<protocol::Runtime::RemoteObject>::toValue(out_result.get()));
1492 9548 : if (out_exceptionDetails.isJust())
1493 3628 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(out_exceptionDetails.fromJust()));
1494 : }
1495 9558 : if (weak->get())
1496 19116 : weak->get()->sendResponse(callId, response, std::move(result));
1497 9558 : return response.status();
1498 : }
1499 :
1500 221 : DispatchResponse::Status DispatcherImpl::setVariableValue(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1501 : {
1502 : // Prepare input parameters.
1503 663 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1504 221 : errors->push();
1505 442 : protocol::Value* scopeNumberValue = object ? object->get("scopeNumber") : nullptr;
1506 221 : errors->setName("scopeNumber");
1507 221 : int in_scopeNumber = ValueConversions<int>::fromValue(scopeNumberValue, errors);
1508 442 : protocol::Value* variableNameValue = object ? object->get("variableName") : nullptr;
1509 221 : errors->setName("variableName");
1510 221 : String in_variableName = ValueConversions<String>::fromValue(variableNameValue, errors);
1511 442 : protocol::Value* newValueValue = object ? object->get("newValue") : nullptr;
1512 221 : errors->setName("newValue");
1513 : std::unique_ptr<protocol::Runtime::CallArgument> in_newValue = ValueConversions<protocol::Runtime::CallArgument>::fromValue(newValueValue, errors);
1514 442 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1515 221 : errors->setName("callFrameId");
1516 221 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1517 221 : errors->pop();
1518 221 : if (errors->hasErrors()) {
1519 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1520 0 : return DispatchResponse::kError;
1521 : }
1522 :
1523 221 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1524 663 : DispatchResponse response = m_backend->setVariableValue(in_scopeNumber, in_variableName, std::move(in_newValue), in_callFrameId);
1525 221 : if (response.status() == DispatchResponse::kFallThrough)
1526 : return response.status();
1527 221 : if (weak->get())
1528 221 : weak->get()->sendResponse(callId, response);
1529 221 : return response.status();
1530 : }
1531 :
1532 220 : DispatchResponse::Status DispatcherImpl::setAsyncCallStackDepth(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1533 : {
1534 : // Prepare input parameters.
1535 660 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1536 220 : errors->push();
1537 440 : protocol::Value* maxDepthValue = object ? object->get("maxDepth") : nullptr;
1538 220 : errors->setName("maxDepth");
1539 220 : int in_maxDepth = ValueConversions<int>::fromValue(maxDepthValue, errors);
1540 220 : errors->pop();
1541 220 : if (errors->hasErrors()) {
1542 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1543 0 : return DispatchResponse::kError;
1544 : }
1545 :
1546 220 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1547 220 : DispatchResponse response = m_backend->setAsyncCallStackDepth(in_maxDepth);
1548 220 : if (response.status() == DispatchResponse::kFallThrough)
1549 : return response.status();
1550 220 : if (weak->get())
1551 220 : weak->get()->sendResponse(callId, response);
1552 220 : return response.status();
1553 : }
1554 :
1555 57 : DispatchResponse::Status DispatcherImpl::setBlackboxPatterns(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1556 : {
1557 : // Prepare input parameters.
1558 171 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1559 57 : errors->push();
1560 114 : protocol::Value* patternsValue = object ? object->get("patterns") : nullptr;
1561 57 : errors->setName("patterns");
1562 : std::unique_ptr<protocol::Array<String>> in_patterns = ValueConversions<protocol::Array<String>>::fromValue(patternsValue, errors);
1563 57 : errors->pop();
1564 57 : if (errors->hasErrors()) {
1565 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1566 0 : return DispatchResponse::kError;
1567 : }
1568 :
1569 57 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1570 171 : DispatchResponse response = m_backend->setBlackboxPatterns(std::move(in_patterns));
1571 57 : if (response.status() == DispatchResponse::kFallThrough)
1572 : return response.status();
1573 57 : if (weak->get())
1574 57 : weak->get()->sendResponse(callId, response);
1575 57 : return response.status();
1576 : }
1577 :
1578 55 : DispatchResponse::Status DispatcherImpl::setBlackboxedRanges(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1579 : {
1580 : // Prepare input parameters.
1581 165 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1582 55 : errors->push();
1583 110 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1584 55 : errors->setName("scriptId");
1585 55 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1586 110 : protocol::Value* positionsValue = object ? object->get("positions") : nullptr;
1587 55 : errors->setName("positions");
1588 : std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> in_positions = ValueConversions<protocol::Array<protocol::Debugger::ScriptPosition>>::fromValue(positionsValue, errors);
1589 55 : errors->pop();
1590 55 : if (errors->hasErrors()) {
1591 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1592 0 : return DispatchResponse::kError;
1593 : }
1594 :
1595 55 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1596 165 : DispatchResponse response = m_backend->setBlackboxedRanges(in_scriptId, std::move(in_positions));
1597 55 : if (response.status() == DispatchResponse::kFallThrough)
1598 : return response.status();
1599 55 : if (weak->get())
1600 55 : weak->get()->sendResponse(callId, response);
1601 55 : return response.status();
1602 : }
1603 :
1604 : // static
1605 3406 : void Dispatcher::wire(UberDispatcher* uber, Backend* backend)
1606 : {
1607 3406 : std::unique_ptr<DispatcherImpl> dispatcher(new DispatcherImpl(uber->channel(), backend, uber->fallThroughForNotFound()));
1608 3406 : uber->setupRedirects(dispatcher->redirects());
1609 10218 : uber->registerBackend("Debugger", std::move(dispatcher));
1610 3406 : }
1611 :
1612 : } // Debugger
1613 : } // namespace v8_inspector
1614 : } // namespace protocol
|