Line data Source code
1 : // This file is generated by TypeBuilder_cpp.template.
2 :
3 : // Copyright (c) 2016 The Chromium Authors. All rights reserved.
4 : // Use of this source code is governed by a BSD-style license that can be
5 : // found in the LICENSE file.
6 :
7 : #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.3";
20 :
21 4649 : std::unique_ptr<Location> Location::fromValue(protocol::Value* value, ErrorSupport* errors)
22 : {
23 4649 : if (!value || value->type() != protocol::Value::TypeObject) {
24 5 : errors->addError("object expected");
25 : return nullptr;
26 : }
27 :
28 2322 : std::unique_ptr<Location> result(new Location());
29 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
30 2322 : errors->push();
31 4644 : protocol::Value* scriptIdValue = object->get("scriptId");
32 2322 : errors->setName("scriptId");
33 4644 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
34 4644 : protocol::Value* lineNumberValue = object->get("lineNumber");
35 2322 : errors->setName("lineNumber");
36 2322 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
37 4644 : protocol::Value* columnNumberValue = object->get("columnNumber");
38 2322 : if (columnNumberValue) {
39 2130 : errors->setName("columnNumber");
40 2130 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
41 : }
42 2322 : errors->pop();
43 2322 : if (errors->hasErrors())
44 : return nullptr;
45 : return result;
46 : }
47 :
48 604404 : std::unique_ptr<protocol::DictionaryValue> Location::toValue() const
49 : {
50 604404 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
51 3022020 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
52 3022020 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
53 604404 : if (m_columnNumber.isJust())
54 2417616 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber.fromJust()));
55 604404 : 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 146601 : std::unique_ptr<protocol::DictionaryValue> CallFrame::toValue() const
145 : {
146 146601 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
147 733005 : result->setValue("callFrameId", ValueConversions<String>::toValue(m_callFrameId));
148 733005 : result->setValue("functionName", ValueConversions<String>::toValue(m_functionName));
149 146601 : if (m_functionLocation.isJust())
150 584212 : result->setValue("functionLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_functionLocation.fromJust()));
151 586404 : result->setValue("location", ValueConversions<protocol::Debugger::Location>::toValue(m_location.get()));
152 733005 : result->setValue("url", ValueConversions<String>::toValue(m_url));
153 586404 : result->setValue("scopeChain", ValueConversions<protocol::Array<protocol::Debugger::Scope>>::toValue(m_scopeChain.get()));
154 586404 : result->setValue("this", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_this.get()));
155 146601 : if (m_returnValue.isJust())
156 22868 : result->setValue("returnValue", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_returnValue.fromJust()));
157 146601 : 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 371837 : std::unique_ptr<protocol::DictionaryValue> Scope::toValue() const
214 : {
215 371837 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
216 1859185 : result->setValue("type", ValueConversions<String>::toValue(m_type));
217 1487348 : result->setValue("object", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_object.get()));
218 371837 : if (m_name.isJust())
219 442730 : result->setValue("name", ValueConversions<String>::toValue(m_name.fromJust()));
220 371837 : if (m_startLocation.isJust())
221 619284 : result->setValue("startLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_startLocation.fromJust()));
222 371837 : if (m_endLocation.isJust())
223 619284 : result->setValue("endLocation", ValueConversions<protocol::Debugger::Location>::toValue(m_endLocation.fromJust()));
224 371837 : 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()->serializeToJSON();
272 0 : return StringBufferImpl::adopt(json);
273 : }
274 :
275 0 : void SearchMatch::writeBinary(std::vector<uint8_t>* out) const
276 : {
277 0 : toValue()->writeBinary(out);
278 0 : }
279 :
280 : // static
281 0 : std::unique_ptr<API::SearchMatch> API::SearchMatch::fromJSONString(const StringView& json)
282 : {
283 0 : ErrorSupport errors;
284 0 : std::unique_ptr<Value> value = StringUtil::parseJSON(json);
285 0 : if (!value)
286 : return nullptr;
287 0 : return protocol::Debugger::SearchMatch::fromValue(value.get(), &errors);
288 : }
289 :
290 : // static
291 0 : std::unique_ptr<API::SearchMatch> API::SearchMatch::fromBinary(const uint8_t* data, size_t length)
292 : {
293 0 : ErrorSupport errors;
294 0 : std::unique_ptr<Value> value = Value::parseBinary(data, length);
295 0 : if (!value)
296 : return nullptr;
297 0 : return protocol::Debugger::SearchMatch::fromValue(value.get(), &errors);
298 : }
299 :
300 :
301 : const char* BreakLocation::TypeEnum::DebuggerStatement = "debuggerStatement";
302 : const char* BreakLocation::TypeEnum::Call = "call";
303 : const char* BreakLocation::TypeEnum::Return = "return";
304 :
305 0 : std::unique_ptr<BreakLocation> BreakLocation::fromValue(protocol::Value* value, ErrorSupport* errors)
306 : {
307 0 : if (!value || value->type() != protocol::Value::TypeObject) {
308 0 : errors->addError("object expected");
309 : return nullptr;
310 : }
311 :
312 0 : std::unique_ptr<BreakLocation> result(new BreakLocation());
313 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
314 0 : errors->push();
315 0 : protocol::Value* scriptIdValue = object->get("scriptId");
316 0 : errors->setName("scriptId");
317 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
318 0 : protocol::Value* lineNumberValue = object->get("lineNumber");
319 0 : errors->setName("lineNumber");
320 0 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
321 0 : protocol::Value* columnNumberValue = object->get("columnNumber");
322 0 : if (columnNumberValue) {
323 0 : errors->setName("columnNumber");
324 0 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
325 : }
326 0 : protocol::Value* typeValue = object->get("type");
327 0 : if (typeValue) {
328 0 : errors->setName("type");
329 0 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
330 : }
331 0 : errors->pop();
332 0 : if (errors->hasErrors())
333 : return nullptr;
334 : return result;
335 : }
336 :
337 4252 : std::unique_ptr<protocol::DictionaryValue> BreakLocation::toValue() const
338 : {
339 4252 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
340 21260 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
341 21260 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
342 4252 : if (m_columnNumber.isJust())
343 17008 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber.fromJust()));
344 4252 : if (m_type.isJust())
345 12525 : result->setValue("type", ValueConversions<String>::toValue(m_type.fromJust()));
346 4252 : return result;
347 : }
348 :
349 0 : std::unique_ptr<BreakLocation> BreakLocation::clone() const
350 : {
351 0 : ErrorSupport errors;
352 0 : return fromValue(toValue().get(), &errors);
353 : }
354 :
355 0 : std::unique_ptr<BreakpointResolvedNotification> BreakpointResolvedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
356 : {
357 0 : if (!value || value->type() != protocol::Value::TypeObject) {
358 0 : errors->addError("object expected");
359 : return nullptr;
360 : }
361 :
362 0 : std::unique_ptr<BreakpointResolvedNotification> result(new BreakpointResolvedNotification());
363 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
364 0 : errors->push();
365 0 : protocol::Value* breakpointIdValue = object->get("breakpointId");
366 0 : errors->setName("breakpointId");
367 0 : result->m_breakpointId = ValueConversions<String>::fromValue(breakpointIdValue, errors);
368 0 : protocol::Value* locationValue = object->get("location");
369 0 : errors->setName("location");
370 0 : result->m_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
371 0 : errors->pop();
372 0 : if (errors->hasErrors())
373 : return nullptr;
374 : return result;
375 : }
376 :
377 70 : std::unique_ptr<protocol::DictionaryValue> BreakpointResolvedNotification::toValue() const
378 : {
379 70 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
380 350 : result->setValue("breakpointId", ValueConversions<String>::toValue(m_breakpointId));
381 280 : result->setValue("location", ValueConversions<protocol::Debugger::Location>::toValue(m_location.get()));
382 70 : return result;
383 : }
384 :
385 0 : std::unique_ptr<BreakpointResolvedNotification> BreakpointResolvedNotification::clone() const
386 : {
387 0 : ErrorSupport errors;
388 0 : return fromValue(toValue().get(), &errors);
389 : }
390 :
391 : const char* PausedNotification::ReasonEnum::XHR = "XHR";
392 : const char* PausedNotification::ReasonEnum::DOM = "DOM";
393 : const char* PausedNotification::ReasonEnum::EventListener = "EventListener";
394 : const char* PausedNotification::ReasonEnum::Exception = "exception";
395 : const char* PausedNotification::ReasonEnum::Assert = "assert";
396 : const char* PausedNotification::ReasonEnum::DebugCommand = "debugCommand";
397 : const char* PausedNotification::ReasonEnum::PromiseRejection = "promiseRejection";
398 : const char* PausedNotification::ReasonEnum::OOM = "OOM";
399 : const char* PausedNotification::ReasonEnum::Other = "other";
400 : const char* PausedNotification::ReasonEnum::Ambiguous = "ambiguous";
401 :
402 0 : std::unique_ptr<PausedNotification> PausedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
403 : {
404 0 : if (!value || value->type() != protocol::Value::TypeObject) {
405 0 : errors->addError("object expected");
406 : return nullptr;
407 : }
408 :
409 0 : std::unique_ptr<PausedNotification> result(new PausedNotification());
410 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
411 0 : errors->push();
412 0 : protocol::Value* callFramesValue = object->get("callFrames");
413 0 : errors->setName("callFrames");
414 0 : result->m_callFrames = ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::fromValue(callFramesValue, errors);
415 0 : protocol::Value* reasonValue = object->get("reason");
416 0 : errors->setName("reason");
417 0 : result->m_reason = ValueConversions<String>::fromValue(reasonValue, errors);
418 0 : protocol::Value* dataValue = object->get("data");
419 0 : if (dataValue) {
420 0 : errors->setName("data");
421 0 : result->m_data = ValueConversions<protocol::DictionaryValue>::fromValue(dataValue, errors);
422 : }
423 0 : protocol::Value* hitBreakpointsValue = object->get("hitBreakpoints");
424 0 : if (hitBreakpointsValue) {
425 0 : errors->setName("hitBreakpoints");
426 0 : result->m_hitBreakpoints = ValueConversions<protocol::Array<String>>::fromValue(hitBreakpointsValue, errors);
427 : }
428 0 : protocol::Value* asyncStackTraceValue = object->get("asyncStackTrace");
429 0 : if (asyncStackTraceValue) {
430 0 : errors->setName("asyncStackTrace");
431 0 : result->m_asyncStackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(asyncStackTraceValue, errors);
432 : }
433 0 : protocol::Value* asyncStackTraceIdValue = object->get("asyncStackTraceId");
434 0 : if (asyncStackTraceIdValue) {
435 0 : errors->setName("asyncStackTraceId");
436 0 : result->m_asyncStackTraceId = ValueConversions<protocol::Runtime::StackTraceId>::fromValue(asyncStackTraceIdValue, errors);
437 : }
438 0 : protocol::Value* asyncCallStackTraceIdValue = object->get("asyncCallStackTraceId");
439 0 : if (asyncCallStackTraceIdValue) {
440 0 : errors->setName("asyncCallStackTraceId");
441 0 : result->m_asyncCallStackTraceId = ValueConversions<protocol::Runtime::StackTraceId>::fromValue(asyncCallStackTraceIdValue, errors);
442 : }
443 0 : errors->pop();
444 0 : if (errors->hasErrors())
445 : return nullptr;
446 : return result;
447 : }
448 :
449 55416 : std::unique_ptr<protocol::DictionaryValue> PausedNotification::toValue() const
450 : {
451 55416 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
452 221664 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(m_callFrames.get()));
453 277080 : result->setValue("reason", ValueConversions<String>::toValue(m_reason));
454 55416 : if (m_data.isJust())
455 7796 : result->setValue("data", ValueConversions<protocol::DictionaryValue>::toValue(m_data.fromJust()));
456 55416 : if (m_hitBreakpoints.isJust())
457 221664 : result->setValue("hitBreakpoints", ValueConversions<protocol::Array<String>>::toValue(m_hitBreakpoints.fromJust()));
458 55416 : if (m_asyncStackTrace.isJust())
459 2500 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_asyncStackTrace.fromJust()));
460 55416 : if (m_asyncStackTraceId.isJust())
461 100 : result->setValue("asyncStackTraceId", ValueConversions<protocol::Runtime::StackTraceId>::toValue(m_asyncStackTraceId.fromJust()));
462 55416 : if (m_asyncCallStackTraceId.isJust())
463 380 : result->setValue("asyncCallStackTraceId", ValueConversions<protocol::Runtime::StackTraceId>::toValue(m_asyncCallStackTraceId.fromJust()));
464 55416 : return result;
465 : }
466 :
467 0 : std::unique_ptr<PausedNotification> PausedNotification::clone() const
468 : {
469 0 : ErrorSupport errors;
470 0 : return fromValue(toValue().get(), &errors);
471 : }
472 :
473 0 : std::unique_ptr<ScriptFailedToParseNotification> ScriptFailedToParseNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
474 : {
475 0 : if (!value || value->type() != protocol::Value::TypeObject) {
476 0 : errors->addError("object expected");
477 : return nullptr;
478 : }
479 :
480 0 : std::unique_ptr<ScriptFailedToParseNotification> result(new ScriptFailedToParseNotification());
481 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
482 0 : errors->push();
483 0 : protocol::Value* scriptIdValue = object->get("scriptId");
484 0 : errors->setName("scriptId");
485 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
486 0 : protocol::Value* urlValue = object->get("url");
487 0 : errors->setName("url");
488 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
489 0 : protocol::Value* startLineValue = object->get("startLine");
490 0 : errors->setName("startLine");
491 0 : result->m_startLine = ValueConversions<int>::fromValue(startLineValue, errors);
492 0 : protocol::Value* startColumnValue = object->get("startColumn");
493 0 : errors->setName("startColumn");
494 0 : result->m_startColumn = ValueConversions<int>::fromValue(startColumnValue, errors);
495 0 : protocol::Value* endLineValue = object->get("endLine");
496 0 : errors->setName("endLine");
497 0 : result->m_endLine = ValueConversions<int>::fromValue(endLineValue, errors);
498 0 : protocol::Value* endColumnValue = object->get("endColumn");
499 0 : errors->setName("endColumn");
500 0 : result->m_endColumn = ValueConversions<int>::fromValue(endColumnValue, errors);
501 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
502 0 : errors->setName("executionContextId");
503 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
504 0 : protocol::Value* hashValue = object->get("hash");
505 0 : errors->setName("hash");
506 0 : result->m_hash = ValueConversions<String>::fromValue(hashValue, errors);
507 0 : protocol::Value* executionContextAuxDataValue = object->get("executionContextAuxData");
508 0 : if (executionContextAuxDataValue) {
509 0 : errors->setName("executionContextAuxData");
510 0 : result->m_executionContextAuxData = ValueConversions<protocol::DictionaryValue>::fromValue(executionContextAuxDataValue, errors);
511 : }
512 0 : protocol::Value* sourceMapURLValue = object->get("sourceMapURL");
513 0 : if (sourceMapURLValue) {
514 0 : errors->setName("sourceMapURL");
515 0 : result->m_sourceMapURL = ValueConversions<String>::fromValue(sourceMapURLValue, errors);
516 : }
517 0 : protocol::Value* hasSourceURLValue = object->get("hasSourceURL");
518 0 : if (hasSourceURLValue) {
519 0 : errors->setName("hasSourceURL");
520 0 : result->m_hasSourceURL = ValueConversions<bool>::fromValue(hasSourceURLValue, errors);
521 : }
522 0 : protocol::Value* isModuleValue = object->get("isModule");
523 0 : if (isModuleValue) {
524 0 : errors->setName("isModule");
525 0 : result->m_isModule = ValueConversions<bool>::fromValue(isModuleValue, errors);
526 : }
527 0 : protocol::Value* lengthValue = object->get("length");
528 0 : if (lengthValue) {
529 0 : errors->setName("length");
530 0 : result->m_length = ValueConversions<int>::fromValue(lengthValue, errors);
531 : }
532 0 : protocol::Value* stackTraceValue = object->get("stackTrace");
533 0 : if (stackTraceValue) {
534 0 : errors->setName("stackTrace");
535 0 : result->m_stackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(stackTraceValue, errors);
536 : }
537 0 : errors->pop();
538 0 : if (errors->hasErrors())
539 : return nullptr;
540 : return result;
541 : }
542 :
543 5201 : std::unique_ptr<protocol::DictionaryValue> ScriptFailedToParseNotification::toValue() const
544 : {
545 5201 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
546 26005 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
547 26005 : result->setValue("url", ValueConversions<String>::toValue(m_url));
548 26005 : result->setValue("startLine", ValueConversions<int>::toValue(m_startLine));
549 26005 : result->setValue("startColumn", ValueConversions<int>::toValue(m_startColumn));
550 26005 : result->setValue("endLine", ValueConversions<int>::toValue(m_endLine));
551 26005 : result->setValue("endColumn", ValueConversions<int>::toValue(m_endColumn));
552 26005 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
553 26005 : result->setValue("hash", ValueConversions<String>::toValue(m_hash));
554 5201 : if (m_executionContextAuxData.isJust())
555 0 : result->setValue("executionContextAuxData", ValueConversions<protocol::DictionaryValue>::toValue(m_executionContextAuxData.fromJust()));
556 5201 : if (m_sourceMapURL.isJust())
557 26005 : result->setValue("sourceMapURL", ValueConversions<String>::toValue(m_sourceMapURL.fromJust()));
558 5201 : if (m_hasSourceURL.isJust())
559 20804 : result->setValue("hasSourceURL", ValueConversions<bool>::toValue(m_hasSourceURL.fromJust()));
560 5201 : if (m_isModule.isJust())
561 20804 : result->setValue("isModule", ValueConversions<bool>::toValue(m_isModule.fromJust()));
562 5201 : if (m_length.isJust())
563 20804 : result->setValue("length", ValueConversions<int>::toValue(m_length.fromJust()));
564 5201 : if (m_stackTrace.isJust())
565 20484 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_stackTrace.fromJust()));
566 5201 : return result;
567 : }
568 :
569 0 : std::unique_ptr<ScriptFailedToParseNotification> ScriptFailedToParseNotification::clone() const
570 : {
571 0 : ErrorSupport errors;
572 0 : return fromValue(toValue().get(), &errors);
573 : }
574 :
575 0 : std::unique_ptr<ScriptParsedNotification> ScriptParsedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
576 : {
577 0 : if (!value || value->type() != protocol::Value::TypeObject) {
578 0 : errors->addError("object expected");
579 : return nullptr;
580 : }
581 :
582 0 : std::unique_ptr<ScriptParsedNotification> result(new ScriptParsedNotification());
583 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
584 0 : errors->push();
585 0 : protocol::Value* scriptIdValue = object->get("scriptId");
586 0 : errors->setName("scriptId");
587 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
588 0 : protocol::Value* urlValue = object->get("url");
589 0 : errors->setName("url");
590 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
591 0 : protocol::Value* startLineValue = object->get("startLine");
592 0 : errors->setName("startLine");
593 0 : result->m_startLine = ValueConversions<int>::fromValue(startLineValue, errors);
594 0 : protocol::Value* startColumnValue = object->get("startColumn");
595 0 : errors->setName("startColumn");
596 0 : result->m_startColumn = ValueConversions<int>::fromValue(startColumnValue, errors);
597 0 : protocol::Value* endLineValue = object->get("endLine");
598 0 : errors->setName("endLine");
599 0 : result->m_endLine = ValueConversions<int>::fromValue(endLineValue, errors);
600 0 : protocol::Value* endColumnValue = object->get("endColumn");
601 0 : errors->setName("endColumn");
602 0 : result->m_endColumn = ValueConversions<int>::fromValue(endColumnValue, errors);
603 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
604 0 : errors->setName("executionContextId");
605 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
606 0 : protocol::Value* hashValue = object->get("hash");
607 0 : errors->setName("hash");
608 0 : result->m_hash = ValueConversions<String>::fromValue(hashValue, errors);
609 0 : protocol::Value* executionContextAuxDataValue = object->get("executionContextAuxData");
610 0 : if (executionContextAuxDataValue) {
611 0 : errors->setName("executionContextAuxData");
612 0 : result->m_executionContextAuxData = ValueConversions<protocol::DictionaryValue>::fromValue(executionContextAuxDataValue, errors);
613 : }
614 0 : protocol::Value* isLiveEditValue = object->get("isLiveEdit");
615 0 : if (isLiveEditValue) {
616 0 : errors->setName("isLiveEdit");
617 0 : result->m_isLiveEdit = ValueConversions<bool>::fromValue(isLiveEditValue, errors);
618 : }
619 0 : protocol::Value* sourceMapURLValue = object->get("sourceMapURL");
620 0 : if (sourceMapURLValue) {
621 0 : errors->setName("sourceMapURL");
622 0 : result->m_sourceMapURL = ValueConversions<String>::fromValue(sourceMapURLValue, errors);
623 : }
624 0 : protocol::Value* hasSourceURLValue = object->get("hasSourceURL");
625 0 : if (hasSourceURLValue) {
626 0 : errors->setName("hasSourceURL");
627 0 : result->m_hasSourceURL = ValueConversions<bool>::fromValue(hasSourceURLValue, errors);
628 : }
629 0 : protocol::Value* isModuleValue = object->get("isModule");
630 0 : if (isModuleValue) {
631 0 : errors->setName("isModule");
632 0 : result->m_isModule = ValueConversions<bool>::fromValue(isModuleValue, errors);
633 : }
634 0 : protocol::Value* lengthValue = object->get("length");
635 0 : if (lengthValue) {
636 0 : errors->setName("length");
637 0 : result->m_length = ValueConversions<int>::fromValue(lengthValue, errors);
638 : }
639 0 : protocol::Value* stackTraceValue = object->get("stackTrace");
640 0 : if (stackTraceValue) {
641 0 : errors->setName("stackTrace");
642 0 : result->m_stackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(stackTraceValue, errors);
643 : }
644 0 : errors->pop();
645 0 : if (errors->hasErrors())
646 : return nullptr;
647 : return result;
648 : }
649 :
650 55326 : std::unique_ptr<protocol::DictionaryValue> ScriptParsedNotification::toValue() const
651 : {
652 55326 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
653 276630 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
654 276630 : result->setValue("url", ValueConversions<String>::toValue(m_url));
655 276630 : result->setValue("startLine", ValueConversions<int>::toValue(m_startLine));
656 276630 : result->setValue("startColumn", ValueConversions<int>::toValue(m_startColumn));
657 276630 : result->setValue("endLine", ValueConversions<int>::toValue(m_endLine));
658 276630 : result->setValue("endColumn", ValueConversions<int>::toValue(m_endColumn));
659 276630 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
660 276630 : result->setValue("hash", ValueConversions<String>::toValue(m_hash));
661 55326 : if (m_executionContextAuxData.isJust())
662 0 : result->setValue("executionContextAuxData", ValueConversions<protocol::DictionaryValue>::toValue(m_executionContextAuxData.fromJust()));
663 55326 : if (m_isLiveEdit.isJust())
664 221304 : result->setValue("isLiveEdit", ValueConversions<bool>::toValue(m_isLiveEdit.fromJust()));
665 55326 : if (m_sourceMapURL.isJust())
666 276630 : result->setValue("sourceMapURL", ValueConversions<String>::toValue(m_sourceMapURL.fromJust()));
667 55326 : if (m_hasSourceURL.isJust())
668 221304 : result->setValue("hasSourceURL", ValueConversions<bool>::toValue(m_hasSourceURL.fromJust()));
669 55326 : if (m_isModule.isJust())
670 221304 : result->setValue("isModule", ValueConversions<bool>::toValue(m_isModule.fromJust()));
671 55326 : if (m_length.isJust())
672 221304 : result->setValue("length", ValueConversions<int>::toValue(m_length.fromJust()));
673 55326 : if (m_stackTrace.isJust())
674 192712 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_stackTrace.fromJust()));
675 55326 : return result;
676 : }
677 :
678 0 : std::unique_ptr<ScriptParsedNotification> ScriptParsedNotification::clone() const
679 : {
680 0 : ErrorSupport errors;
681 0 : return fromValue(toValue().get(), &errors);
682 : }
683 :
684 : // ------------- Enum values from params.
685 :
686 :
687 : namespace ContinueToLocation {
688 : namespace TargetCallFramesEnum {
689 : const char* Any = "any";
690 : const char* Current = "current";
691 : } // namespace TargetCallFramesEnum
692 : } // namespace ContinueToLocation
693 :
694 : namespace SetPauseOnExceptions {
695 : namespace StateEnum {
696 : const char* None = "none";
697 : const char* Uncaught = "uncaught";
698 : const char* All = "all";
699 : } // namespace StateEnum
700 : } // namespace SetPauseOnExceptions
701 :
702 : namespace Paused {
703 : namespace ReasonEnum {
704 : const char* XHR = "XHR";
705 : const char* DOM = "DOM";
706 : const char* EventListener = "EventListener";
707 : const char* Exception = "exception";
708 : const char* Assert = "assert";
709 : const char* DebugCommand = "debugCommand";
710 : const char* PromiseRejection = "promiseRejection";
711 : const char* OOM = "OOM";
712 : const char* Other = "other";
713 : const char* Ambiguous = "ambiguous";
714 : } // namespace ReasonEnum
715 : } // namespace Paused
716 :
717 : namespace API {
718 : namespace Paused {
719 : namespace ReasonEnum {
720 : const char* XHR = "XHR";
721 : const char* DOM = "DOM";
722 : const char* EventListener = "EventListener";
723 : const char* Exception = "exception";
724 : const char* Assert = "assert";
725 : const char* DebugCommand = "debugCommand";
726 : const char* PromiseRejection = "promiseRejection";
727 : const char* OOM = "OOM";
728 : const char* Other = "other";
729 : const char* Ambiguous = "ambiguous";
730 : } // namespace ReasonEnum
731 : } // namespace Paused
732 : } // namespace API
733 :
734 : // ------------- Frontend notifications.
735 :
736 70 : void Frontend::breakpointResolved(const String& breakpointId, std::unique_ptr<protocol::Debugger::Location> location)
737 : {
738 70 : if (!m_frontendChannel)
739 70 : return;
740 : std::unique_ptr<BreakpointResolvedNotification> messageData = BreakpointResolvedNotification::create()
741 70 : .setBreakpointId(breakpointId)
742 : .setLocation(std::move(location))
743 : .build();
744 490 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.breakpointResolved", std::move(messageData)));
745 : }
746 :
747 55416 : 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, Maybe<protocol::Runtime::StackTraceId> asyncStackTraceId, Maybe<protocol::Runtime::StackTraceId> asyncCallStackTraceId)
748 : {
749 55416 : if (!m_frontendChannel)
750 55416 : return;
751 : std::unique_ptr<PausedNotification> messageData = PausedNotification::create()
752 55416 : .setCallFrames(std::move(callFrames))
753 : .setReason(reason)
754 : .build();
755 55416 : if (data.isJust())
756 : messageData->setData(std::move(data).takeJust());
757 55416 : if (hitBreakpoints.isJust())
758 : messageData->setHitBreakpoints(std::move(hitBreakpoints).takeJust());
759 55416 : if (asyncStackTrace.isJust())
760 : messageData->setAsyncStackTrace(std::move(asyncStackTrace).takeJust());
761 55416 : if (asyncStackTraceId.isJust())
762 : messageData->setAsyncStackTraceId(std::move(asyncStackTraceId).takeJust());
763 55416 : if (asyncCallStackTraceId.isJust())
764 : messageData->setAsyncCallStackTraceId(std::move(asyncCallStackTraceId).takeJust());
765 387912 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.paused", std::move(messageData)));
766 : }
767 :
768 55144 : void Frontend::resumed()
769 : {
770 55144 : if (!m_frontendChannel)
771 55144 : return;
772 386008 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.resumed"));
773 : }
774 :
775 5201 : 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)
776 : {
777 5201 : if (!m_frontendChannel)
778 5201 : return;
779 : std::unique_ptr<ScriptFailedToParseNotification> messageData = ScriptFailedToParseNotification::create()
780 5201 : .setScriptId(scriptId)
781 : .setUrl(url)
782 : .setStartLine(startLine)
783 : .setStartColumn(startColumn)
784 : .setEndLine(endLine)
785 : .setEndColumn(endColumn)
786 : .setExecutionContextId(executionContextId)
787 : .setHash(hash)
788 : .build();
789 5201 : if (executionContextAuxData.isJust())
790 : messageData->setExecutionContextAuxData(std::move(executionContextAuxData).takeJust());
791 5201 : if (sourceMapURL.isJust())
792 10402 : messageData->setSourceMapURL(std::move(sourceMapURL).takeJust());
793 5201 : if (hasSourceURL.isJust())
794 5201 : messageData->setHasSourceURL(std::move(hasSourceURL).takeJust());
795 5201 : if (isModule.isJust())
796 5201 : messageData->setIsModule(std::move(isModule).takeJust());
797 5201 : if (length.isJust())
798 5201 : messageData->setLength(std::move(length).takeJust());
799 5201 : if (stackTrace.isJust())
800 : messageData->setStackTrace(std::move(stackTrace).takeJust());
801 36407 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.scriptFailedToParse", std::move(messageData)));
802 : }
803 :
804 55326 : 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)
805 : {
806 55326 : if (!m_frontendChannel)
807 55326 : return;
808 : std::unique_ptr<ScriptParsedNotification> messageData = ScriptParsedNotification::create()
809 55326 : .setScriptId(scriptId)
810 : .setUrl(url)
811 : .setStartLine(startLine)
812 : .setStartColumn(startColumn)
813 : .setEndLine(endLine)
814 : .setEndColumn(endColumn)
815 : .setExecutionContextId(executionContextId)
816 : .setHash(hash)
817 : .build();
818 55326 : if (executionContextAuxData.isJust())
819 : messageData->setExecutionContextAuxData(std::move(executionContextAuxData).takeJust());
820 55326 : if (isLiveEdit.isJust())
821 55326 : messageData->setIsLiveEdit(std::move(isLiveEdit).takeJust());
822 55326 : if (sourceMapURL.isJust())
823 110652 : messageData->setSourceMapURL(std::move(sourceMapURL).takeJust());
824 55326 : if (hasSourceURL.isJust())
825 55326 : messageData->setHasSourceURL(std::move(hasSourceURL).takeJust());
826 55326 : if (isModule.isJust())
827 55326 : messageData->setIsModule(std::move(isModule).takeJust());
828 55326 : if (length.isJust())
829 55326 : messageData->setLength(std::move(length).takeJust());
830 55326 : if (stackTrace.isJust())
831 : messageData->setStackTrace(std::move(stackTrace).takeJust());
832 387282 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Debugger.scriptParsed", std::move(messageData)));
833 : }
834 :
835 0 : void Frontend::flush()
836 : {
837 0 : m_frontendChannel->flushProtocolNotifications();
838 0 : }
839 :
840 0 : void Frontend::sendRawNotification(String notification)
841 : {
842 0 : m_frontendChannel->sendProtocolNotification(InternalRawNotification::fromJSON(std::move(notification)));
843 0 : }
844 :
845 0 : void Frontend::sendRawNotification(std::vector<uint8_t> notification)
846 : {
847 0 : m_frontendChannel->sendProtocolNotification(InternalRawNotification::fromBinary(std::move(notification)));
848 0 : }
849 :
850 : // --------------------- Dispatcher.
851 :
852 : class DispatcherImpl : public protocol::DispatcherBase {
853 : public:
854 3832 : DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend)
855 : : DispatcherBase(frontendChannel)
856 11496 : , m_backend(backend) {
857 11496 : m_dispatchMap["Debugger.continueToLocation"] = &DispatcherImpl::continueToLocation;
858 11496 : m_dispatchMap["Debugger.disable"] = &DispatcherImpl::disable;
859 11496 : m_dispatchMap["Debugger.enable"] = &DispatcherImpl::enable;
860 11496 : m_dispatchMap["Debugger.evaluateOnCallFrame"] = &DispatcherImpl::evaluateOnCallFrame;
861 11496 : m_dispatchMap["Debugger.getPossibleBreakpoints"] = &DispatcherImpl::getPossibleBreakpoints;
862 11496 : m_dispatchMap["Debugger.getScriptSource"] = &DispatcherImpl::getScriptSource;
863 11496 : m_dispatchMap["Debugger.getStackTrace"] = &DispatcherImpl::getStackTrace;
864 11496 : m_dispatchMap["Debugger.pause"] = &DispatcherImpl::pause;
865 11496 : m_dispatchMap["Debugger.pauseOnAsyncCall"] = &DispatcherImpl::pauseOnAsyncCall;
866 11496 : m_dispatchMap["Debugger.removeBreakpoint"] = &DispatcherImpl::removeBreakpoint;
867 11496 : m_dispatchMap["Debugger.restartFrame"] = &DispatcherImpl::restartFrame;
868 11496 : m_dispatchMap["Debugger.resume"] = &DispatcherImpl::resume;
869 11496 : m_dispatchMap["Debugger.searchInContent"] = &DispatcherImpl::searchInContent;
870 11496 : m_dispatchMap["Debugger.setAsyncCallStackDepth"] = &DispatcherImpl::setAsyncCallStackDepth;
871 11496 : m_dispatchMap["Debugger.setBlackboxPatterns"] = &DispatcherImpl::setBlackboxPatterns;
872 11496 : m_dispatchMap["Debugger.setBlackboxedRanges"] = &DispatcherImpl::setBlackboxedRanges;
873 11496 : m_dispatchMap["Debugger.setBreakpoint"] = &DispatcherImpl::setBreakpoint;
874 11496 : m_dispatchMap["Debugger.setBreakpointByUrl"] = &DispatcherImpl::setBreakpointByUrl;
875 11496 : m_dispatchMap["Debugger.setBreakpointOnFunctionCall"] = &DispatcherImpl::setBreakpointOnFunctionCall;
876 11496 : m_dispatchMap["Debugger.setBreakpointsActive"] = &DispatcherImpl::setBreakpointsActive;
877 11496 : m_dispatchMap["Debugger.setPauseOnExceptions"] = &DispatcherImpl::setPauseOnExceptions;
878 11496 : m_dispatchMap["Debugger.setReturnValue"] = &DispatcherImpl::setReturnValue;
879 11496 : m_dispatchMap["Debugger.setScriptSource"] = &DispatcherImpl::setScriptSource;
880 11496 : m_dispatchMap["Debugger.setSkipAllPauses"] = &DispatcherImpl::setSkipAllPauses;
881 11496 : m_dispatchMap["Debugger.setVariableValue"] = &DispatcherImpl::setVariableValue;
882 11496 : m_dispatchMap["Debugger.stepInto"] = &DispatcherImpl::stepInto;
883 11496 : m_dispatchMap["Debugger.stepOut"] = &DispatcherImpl::stepOut;
884 11496 : m_dispatchMap["Debugger.stepOver"] = &DispatcherImpl::stepOver;
885 3832 : }
886 11496 : ~DispatcherImpl() override { }
887 : bool canDispatch(const String& method) override;
888 : void dispatch(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<protocol::DictionaryValue> messageObject) override;
889 : std::unordered_map<String, String>& redirects() { return m_redirects; }
890 :
891 : protected:
892 : using CallHandler = void (DispatcherImpl::*)(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
893 : using DispatchMap = std::unordered_map<String, CallHandler>;
894 : DispatchMap m_dispatchMap;
895 : std::unordered_map<String, String> m_redirects;
896 :
897 : void continueToLocation(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
898 : void disable(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
899 : void enable(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
900 : void evaluateOnCallFrame(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
901 : void getPossibleBreakpoints(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
902 : void getScriptSource(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
903 : void getStackTrace(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
904 : void pause(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
905 : void pauseOnAsyncCall(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
906 : void removeBreakpoint(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
907 : void restartFrame(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
908 : void resume(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
909 : void searchInContent(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
910 : void setAsyncCallStackDepth(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
911 : void setBlackboxPatterns(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
912 : void setBlackboxedRanges(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
913 : void setBreakpoint(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
914 : void setBreakpointByUrl(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
915 : void setBreakpointOnFunctionCall(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
916 : void setBreakpointsActive(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
917 : void setPauseOnExceptions(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
918 : void setReturnValue(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
919 : void setScriptSource(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
920 : void setSkipAllPauses(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
921 : void setVariableValue(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
922 : void stepInto(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
923 : void stepOut(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
924 : void stepOver(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
925 :
926 : Backend* m_backend;
927 : };
928 :
929 88391 : bool DispatcherImpl::canDispatch(const String& method) {
930 88391 : return m_dispatchMap.find(method) != m_dispatchMap.end();
931 : }
932 :
933 88391 : void DispatcherImpl::dispatch(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<protocol::DictionaryValue> messageObject)
934 : {
935 : std::unordered_map<String, CallHandler>::iterator it = m_dispatchMap.find(method);
936 : DCHECK(it != m_dispatchMap.end());
937 88391 : protocol::ErrorSupport errors;
938 265173 : (this->*(it->second))(callId, method, message, std::move(messageObject), &errors);
939 88391 : }
940 :
941 :
942 60 : void DispatcherImpl::continueToLocation(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
943 : {
944 : // Prepare input parameters.
945 180 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
946 60 : errors->push();
947 120 : protocol::Value* locationValue = object ? object->get("location") : nullptr;
948 60 : errors->setName("location");
949 : std::unique_ptr<protocol::Debugger::Location> in_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
950 120 : protocol::Value* targetCallFramesValue = object ? object->get("targetCallFrames") : nullptr;
951 : Maybe<String> in_targetCallFrames;
952 60 : if (targetCallFramesValue) {
953 30 : errors->setName("targetCallFrames");
954 60 : in_targetCallFrames = ValueConversions<String>::fromValue(targetCallFramesValue, errors);
955 : }
956 60 : errors->pop();
957 60 : if (errors->hasErrors()) {
958 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
959 0 : return;
960 : }
961 :
962 60 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
963 240 : DispatchResponse response = m_backend->continueToLocation(std::move(in_location), std::move(in_targetCallFrames));
964 60 : if (response.status() == DispatchResponse::kFallThrough) {
965 0 : channel()->fallThrough(callId, method, message);
966 0 : return;
967 : }
968 60 : if (weak->get())
969 60 : weak->get()->sendResponse(callId, response);
970 : return;
971 : }
972 :
973 1522 : void DispatcherImpl::disable(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
974 : {
975 :
976 1522 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
977 1522 : DispatchResponse response = m_backend->disable();
978 1522 : if (response.status() == DispatchResponse::kFallThrough) {
979 0 : channel()->fallThrough(callId, method, message);
980 0 : return;
981 : }
982 1522 : if (weak->get())
983 1522 : weak->get()->sendResponse(callId, response);
984 : return;
985 : }
986 :
987 3476 : void DispatcherImpl::enable(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
988 : {
989 : // Declare output parameters.
990 : String out_debuggerId;
991 :
992 3476 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
993 3476 : DispatchResponse response = m_backend->enable(&out_debuggerId);
994 3476 : if (response.status() == DispatchResponse::kFallThrough) {
995 0 : channel()->fallThrough(callId, method, message);
996 0 : return;
997 : }
998 3476 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
999 3476 : if (response.status() == DispatchResponse::kSuccess) {
1000 13904 : result->setValue("debuggerId", ValueConversions<String>::toValue(out_debuggerId));
1001 : }
1002 3476 : if (weak->get())
1003 6952 : weak->get()->sendResponse(callId, response, std::move(result));
1004 : return;
1005 : }
1006 :
1007 11141 : void DispatcherImpl::evaluateOnCallFrame(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1008 : {
1009 : // Prepare input parameters.
1010 33423 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1011 11141 : errors->push();
1012 22282 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1013 11141 : errors->setName("callFrameId");
1014 11141 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1015 22282 : protocol::Value* expressionValue = object ? object->get("expression") : nullptr;
1016 11141 : errors->setName("expression");
1017 11141 : String in_expression = ValueConversions<String>::fromValue(expressionValue, errors);
1018 22282 : protocol::Value* objectGroupValue = object ? object->get("objectGroup") : nullptr;
1019 : Maybe<String> in_objectGroup;
1020 11141 : if (objectGroupValue) {
1021 0 : errors->setName("objectGroup");
1022 0 : in_objectGroup = ValueConversions<String>::fromValue(objectGroupValue, errors);
1023 : }
1024 22282 : protocol::Value* includeCommandLineAPIValue = object ? object->get("includeCommandLineAPI") : nullptr;
1025 : Maybe<bool> in_includeCommandLineAPI;
1026 11141 : if (includeCommandLineAPIValue) {
1027 0 : errors->setName("includeCommandLineAPI");
1028 0 : in_includeCommandLineAPI = ValueConversions<bool>::fromValue(includeCommandLineAPIValue, errors);
1029 : }
1030 22282 : protocol::Value* silentValue = object ? object->get("silent") : nullptr;
1031 : Maybe<bool> in_silent;
1032 11141 : if (silentValue) {
1033 0 : errors->setName("silent");
1034 0 : in_silent = ValueConversions<bool>::fromValue(silentValue, errors);
1035 : }
1036 22282 : protocol::Value* returnByValueValue = object ? object->get("returnByValue") : nullptr;
1037 : Maybe<bool> in_returnByValue;
1038 11141 : if (returnByValueValue) {
1039 0 : errors->setName("returnByValue");
1040 0 : in_returnByValue = ValueConversions<bool>::fromValue(returnByValueValue, errors);
1041 : }
1042 22282 : protocol::Value* generatePreviewValue = object ? object->get("generatePreview") : nullptr;
1043 : Maybe<bool> in_generatePreview;
1044 11141 : if (generatePreviewValue) {
1045 0 : errors->setName("generatePreview");
1046 0 : in_generatePreview = ValueConversions<bool>::fromValue(generatePreviewValue, errors);
1047 : }
1048 22282 : protocol::Value* throwOnSideEffectValue = object ? object->get("throwOnSideEffect") : nullptr;
1049 : Maybe<bool> in_throwOnSideEffect;
1050 11141 : if (throwOnSideEffectValue) {
1051 10487 : errors->setName("throwOnSideEffect");
1052 10487 : in_throwOnSideEffect = ValueConversions<bool>::fromValue(throwOnSideEffectValue, errors);
1053 : }
1054 22282 : protocol::Value* timeoutValue = object ? object->get("timeout") : nullptr;
1055 : Maybe<double> in_timeout;
1056 11141 : if (timeoutValue) {
1057 15 : errors->setName("timeout");
1058 15 : in_timeout = ValueConversions<double>::fromValue(timeoutValue, errors);
1059 : }
1060 11141 : errors->pop();
1061 11141 : if (errors->hasErrors()) {
1062 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1063 0 : return;
1064 : }
1065 : // Declare output parameters.
1066 11141 : std::unique_ptr<protocol::Runtime::RemoteObject> out_result;
1067 : Maybe<protocol::Runtime::ExceptionDetails> out_exceptionDetails;
1068 :
1069 11141 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1070 33423 : 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), std::move(in_timeout), &out_result, &out_exceptionDetails);
1071 11141 : if (response.status() == DispatchResponse::kFallThrough) {
1072 0 : channel()->fallThrough(callId, method, message);
1073 0 : return;
1074 : }
1075 11141 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1076 11141 : if (response.status() == DispatchResponse::kSuccess) {
1077 44476 : result->setValue("result", ValueConversions<protocol::Runtime::RemoteObject>::toValue(out_result.get()));
1078 11119 : if (out_exceptionDetails.isJust())
1079 4736 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(out_exceptionDetails.fromJust()));
1080 : }
1081 11141 : if (weak->get())
1082 22282 : weak->get()->sendResponse(callId, response, std::move(result));
1083 : return;
1084 : }
1085 :
1086 269 : void DispatcherImpl::getPossibleBreakpoints(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1087 : {
1088 : // Prepare input parameters.
1089 807 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1090 269 : errors->push();
1091 538 : protocol::Value* startValue = object ? object->get("start") : nullptr;
1092 269 : errors->setName("start");
1093 : std::unique_ptr<protocol::Debugger::Location> in_start = ValueConversions<protocol::Debugger::Location>::fromValue(startValue, errors);
1094 538 : protocol::Value* endValue = object ? object->get("end") : nullptr;
1095 : Maybe<protocol::Debugger::Location> in_end;
1096 269 : if (endValue) {
1097 106 : errors->setName("end");
1098 106 : in_end = ValueConversions<protocol::Debugger::Location>::fromValue(endValue, errors);
1099 : }
1100 538 : protocol::Value* restrictToFunctionValue = object ? object->get("restrictToFunction") : nullptr;
1101 : Maybe<bool> in_restrictToFunction;
1102 269 : if (restrictToFunctionValue) {
1103 0 : errors->setName("restrictToFunction");
1104 0 : in_restrictToFunction = ValueConversions<bool>::fromValue(restrictToFunctionValue, errors);
1105 : }
1106 269 : errors->pop();
1107 269 : if (errors->hasErrors()) {
1108 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1109 0 : return;
1110 : }
1111 : // Declare output parameters.
1112 269 : std::unique_ptr<protocol::Array<protocol::Debugger::BreakLocation>> out_locations;
1113 :
1114 269 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1115 1076 : DispatchResponse response = m_backend->getPossibleBreakpoints(std::move(in_start), std::move(in_end), std::move(in_restrictToFunction), &out_locations);
1116 269 : if (response.status() == DispatchResponse::kFallThrough) {
1117 0 : channel()->fallThrough(callId, method, message);
1118 0 : return;
1119 : }
1120 269 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1121 269 : if (response.status() == DispatchResponse::kSuccess) {
1122 1036 : result->setValue("locations", ValueConversions<protocol::Array<protocol::Debugger::BreakLocation>>::toValue(out_locations.get()));
1123 : }
1124 269 : if (weak->get())
1125 538 : weak->get()->sendResponse(callId, response, std::move(result));
1126 : return;
1127 : }
1128 :
1129 16078 : void DispatcherImpl::getScriptSource(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1130 : {
1131 : // Prepare input parameters.
1132 48234 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1133 16078 : errors->push();
1134 32156 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1135 16078 : errors->setName("scriptId");
1136 16078 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1137 16078 : errors->pop();
1138 16078 : if (errors->hasErrors()) {
1139 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1140 0 : return;
1141 : }
1142 : // Declare output parameters.
1143 : String out_scriptSource;
1144 :
1145 16078 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1146 16078 : DispatchResponse response = m_backend->getScriptSource(in_scriptId, &out_scriptSource);
1147 16078 : if (response.status() == DispatchResponse::kFallThrough) {
1148 0 : channel()->fallThrough(callId, method, message);
1149 0 : return;
1150 : }
1151 16078 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1152 16078 : if (response.status() == DispatchResponse::kSuccess) {
1153 62312 : result->setValue("scriptSource", ValueConversions<String>::toValue(out_scriptSource));
1154 : }
1155 16078 : if (weak->get())
1156 32156 : weak->get()->sendResponse(callId, response, std::move(result));
1157 : return;
1158 : }
1159 :
1160 35 : void DispatcherImpl::getStackTrace(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1161 : {
1162 : // Prepare input parameters.
1163 105 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1164 35 : errors->push();
1165 70 : protocol::Value* stackTraceIdValue = object ? object->get("stackTraceId") : nullptr;
1166 35 : errors->setName("stackTraceId");
1167 : std::unique_ptr<protocol::Runtime::StackTraceId> in_stackTraceId = ValueConversions<protocol::Runtime::StackTraceId>::fromValue(stackTraceIdValue, errors);
1168 35 : errors->pop();
1169 35 : if (errors->hasErrors()) {
1170 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1171 0 : return;
1172 : }
1173 : // Declare output parameters.
1174 35 : std::unique_ptr<protocol::Runtime::StackTrace> out_stackTrace;
1175 :
1176 35 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1177 105 : DispatchResponse response = m_backend->getStackTrace(std::move(in_stackTraceId), &out_stackTrace);
1178 35 : if (response.status() == DispatchResponse::kFallThrough) {
1179 0 : channel()->fallThrough(callId, method, message);
1180 0 : return;
1181 : }
1182 35 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1183 35 : if (response.status() == DispatchResponse::kSuccess) {
1184 140 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(out_stackTrace.get()));
1185 : }
1186 35 : if (weak->get())
1187 70 : weak->get()->sendResponse(callId, response, std::move(result));
1188 : return;
1189 : }
1190 :
1191 265 : void DispatcherImpl::pause(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1192 : {
1193 :
1194 265 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1195 265 : DispatchResponse response = m_backend->pause();
1196 265 : if (response.status() == DispatchResponse::kFallThrough) {
1197 0 : channel()->fallThrough(callId, method, message);
1198 0 : return;
1199 : }
1200 265 : if (weak->get())
1201 265 : weak->get()->sendResponse(callId, response);
1202 : return;
1203 : }
1204 :
1205 95 : void DispatcherImpl::pauseOnAsyncCall(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1206 : {
1207 : // Prepare input parameters.
1208 285 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1209 95 : errors->push();
1210 190 : protocol::Value* parentStackTraceIdValue = object ? object->get("parentStackTraceId") : nullptr;
1211 95 : errors->setName("parentStackTraceId");
1212 : std::unique_ptr<protocol::Runtime::StackTraceId> in_parentStackTraceId = ValueConversions<protocol::Runtime::StackTraceId>::fromValue(parentStackTraceIdValue, errors);
1213 95 : errors->pop();
1214 95 : if (errors->hasErrors()) {
1215 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1216 0 : return;
1217 : }
1218 :
1219 95 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1220 285 : DispatchResponse response = m_backend->pauseOnAsyncCall(std::move(in_parentStackTraceId));
1221 95 : if (response.status() == DispatchResponse::kFallThrough) {
1222 0 : channel()->fallThrough(callId, method, message);
1223 0 : return;
1224 : }
1225 95 : if (weak->get())
1226 95 : weak->get()->sendResponse(callId, response);
1227 : return;
1228 : }
1229 :
1230 788 : void DispatcherImpl::removeBreakpoint(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1231 : {
1232 : // Prepare input parameters.
1233 2364 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1234 788 : errors->push();
1235 1576 : protocol::Value* breakpointIdValue = object ? object->get("breakpointId") : nullptr;
1236 788 : errors->setName("breakpointId");
1237 788 : String in_breakpointId = ValueConversions<String>::fromValue(breakpointIdValue, errors);
1238 788 : errors->pop();
1239 788 : if (errors->hasErrors()) {
1240 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1241 0 : return;
1242 : }
1243 :
1244 788 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1245 788 : DispatchResponse response = m_backend->removeBreakpoint(in_breakpointId);
1246 788 : if (response.status() == DispatchResponse::kFallThrough) {
1247 0 : channel()->fallThrough(callId, method, message);
1248 0 : return;
1249 : }
1250 788 : if (weak->get())
1251 788 : weak->get()->sendResponse(callId, response);
1252 : return;
1253 : }
1254 :
1255 104 : void DispatcherImpl::restartFrame(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1256 : {
1257 : // Prepare input parameters.
1258 312 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1259 104 : errors->push();
1260 208 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1261 104 : errors->setName("callFrameId");
1262 104 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1263 104 : errors->pop();
1264 104 : if (errors->hasErrors()) {
1265 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1266 0 : return;
1267 : }
1268 : // Declare output parameters.
1269 104 : std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>> out_callFrames;
1270 : Maybe<protocol::Runtime::StackTrace> out_asyncStackTrace;
1271 : Maybe<protocol::Runtime::StackTraceId> out_asyncStackTraceId;
1272 :
1273 104 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1274 104 : DispatchResponse response = m_backend->restartFrame(in_callFrameId, &out_callFrames, &out_asyncStackTrace, &out_asyncStackTraceId);
1275 104 : if (response.status() == DispatchResponse::kFallThrough) {
1276 0 : channel()->fallThrough(callId, method, message);
1277 0 : return;
1278 : }
1279 104 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1280 104 : if (response.status() == DispatchResponse::kSuccess) {
1281 0 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(out_callFrames.get()));
1282 0 : if (out_asyncStackTrace.isJust())
1283 0 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(out_asyncStackTrace.fromJust()));
1284 0 : if (out_asyncStackTraceId.isJust())
1285 0 : result->setValue("asyncStackTraceId", ValueConversions<protocol::Runtime::StackTraceId>::toValue(out_asyncStackTraceId.fromJust()));
1286 : }
1287 104 : if (weak->get())
1288 208 : weak->get()->sendResponse(callId, response, std::move(result));
1289 : return;
1290 : }
1291 :
1292 2230 : void DispatcherImpl::resume(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1293 : {
1294 :
1295 2230 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1296 2230 : DispatchResponse response = m_backend->resume();
1297 2230 : if (response.status() == DispatchResponse::kFallThrough) {
1298 0 : channel()->fallThrough(callId, method, message);
1299 0 : return;
1300 : }
1301 2230 : if (weak->get())
1302 2230 : weak->get()->sendResponse(callId, response);
1303 : return;
1304 : }
1305 :
1306 0 : void DispatcherImpl::searchInContent(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1307 : {
1308 : // Prepare input parameters.
1309 0 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1310 0 : errors->push();
1311 0 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1312 0 : errors->setName("scriptId");
1313 0 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1314 0 : protocol::Value* queryValue = object ? object->get("query") : nullptr;
1315 0 : errors->setName("query");
1316 0 : String in_query = ValueConversions<String>::fromValue(queryValue, errors);
1317 0 : protocol::Value* caseSensitiveValue = object ? object->get("caseSensitive") : nullptr;
1318 : Maybe<bool> in_caseSensitive;
1319 0 : if (caseSensitiveValue) {
1320 0 : errors->setName("caseSensitive");
1321 0 : in_caseSensitive = ValueConversions<bool>::fromValue(caseSensitiveValue, errors);
1322 : }
1323 0 : protocol::Value* isRegexValue = object ? object->get("isRegex") : nullptr;
1324 : Maybe<bool> in_isRegex;
1325 0 : if (isRegexValue) {
1326 0 : errors->setName("isRegex");
1327 0 : in_isRegex = ValueConversions<bool>::fromValue(isRegexValue, errors);
1328 : }
1329 0 : errors->pop();
1330 0 : if (errors->hasErrors()) {
1331 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1332 0 : return;
1333 : }
1334 : // Declare output parameters.
1335 0 : std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>> out_result;
1336 :
1337 0 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1338 0 : DispatchResponse response = m_backend->searchInContent(in_scriptId, in_query, std::move(in_caseSensitive), std::move(in_isRegex), &out_result);
1339 0 : if (response.status() == DispatchResponse::kFallThrough) {
1340 0 : channel()->fallThrough(callId, method, message);
1341 0 : return;
1342 : }
1343 0 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1344 0 : if (response.status() == DispatchResponse::kSuccess) {
1345 0 : result->setValue("result", ValueConversions<protocol::Array<protocol::Debugger::SearchMatch>>::toValue(out_result.get()));
1346 : }
1347 0 : if (weak->get())
1348 0 : weak->get()->sendResponse(callId, response, std::move(result));
1349 : return;
1350 : }
1351 :
1352 350 : void DispatcherImpl::setAsyncCallStackDepth(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1353 : {
1354 : // Prepare input parameters.
1355 1050 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1356 350 : errors->push();
1357 700 : protocol::Value* maxDepthValue = object ? object->get("maxDepth") : nullptr;
1358 350 : errors->setName("maxDepth");
1359 350 : int in_maxDepth = ValueConversions<int>::fromValue(maxDepthValue, errors);
1360 350 : errors->pop();
1361 350 : if (errors->hasErrors()) {
1362 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1363 0 : return;
1364 : }
1365 :
1366 350 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1367 350 : DispatchResponse response = m_backend->setAsyncCallStackDepth(in_maxDepth);
1368 350 : if (response.status() == DispatchResponse::kFallThrough) {
1369 0 : channel()->fallThrough(callId, method, message);
1370 0 : return;
1371 : }
1372 350 : if (weak->get())
1373 350 : weak->get()->sendResponse(callId, response);
1374 : return;
1375 : }
1376 :
1377 105 : void DispatcherImpl::setBlackboxPatterns(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1378 : {
1379 : // Prepare input parameters.
1380 315 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1381 105 : errors->push();
1382 210 : protocol::Value* patternsValue = object ? object->get("patterns") : nullptr;
1383 105 : errors->setName("patterns");
1384 : std::unique_ptr<protocol::Array<String>> in_patterns = ValueConversions<protocol::Array<String>>::fromValue(patternsValue, errors);
1385 105 : errors->pop();
1386 105 : if (errors->hasErrors()) {
1387 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1388 0 : return;
1389 : }
1390 :
1391 105 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1392 315 : DispatchResponse response = m_backend->setBlackboxPatterns(std::move(in_patterns));
1393 105 : if (response.status() == DispatchResponse::kFallThrough) {
1394 0 : channel()->fallThrough(callId, method, message);
1395 0 : return;
1396 : }
1397 105 : if (weak->get())
1398 105 : weak->get()->sendResponse(callId, response);
1399 : return;
1400 : }
1401 :
1402 55 : void DispatcherImpl::setBlackboxedRanges(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1403 : {
1404 : // Prepare input parameters.
1405 165 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1406 55 : errors->push();
1407 110 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1408 55 : errors->setName("scriptId");
1409 55 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1410 110 : protocol::Value* positionsValue = object ? object->get("positions") : nullptr;
1411 55 : errors->setName("positions");
1412 : std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> in_positions = ValueConversions<protocol::Array<protocol::Debugger::ScriptPosition>>::fromValue(positionsValue, errors);
1413 55 : errors->pop();
1414 55 : if (errors->hasErrors()) {
1415 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1416 0 : return;
1417 : }
1418 :
1419 55 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1420 165 : DispatchResponse response = m_backend->setBlackboxedRanges(in_scriptId, std::move(in_positions));
1421 55 : if (response.status() == DispatchResponse::kFallThrough) {
1422 0 : channel()->fallThrough(callId, method, message);
1423 0 : return;
1424 : }
1425 55 : if (weak->get())
1426 55 : weak->get()->sendResponse(callId, response);
1427 : return;
1428 : }
1429 :
1430 1892 : void DispatcherImpl::setBreakpoint(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1431 : {
1432 : // Prepare input parameters.
1433 5676 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1434 1892 : errors->push();
1435 3784 : protocol::Value* locationValue = object ? object->get("location") : nullptr;
1436 1892 : errors->setName("location");
1437 : std::unique_ptr<protocol::Debugger::Location> in_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
1438 3784 : protocol::Value* conditionValue = object ? object->get("condition") : nullptr;
1439 : Maybe<String> in_condition;
1440 1892 : if (conditionValue) {
1441 180 : errors->setName("condition");
1442 360 : in_condition = ValueConversions<String>::fromValue(conditionValue, errors);
1443 : }
1444 1892 : errors->pop();
1445 1892 : if (errors->hasErrors()) {
1446 10 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1447 5 : return;
1448 : }
1449 : // Declare output parameters.
1450 : String out_breakpointId;
1451 1887 : std::unique_ptr<protocol::Debugger::Location> out_actualLocation;
1452 :
1453 1887 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1454 7548 : DispatchResponse response = m_backend->setBreakpoint(std::move(in_location), std::move(in_condition), &out_breakpointId, &out_actualLocation);
1455 1887 : if (response.status() == DispatchResponse::kFallThrough) {
1456 0 : channel()->fallThrough(callId, method, message);
1457 0 : return;
1458 : }
1459 1887 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1460 1887 : if (response.status() == DispatchResponse::kSuccess) {
1461 6972 : result->setValue("breakpointId", ValueConversions<String>::toValue(out_breakpointId));
1462 6972 : result->setValue("actualLocation", ValueConversions<protocol::Debugger::Location>::toValue(out_actualLocation.get()));
1463 : }
1464 1887 : if (weak->get())
1465 3774 : weak->get()->sendResponse(callId, response, std::move(result));
1466 : return;
1467 : }
1468 :
1469 230 : void DispatcherImpl::setBreakpointByUrl(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1470 : {
1471 : // Prepare input parameters.
1472 690 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1473 230 : errors->push();
1474 460 : protocol::Value* lineNumberValue = object ? object->get("lineNumber") : nullptr;
1475 230 : errors->setName("lineNumber");
1476 230 : int in_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
1477 460 : protocol::Value* urlValue = object ? object->get("url") : nullptr;
1478 : Maybe<String> in_url;
1479 230 : if (urlValue) {
1480 215 : errors->setName("url");
1481 430 : in_url = ValueConversions<String>::fromValue(urlValue, errors);
1482 : }
1483 460 : protocol::Value* urlRegexValue = object ? object->get("urlRegex") : nullptr;
1484 : Maybe<String> in_urlRegex;
1485 230 : if (urlRegexValue) {
1486 5 : errors->setName("urlRegex");
1487 10 : in_urlRegex = ValueConversions<String>::fromValue(urlRegexValue, errors);
1488 : }
1489 460 : protocol::Value* scriptHashValue = object ? object->get("scriptHash") : nullptr;
1490 : Maybe<String> in_scriptHash;
1491 230 : if (scriptHashValue) {
1492 10 : errors->setName("scriptHash");
1493 20 : in_scriptHash = ValueConversions<String>::fromValue(scriptHashValue, errors);
1494 : }
1495 460 : protocol::Value* columnNumberValue = object ? object->get("columnNumber") : nullptr;
1496 : Maybe<int> in_columnNumber;
1497 230 : if (columnNumberValue) {
1498 85 : errors->setName("columnNumber");
1499 85 : in_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
1500 : }
1501 460 : protocol::Value* conditionValue = object ? object->get("condition") : nullptr;
1502 : Maybe<String> in_condition;
1503 230 : if (conditionValue) {
1504 10 : errors->setName("condition");
1505 20 : in_condition = ValueConversions<String>::fromValue(conditionValue, errors);
1506 : }
1507 230 : errors->pop();
1508 230 : if (errors->hasErrors()) {
1509 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1510 0 : return;
1511 : }
1512 : // Declare output parameters.
1513 : String out_breakpointId;
1514 230 : std::unique_ptr<protocol::Array<protocol::Debugger::Location>> out_locations;
1515 :
1516 230 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1517 1380 : 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);
1518 230 : if (response.status() == DispatchResponse::kFallThrough) {
1519 0 : channel()->fallThrough(callId, method, message);
1520 0 : return;
1521 : }
1522 230 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1523 230 : if (response.status() == DispatchResponse::kSuccess) {
1524 920 : result->setValue("breakpointId", ValueConversions<String>::toValue(out_breakpointId));
1525 920 : result->setValue("locations", ValueConversions<protocol::Array<protocol::Debugger::Location>>::toValue(out_locations.get()));
1526 : }
1527 230 : if (weak->get())
1528 460 : weak->get()->sendResponse(callId, response, std::move(result));
1529 : return;
1530 : }
1531 :
1532 20 : void DispatcherImpl::setBreakpointOnFunctionCall(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1533 : {
1534 : // Prepare input parameters.
1535 60 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1536 20 : errors->push();
1537 40 : protocol::Value* objectIdValue = object ? object->get("objectId") : nullptr;
1538 20 : errors->setName("objectId");
1539 20 : String in_objectId = ValueConversions<String>::fromValue(objectIdValue, errors);
1540 40 : protocol::Value* conditionValue = object ? object->get("condition") : nullptr;
1541 : Maybe<String> in_condition;
1542 20 : if (conditionValue) {
1543 5 : errors->setName("condition");
1544 10 : in_condition = ValueConversions<String>::fromValue(conditionValue, errors);
1545 : }
1546 20 : errors->pop();
1547 20 : if (errors->hasErrors()) {
1548 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1549 0 : return;
1550 : }
1551 : // Declare output parameters.
1552 : String out_breakpointId;
1553 :
1554 20 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1555 60 : DispatchResponse response = m_backend->setBreakpointOnFunctionCall(in_objectId, std::move(in_condition), &out_breakpointId);
1556 20 : if (response.status() == DispatchResponse::kFallThrough) {
1557 0 : channel()->fallThrough(callId, method, message);
1558 0 : return;
1559 : }
1560 20 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1561 20 : if (response.status() == DispatchResponse::kSuccess) {
1562 60 : result->setValue("breakpointId", ValueConversions<String>::toValue(out_breakpointId));
1563 : }
1564 20 : if (weak->get())
1565 40 : weak->get()->sendResponse(callId, response, std::move(result));
1566 : return;
1567 : }
1568 :
1569 138 : void DispatcherImpl::setBreakpointsActive(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1570 : {
1571 : // Prepare input parameters.
1572 414 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1573 138 : errors->push();
1574 276 : protocol::Value* activeValue = object ? object->get("active") : nullptr;
1575 138 : errors->setName("active");
1576 138 : bool in_active = ValueConversions<bool>::fromValue(activeValue, errors);
1577 138 : errors->pop();
1578 138 : if (errors->hasErrors()) {
1579 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1580 0 : return;
1581 : }
1582 :
1583 138 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1584 138 : DispatchResponse response = m_backend->setBreakpointsActive(in_active);
1585 138 : if (response.status() == DispatchResponse::kFallThrough) {
1586 0 : channel()->fallThrough(callId, method, message);
1587 0 : return;
1588 : }
1589 138 : if (weak->get())
1590 138 : weak->get()->sendResponse(callId, response);
1591 : return;
1592 : }
1593 :
1594 4745 : void DispatcherImpl::setPauseOnExceptions(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1595 : {
1596 : // Prepare input parameters.
1597 14235 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1598 4745 : errors->push();
1599 9490 : protocol::Value* stateValue = object ? object->get("state") : nullptr;
1600 4745 : errors->setName("state");
1601 4745 : String in_state = ValueConversions<String>::fromValue(stateValue, errors);
1602 4745 : errors->pop();
1603 4745 : if (errors->hasErrors()) {
1604 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1605 0 : return;
1606 : }
1607 :
1608 4745 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1609 4745 : DispatchResponse response = m_backend->setPauseOnExceptions(in_state);
1610 4745 : if (response.status() == DispatchResponse::kFallThrough) {
1611 0 : channel()->fallThrough(callId, method, message);
1612 0 : return;
1613 : }
1614 4745 : if (weak->get())
1615 4745 : weak->get()->sendResponse(callId, response);
1616 : return;
1617 : }
1618 :
1619 15 : void DispatcherImpl::setReturnValue(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1620 : {
1621 : // Prepare input parameters.
1622 45 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1623 15 : errors->push();
1624 30 : protocol::Value* newValueValue = object ? object->get("newValue") : nullptr;
1625 15 : errors->setName("newValue");
1626 : std::unique_ptr<protocol::Runtime::CallArgument> in_newValue = ValueConversions<protocol::Runtime::CallArgument>::fromValue(newValueValue, errors);
1627 15 : errors->pop();
1628 15 : if (errors->hasErrors()) {
1629 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1630 0 : return;
1631 : }
1632 :
1633 15 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1634 45 : DispatchResponse response = m_backend->setReturnValue(std::move(in_newValue));
1635 15 : if (response.status() == DispatchResponse::kFallThrough) {
1636 0 : channel()->fallThrough(callId, method, message);
1637 0 : return;
1638 : }
1639 15 : if (weak->get())
1640 15 : weak->get()->sendResponse(callId, response);
1641 : return;
1642 : }
1643 :
1644 64 : void DispatcherImpl::setScriptSource(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1645 : {
1646 : // Prepare input parameters.
1647 192 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1648 64 : errors->push();
1649 128 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
1650 64 : errors->setName("scriptId");
1651 64 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
1652 128 : protocol::Value* scriptSourceValue = object ? object->get("scriptSource") : nullptr;
1653 64 : errors->setName("scriptSource");
1654 64 : String in_scriptSource = ValueConversions<String>::fromValue(scriptSourceValue, errors);
1655 128 : protocol::Value* dryRunValue = object ? object->get("dryRun") : nullptr;
1656 : Maybe<bool> in_dryRun;
1657 64 : if (dryRunValue) {
1658 0 : errors->setName("dryRun");
1659 0 : in_dryRun = ValueConversions<bool>::fromValue(dryRunValue, errors);
1660 : }
1661 64 : errors->pop();
1662 64 : if (errors->hasErrors()) {
1663 18 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1664 9 : return;
1665 : }
1666 : // Declare output parameters.
1667 : Maybe<protocol::Array<protocol::Debugger::CallFrame>> out_callFrames;
1668 : Maybe<bool> out_stackChanged;
1669 : Maybe<protocol::Runtime::StackTrace> out_asyncStackTrace;
1670 : Maybe<protocol::Runtime::StackTraceId> out_asyncStackTraceId;
1671 : Maybe<protocol::Runtime::ExceptionDetails> out_exceptionDetails;
1672 :
1673 55 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1674 110 : DispatchResponse response = m_backend->setScriptSource(in_scriptId, in_scriptSource, std::move(in_dryRun), &out_callFrames, &out_stackChanged, &out_asyncStackTrace, &out_asyncStackTraceId, &out_exceptionDetails);
1675 55 : if (response.status() == DispatchResponse::kFallThrough) {
1676 0 : channel()->fallThrough(callId, method, message);
1677 0 : return;
1678 : }
1679 55 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1680 55 : if (response.status() == DispatchResponse::kSuccess) {
1681 50 : if (out_callFrames.isJust())
1682 160 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Debugger::CallFrame>>::toValue(out_callFrames.fromJust()));
1683 50 : if (out_stackChanged.isJust())
1684 200 : result->setValue("stackChanged", ValueConversions<bool>::toValue(out_stackChanged.fromJust()));
1685 50 : if (out_asyncStackTrace.isJust())
1686 0 : result->setValue("asyncStackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(out_asyncStackTrace.fromJust()));
1687 50 : if (out_asyncStackTraceId.isJust())
1688 0 : result->setValue("asyncStackTraceId", ValueConversions<protocol::Runtime::StackTraceId>::toValue(out_asyncStackTraceId.fromJust()));
1689 50 : if (out_exceptionDetails.isJust())
1690 40 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(out_exceptionDetails.fromJust()));
1691 : }
1692 55 : if (weak->get())
1693 110 : weak->get()->sendResponse(callId, response, std::move(result));
1694 : return;
1695 : }
1696 :
1697 35 : void DispatcherImpl::setSkipAllPauses(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1698 : {
1699 : // Prepare input parameters.
1700 105 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1701 35 : errors->push();
1702 70 : protocol::Value* skipValue = object ? object->get("skip") : nullptr;
1703 35 : errors->setName("skip");
1704 35 : bool in_skip = ValueConversions<bool>::fromValue(skipValue, errors);
1705 35 : errors->pop();
1706 35 : if (errors->hasErrors()) {
1707 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1708 0 : return;
1709 : }
1710 :
1711 35 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1712 35 : DispatchResponse response = m_backend->setSkipAllPauses(in_skip);
1713 35 : if (response.status() == DispatchResponse::kFallThrough) {
1714 0 : channel()->fallThrough(callId, method, message);
1715 0 : return;
1716 : }
1717 35 : if (weak->get())
1718 35 : weak->get()->sendResponse(callId, response);
1719 : return;
1720 : }
1721 :
1722 221 : void DispatcherImpl::setVariableValue(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1723 : {
1724 : // Prepare input parameters.
1725 663 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1726 221 : errors->push();
1727 442 : protocol::Value* scopeNumberValue = object ? object->get("scopeNumber") : nullptr;
1728 221 : errors->setName("scopeNumber");
1729 221 : int in_scopeNumber = ValueConversions<int>::fromValue(scopeNumberValue, errors);
1730 442 : protocol::Value* variableNameValue = object ? object->get("variableName") : nullptr;
1731 221 : errors->setName("variableName");
1732 221 : String in_variableName = ValueConversions<String>::fromValue(variableNameValue, errors);
1733 442 : protocol::Value* newValueValue = object ? object->get("newValue") : nullptr;
1734 221 : errors->setName("newValue");
1735 : std::unique_ptr<protocol::Runtime::CallArgument> in_newValue = ValueConversions<protocol::Runtime::CallArgument>::fromValue(newValueValue, errors);
1736 442 : protocol::Value* callFrameIdValue = object ? object->get("callFrameId") : nullptr;
1737 221 : errors->setName("callFrameId");
1738 221 : String in_callFrameId = ValueConversions<String>::fromValue(callFrameIdValue, errors);
1739 221 : errors->pop();
1740 221 : if (errors->hasErrors()) {
1741 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1742 0 : return;
1743 : }
1744 :
1745 221 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1746 663 : DispatchResponse response = m_backend->setVariableValue(in_scopeNumber, in_variableName, std::move(in_newValue), in_callFrameId);
1747 221 : if (response.status() == DispatchResponse::kFallThrough) {
1748 0 : channel()->fallThrough(callId, method, message);
1749 0 : return;
1750 : }
1751 221 : if (weak->get())
1752 221 : weak->get()->sendResponse(callId, response);
1753 : return;
1754 : }
1755 :
1756 36294 : void DispatcherImpl::stepInto(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1757 : {
1758 : // Prepare input parameters.
1759 108882 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1760 36294 : errors->push();
1761 39712 : protocol::Value* breakOnAsyncCallValue = object ? object->get("breakOnAsyncCall") : nullptr;
1762 : Maybe<bool> in_breakOnAsyncCall;
1763 36294 : if (breakOnAsyncCallValue) {
1764 120 : errors->setName("breakOnAsyncCall");
1765 120 : in_breakOnAsyncCall = ValueConversions<bool>::fromValue(breakOnAsyncCallValue, errors);
1766 : }
1767 36294 : errors->pop();
1768 36294 : if (errors->hasErrors()) {
1769 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1770 0 : return;
1771 : }
1772 :
1773 36294 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1774 72588 : DispatchResponse response = m_backend->stepInto(std::move(in_breakOnAsyncCall));
1775 36294 : if (response.status() == DispatchResponse::kFallThrough) {
1776 0 : channel()->fallThrough(callId, method, message);
1777 0 : return;
1778 : }
1779 36294 : if (weak->get())
1780 36294 : weak->get()->sendResponse(callId, response);
1781 : return;
1782 : }
1783 :
1784 533 : void DispatcherImpl::stepOut(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1785 : {
1786 :
1787 533 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1788 533 : DispatchResponse response = m_backend->stepOut();
1789 533 : if (response.status() == DispatchResponse::kFallThrough) {
1790 0 : channel()->fallThrough(callId, method, message);
1791 0 : return;
1792 : }
1793 533 : if (weak->get())
1794 533 : weak->get()->sendResponse(callId, response);
1795 : return;
1796 : }
1797 :
1798 7631 : void DispatcherImpl::stepOver(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1799 : {
1800 :
1801 7631 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1802 7631 : DispatchResponse response = m_backend->stepOver();
1803 7631 : if (response.status() == DispatchResponse::kFallThrough) {
1804 0 : channel()->fallThrough(callId, method, message);
1805 0 : return;
1806 : }
1807 7631 : if (weak->get())
1808 7631 : weak->get()->sendResponse(callId, response);
1809 : return;
1810 : }
1811 :
1812 : // static
1813 3832 : void Dispatcher::wire(UberDispatcher* uber, Backend* backend)
1814 : {
1815 3832 : std::unique_ptr<DispatcherImpl> dispatcher(new DispatcherImpl(uber->channel(), backend));
1816 3832 : uber->setupRedirects(dispatcher->redirects());
1817 11496 : uber->registerBackend("Debugger", std::move(dispatcher));
1818 3832 : }
1819 :
1820 : } // Debugger
1821 : } // namespace v8_inspector
1822 : } // namespace protocol
|