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/Runtime.h"
8 :
9 : #include "src/inspector/protocol/Protocol.h"
10 :
11 : namespace v8_inspector {
12 : namespace protocol {
13 : namespace Runtime {
14 :
15 : // ------------- Enum values from types.
16 :
17 : const char Metainfo::domainName[] = "Runtime";
18 : const char Metainfo::commandPrefix[] = "Runtime.";
19 : const char Metainfo::version[] = "1.3";
20 :
21 : const char* RemoteObject::TypeEnum::Object = "object";
22 : const char* RemoteObject::TypeEnum::Function = "function";
23 : const char* RemoteObject::TypeEnum::Undefined = "undefined";
24 : const char* RemoteObject::TypeEnum::String = "string";
25 : const char* RemoteObject::TypeEnum::Number = "number";
26 : const char* RemoteObject::TypeEnum::Boolean = "boolean";
27 : const char* RemoteObject::TypeEnum::Symbol = "symbol";
28 : const char* RemoteObject::TypeEnum::Bigint = "bigint";
29 :
30 : const char* RemoteObject::SubtypeEnum::Array = "array";
31 : const char* RemoteObject::SubtypeEnum::Null = "null";
32 : const char* RemoteObject::SubtypeEnum::Node = "node";
33 : const char* RemoteObject::SubtypeEnum::Regexp = "regexp";
34 : const char* RemoteObject::SubtypeEnum::Date = "date";
35 : const char* RemoteObject::SubtypeEnum::Map = "map";
36 : const char* RemoteObject::SubtypeEnum::Set = "set";
37 : const char* RemoteObject::SubtypeEnum::Weakmap = "weakmap";
38 : const char* RemoteObject::SubtypeEnum::Weakset = "weakset";
39 : const char* RemoteObject::SubtypeEnum::Iterator = "iterator";
40 : const char* RemoteObject::SubtypeEnum::Generator = "generator";
41 : const char* RemoteObject::SubtypeEnum::Error = "error";
42 : const char* RemoteObject::SubtypeEnum::Proxy = "proxy";
43 : const char* RemoteObject::SubtypeEnum::Promise = "promise";
44 : const char* RemoteObject::SubtypeEnum::Typedarray = "typedarray";
45 : const char* RemoteObject::SubtypeEnum::Arraybuffer = "arraybuffer";
46 : const char* RemoteObject::SubtypeEnum::Dataview = "dataview";
47 :
48 90 : std::unique_ptr<RemoteObject> RemoteObject::fromValue(protocol::Value* value, ErrorSupport* errors)
49 : {
50 90 : if (!value || value->type() != protocol::Value::TypeObject) {
51 0 : errors->addError("object expected");
52 : return nullptr;
53 : }
54 :
55 45 : std::unique_ptr<RemoteObject> result(new RemoteObject());
56 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
57 45 : errors->push();
58 90 : protocol::Value* typeValue = object->get("type");
59 45 : errors->setName("type");
60 90 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
61 90 : protocol::Value* subtypeValue = object->get("subtype");
62 45 : if (subtypeValue) {
63 15 : errors->setName("subtype");
64 30 : result->m_subtype = ValueConversions<String>::fromValue(subtypeValue, errors);
65 : }
66 90 : protocol::Value* classNameValue = object->get("className");
67 45 : if (classNameValue) {
68 15 : errors->setName("className");
69 30 : result->m_className = ValueConversions<String>::fromValue(classNameValue, errors);
70 : }
71 90 : protocol::Value* valueValue = object->get("value");
72 45 : if (valueValue) {
73 25 : errors->setName("value");
74 50 : result->m_value = ValueConversions<protocol::Value>::fromValue(valueValue, errors);
75 : }
76 90 : protocol::Value* unserializableValueValue = object->get("unserializableValue");
77 45 : if (unserializableValueValue) {
78 0 : errors->setName("unserializableValue");
79 0 : result->m_unserializableValue = ValueConversions<String>::fromValue(unserializableValueValue, errors);
80 : }
81 90 : protocol::Value* descriptionValue = object->get("description");
82 45 : if (descriptionValue) {
83 25 : errors->setName("description");
84 50 : result->m_description = ValueConversions<String>::fromValue(descriptionValue, errors);
85 : }
86 90 : protocol::Value* objectIdValue = object->get("objectId");
87 45 : if (objectIdValue) {
88 15 : errors->setName("objectId");
89 30 : result->m_objectId = ValueConversions<String>::fromValue(objectIdValue, errors);
90 : }
91 90 : protocol::Value* previewValue = object->get("preview");
92 45 : if (previewValue) {
93 0 : errors->setName("preview");
94 0 : result->m_preview = ValueConversions<protocol::Runtime::ObjectPreview>::fromValue(previewValue, errors);
95 : }
96 90 : protocol::Value* customPreviewValue = object->get("customPreview");
97 45 : if (customPreviewValue) {
98 0 : errors->setName("customPreview");
99 0 : result->m_customPreview = ValueConversions<protocol::Runtime::CustomPreview>::fromValue(customPreviewValue, errors);
100 : }
101 45 : errors->pop();
102 45 : if (errors->hasErrors())
103 : return nullptr;
104 : return result;
105 : }
106 :
107 3081556 : std::unique_ptr<protocol::DictionaryValue> RemoteObject::toValue() const
108 : {
109 3081556 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
110 15407780 : result->setValue("type", ValueConversions<String>::toValue(m_type));
111 3081556 : if (m_subtype.isJust())
112 299655 : result->setValue("subtype", ValueConversions<String>::toValue(m_subtype.fromJust()));
113 3081556 : if (m_className.isJust())
114 13647260 : result->setValue("className", ValueConversions<String>::toValue(m_className.fromJust()));
115 3081556 : if (m_value.isJust())
116 911616 : result->setValue("value", ValueConversions<protocol::Value>::toValue(m_value.fromJust()));
117 3081556 : if (m_unserializableValue.isJust())
118 179885 : result->setValue("unserializableValue", ValueConversions<String>::toValue(m_unserializableValue.fromJust()));
119 3081556 : if (m_description.isJust())
120 14641740 : result->setValue("description", ValueConversions<String>::toValue(m_description.fromJust()));
121 3081556 : if (m_objectId.isJust())
122 13739400 : result->setValue("objectId", ValueConversions<String>::toValue(m_objectId.fromJust()));
123 3081556 : if (m_preview.isJust())
124 2900 : result->setValue("preview", ValueConversions<protocol::Runtime::ObjectPreview>::toValue(m_preview.fromJust()));
125 3081556 : if (m_customPreview.isJust())
126 240 : result->setValue("customPreview", ValueConversions<protocol::Runtime::CustomPreview>::toValue(m_customPreview.fromJust()));
127 3081556 : return result;
128 : }
129 :
130 45 : std::unique_ptr<RemoteObject> RemoteObject::clone() const
131 : {
132 45 : ErrorSupport errors;
133 135 : return fromValue(toValue().get(), &errors);
134 : }
135 :
136 0 : std::unique_ptr<StringBuffer> RemoteObject::toJSONString() const
137 : {
138 0 : String json = toValue()->serializeToJSON();
139 0 : return StringBufferImpl::adopt(json);
140 : }
141 :
142 0 : void RemoteObject::writeBinary(std::vector<uint8_t>* out) const
143 : {
144 0 : toValue()->writeBinary(out);
145 0 : }
146 :
147 : // static
148 0 : std::unique_ptr<API::RemoteObject> API::RemoteObject::fromJSONString(const StringView& json)
149 : {
150 0 : ErrorSupport errors;
151 0 : std::unique_ptr<Value> value = StringUtil::parseJSON(json);
152 0 : if (!value)
153 : return nullptr;
154 0 : return protocol::Runtime::RemoteObject::fromValue(value.get(), &errors);
155 : }
156 :
157 : // static
158 0 : std::unique_ptr<API::RemoteObject> API::RemoteObject::fromBinary(const uint8_t* data, size_t length)
159 : {
160 0 : ErrorSupport errors;
161 0 : std::unique_ptr<Value> value = Value::parseBinary(data, length);
162 0 : if (!value)
163 : return nullptr;
164 0 : return protocol::Runtime::RemoteObject::fromValue(value.get(), &errors);
165 : }
166 :
167 :
168 0 : std::unique_ptr<CustomPreview> CustomPreview::fromValue(protocol::Value* value, ErrorSupport* errors)
169 : {
170 0 : if (!value || value->type() != protocol::Value::TypeObject) {
171 0 : errors->addError("object expected");
172 : return nullptr;
173 : }
174 :
175 0 : std::unique_ptr<CustomPreview> result(new CustomPreview());
176 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
177 0 : errors->push();
178 0 : protocol::Value* headerValue = object->get("header");
179 0 : errors->setName("header");
180 0 : result->m_header = ValueConversions<String>::fromValue(headerValue, errors);
181 0 : protocol::Value* bodyGetterIdValue = object->get("bodyGetterId");
182 0 : if (bodyGetterIdValue) {
183 0 : errors->setName("bodyGetterId");
184 0 : result->m_bodyGetterId = ValueConversions<String>::fromValue(bodyGetterIdValue, errors);
185 : }
186 0 : errors->pop();
187 0 : if (errors->hasErrors())
188 : return nullptr;
189 : return result;
190 : }
191 :
192 60 : std::unique_ptr<protocol::DictionaryValue> CustomPreview::toValue() const
193 : {
194 60 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
195 300 : result->setValue("header", ValueConversions<String>::toValue(m_header));
196 60 : if (m_bodyGetterId.isJust())
197 250 : result->setValue("bodyGetterId", ValueConversions<String>::toValue(m_bodyGetterId.fromJust()));
198 60 : return result;
199 : }
200 :
201 0 : std::unique_ptr<CustomPreview> CustomPreview::clone() const
202 : {
203 0 : ErrorSupport errors;
204 0 : return fromValue(toValue().get(), &errors);
205 : }
206 :
207 : const char* ObjectPreview::TypeEnum::Object = "object";
208 : const char* ObjectPreview::TypeEnum::Function = "function";
209 : const char* ObjectPreview::TypeEnum::Undefined = "undefined";
210 : const char* ObjectPreview::TypeEnum::String = "string";
211 : const char* ObjectPreview::TypeEnum::Number = "number";
212 : const char* ObjectPreview::TypeEnum::Boolean = "boolean";
213 : const char* ObjectPreview::TypeEnum::Symbol = "symbol";
214 : const char* ObjectPreview::TypeEnum::Bigint = "bigint";
215 :
216 : const char* ObjectPreview::SubtypeEnum::Array = "array";
217 : const char* ObjectPreview::SubtypeEnum::Null = "null";
218 : const char* ObjectPreview::SubtypeEnum::Node = "node";
219 : const char* ObjectPreview::SubtypeEnum::Regexp = "regexp";
220 : const char* ObjectPreview::SubtypeEnum::Date = "date";
221 : const char* ObjectPreview::SubtypeEnum::Map = "map";
222 : const char* ObjectPreview::SubtypeEnum::Set = "set";
223 : const char* ObjectPreview::SubtypeEnum::Weakmap = "weakmap";
224 : const char* ObjectPreview::SubtypeEnum::Weakset = "weakset";
225 : const char* ObjectPreview::SubtypeEnum::Iterator = "iterator";
226 : const char* ObjectPreview::SubtypeEnum::Generator = "generator";
227 : const char* ObjectPreview::SubtypeEnum::Error = "error";
228 :
229 0 : std::unique_ptr<ObjectPreview> ObjectPreview::fromValue(protocol::Value* value, ErrorSupport* errors)
230 : {
231 0 : if (!value || value->type() != protocol::Value::TypeObject) {
232 0 : errors->addError("object expected");
233 : return nullptr;
234 : }
235 :
236 0 : std::unique_ptr<ObjectPreview> result(new ObjectPreview());
237 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
238 0 : errors->push();
239 0 : protocol::Value* typeValue = object->get("type");
240 0 : errors->setName("type");
241 0 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
242 0 : protocol::Value* subtypeValue = object->get("subtype");
243 0 : if (subtypeValue) {
244 0 : errors->setName("subtype");
245 0 : result->m_subtype = ValueConversions<String>::fromValue(subtypeValue, errors);
246 : }
247 0 : protocol::Value* descriptionValue = object->get("description");
248 0 : if (descriptionValue) {
249 0 : errors->setName("description");
250 0 : result->m_description = ValueConversions<String>::fromValue(descriptionValue, errors);
251 : }
252 0 : protocol::Value* overflowValue = object->get("overflow");
253 0 : errors->setName("overflow");
254 0 : result->m_overflow = ValueConversions<bool>::fromValue(overflowValue, errors);
255 0 : protocol::Value* propertiesValue = object->get("properties");
256 0 : errors->setName("properties");
257 0 : result->m_properties = ValueConversions<protocol::Array<protocol::Runtime::PropertyPreview>>::fromValue(propertiesValue, errors);
258 0 : protocol::Value* entriesValue = object->get("entries");
259 0 : if (entriesValue) {
260 0 : errors->setName("entries");
261 0 : result->m_entries = ValueConversions<protocol::Array<protocol::Runtime::EntryPreview>>::fromValue(entriesValue, errors);
262 : }
263 0 : errors->pop();
264 0 : if (errors->hasErrors())
265 : return nullptr;
266 : return result;
267 : }
268 :
269 11040 : std::unique_ptr<protocol::DictionaryValue> ObjectPreview::toValue() const
270 : {
271 11040 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
272 55200 : result->setValue("type", ValueConversions<String>::toValue(m_type));
273 11040 : if (m_subtype.isJust())
274 52500 : result->setValue("subtype", ValueConversions<String>::toValue(m_subtype.fromJust()));
275 11040 : if (m_description.isJust())
276 55200 : result->setValue("description", ValueConversions<String>::toValue(m_description.fromJust()));
277 55200 : result->setValue("overflow", ValueConversions<bool>::toValue(m_overflow));
278 44160 : result->setValue("properties", ValueConversions<protocol::Array<protocol::Runtime::PropertyPreview>>::toValue(m_properties.get()));
279 11040 : if (m_entries.isJust())
280 400 : result->setValue("entries", ValueConversions<protocol::Array<protocol::Runtime::EntryPreview>>::toValue(m_entries.fromJust()));
281 11040 : return result;
282 : }
283 :
284 0 : std::unique_ptr<ObjectPreview> ObjectPreview::clone() const
285 : {
286 0 : ErrorSupport errors;
287 0 : return fromValue(toValue().get(), &errors);
288 : }
289 :
290 : const char* PropertyPreview::TypeEnum::Object = "object";
291 : const char* PropertyPreview::TypeEnum::Function = "function";
292 : const char* PropertyPreview::TypeEnum::Undefined = "undefined";
293 : const char* PropertyPreview::TypeEnum::String = "string";
294 : const char* PropertyPreview::TypeEnum::Number = "number";
295 : const char* PropertyPreview::TypeEnum::Boolean = "boolean";
296 : const char* PropertyPreview::TypeEnum::Symbol = "symbol";
297 : const char* PropertyPreview::TypeEnum::Accessor = "accessor";
298 : const char* PropertyPreview::TypeEnum::Bigint = "bigint";
299 :
300 : const char* PropertyPreview::SubtypeEnum::Array = "array";
301 : const char* PropertyPreview::SubtypeEnum::Null = "null";
302 : const char* PropertyPreview::SubtypeEnum::Node = "node";
303 : const char* PropertyPreview::SubtypeEnum::Regexp = "regexp";
304 : const char* PropertyPreview::SubtypeEnum::Date = "date";
305 : const char* PropertyPreview::SubtypeEnum::Map = "map";
306 : const char* PropertyPreview::SubtypeEnum::Set = "set";
307 : const char* PropertyPreview::SubtypeEnum::Weakmap = "weakmap";
308 : const char* PropertyPreview::SubtypeEnum::Weakset = "weakset";
309 : const char* PropertyPreview::SubtypeEnum::Iterator = "iterator";
310 : const char* PropertyPreview::SubtypeEnum::Generator = "generator";
311 : const char* PropertyPreview::SubtypeEnum::Error = "error";
312 :
313 50 : std::unique_ptr<PropertyPreview> PropertyPreview::fromValue(protocol::Value* value, ErrorSupport* errors)
314 : {
315 50 : if (!value || value->type() != protocol::Value::TypeObject) {
316 0 : errors->addError("object expected");
317 : return nullptr;
318 : }
319 :
320 25 : std::unique_ptr<PropertyPreview> result(new PropertyPreview());
321 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
322 25 : errors->push();
323 50 : protocol::Value* nameValue = object->get("name");
324 25 : errors->setName("name");
325 50 : result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
326 50 : protocol::Value* typeValue = object->get("type");
327 25 : errors->setName("type");
328 50 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
329 50 : protocol::Value* valueValue = object->get("value");
330 25 : if (valueValue) {
331 25 : errors->setName("value");
332 50 : result->m_value = ValueConversions<String>::fromValue(valueValue, errors);
333 : }
334 50 : protocol::Value* valuePreviewValue = object->get("valuePreview");
335 25 : if (valuePreviewValue) {
336 0 : errors->setName("valuePreview");
337 0 : result->m_valuePreview = ValueConversions<protocol::Runtime::ObjectPreview>::fromValue(valuePreviewValue, errors);
338 : }
339 50 : protocol::Value* subtypeValue = object->get("subtype");
340 25 : if (subtypeValue) {
341 0 : errors->setName("subtype");
342 0 : result->m_subtype = ValueConversions<String>::fromValue(subtypeValue, errors);
343 : }
344 25 : errors->pop();
345 25 : if (errors->hasErrors())
346 : return nullptr;
347 : return result;
348 : }
349 :
350 32105 : std::unique_ptr<protocol::DictionaryValue> PropertyPreview::toValue() const
351 : {
352 32105 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
353 160525 : result->setValue("name", ValueConversions<String>::toValue(m_name));
354 160525 : result->setValue("type", ValueConversions<String>::toValue(m_type));
355 32105 : if (m_value.isJust())
356 160350 : result->setValue("value", ValueConversions<String>::toValue(m_value.fromJust()));
357 32105 : if (m_valuePreview.isJust())
358 40300 : result->setValue("valuePreview", ValueConversions<protocol::Runtime::ObjectPreview>::toValue(m_valuePreview.fromJust()));
359 32105 : if (m_subtype.isJust())
360 50925 : result->setValue("subtype", ValueConversions<String>::toValue(m_subtype.fromJust()));
361 32105 : return result;
362 : }
363 :
364 25 : std::unique_ptr<PropertyPreview> PropertyPreview::clone() const
365 : {
366 25 : ErrorSupport errors;
367 75 : return fromValue(toValue().get(), &errors);
368 : }
369 :
370 0 : std::unique_ptr<EntryPreview> EntryPreview::fromValue(protocol::Value* value, ErrorSupport* errors)
371 : {
372 0 : if (!value || value->type() != protocol::Value::TypeObject) {
373 0 : errors->addError("object expected");
374 : return nullptr;
375 : }
376 :
377 0 : std::unique_ptr<EntryPreview> result(new EntryPreview());
378 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
379 0 : errors->push();
380 0 : protocol::Value* keyValue = object->get("key");
381 0 : if (keyValue) {
382 0 : errors->setName("key");
383 0 : result->m_key = ValueConversions<protocol::Runtime::ObjectPreview>::fromValue(keyValue, errors);
384 : }
385 0 : protocol::Value* valueValue = object->get("value");
386 0 : errors->setName("value");
387 0 : result->m_value = ValueConversions<protocol::Runtime::ObjectPreview>::fromValue(valueValue, errors);
388 0 : errors->pop();
389 0 : if (errors->hasErrors())
390 : return nullptr;
391 : return result;
392 : }
393 :
394 190 : std::unique_ptr<protocol::DictionaryValue> EntryPreview::toValue() const
395 : {
396 190 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
397 190 : if (m_key.isJust())
398 200 : result->setValue("key", ValueConversions<protocol::Runtime::ObjectPreview>::toValue(m_key.fromJust()));
399 760 : result->setValue("value", ValueConversions<protocol::Runtime::ObjectPreview>::toValue(m_value.get()));
400 190 : return result;
401 : }
402 :
403 0 : std::unique_ptr<EntryPreview> EntryPreview::clone() const
404 : {
405 0 : ErrorSupport errors;
406 0 : return fromValue(toValue().get(), &errors);
407 : }
408 :
409 0 : std::unique_ptr<PropertyDescriptor> PropertyDescriptor::fromValue(protocol::Value* value, ErrorSupport* errors)
410 : {
411 0 : if (!value || value->type() != protocol::Value::TypeObject) {
412 0 : errors->addError("object expected");
413 : return nullptr;
414 : }
415 :
416 0 : std::unique_ptr<PropertyDescriptor> result(new PropertyDescriptor());
417 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
418 0 : errors->push();
419 0 : protocol::Value* nameValue = object->get("name");
420 0 : errors->setName("name");
421 0 : result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
422 0 : protocol::Value* valueValue = object->get("value");
423 0 : if (valueValue) {
424 0 : errors->setName("value");
425 0 : result->m_value = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(valueValue, errors);
426 : }
427 0 : protocol::Value* writableValue = object->get("writable");
428 0 : if (writableValue) {
429 0 : errors->setName("writable");
430 0 : result->m_writable = ValueConversions<bool>::fromValue(writableValue, errors);
431 : }
432 0 : protocol::Value* getValue = object->get("get");
433 0 : if (getValue) {
434 0 : errors->setName("get");
435 0 : result->m_get = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(getValue, errors);
436 : }
437 0 : protocol::Value* setValue = object->get("set");
438 0 : if (setValue) {
439 0 : errors->setName("set");
440 0 : result->m_set = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(setValue, errors);
441 : }
442 0 : protocol::Value* configurableValue = object->get("configurable");
443 0 : errors->setName("configurable");
444 0 : result->m_configurable = ValueConversions<bool>::fromValue(configurableValue, errors);
445 0 : protocol::Value* enumerableValue = object->get("enumerable");
446 0 : errors->setName("enumerable");
447 0 : result->m_enumerable = ValueConversions<bool>::fromValue(enumerableValue, errors);
448 0 : protocol::Value* wasThrownValue = object->get("wasThrown");
449 0 : if (wasThrownValue) {
450 0 : errors->setName("wasThrown");
451 0 : result->m_wasThrown = ValueConversions<bool>::fromValue(wasThrownValue, errors);
452 : }
453 0 : protocol::Value* isOwnValue = object->get("isOwn");
454 0 : if (isOwnValue) {
455 0 : errors->setName("isOwn");
456 0 : result->m_isOwn = ValueConversions<bool>::fromValue(isOwnValue, errors);
457 : }
458 0 : protocol::Value* symbolValue = object->get("symbol");
459 0 : if (symbolValue) {
460 0 : errors->setName("symbol");
461 0 : result->m_symbol = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(symbolValue, errors);
462 : }
463 0 : errors->pop();
464 0 : if (errors->hasErrors())
465 : return nullptr;
466 : return result;
467 : }
468 :
469 2506694 : std::unique_ptr<protocol::DictionaryValue> PropertyDescriptor::toValue() const
470 : {
471 2506694 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
472 12533470 : result->setValue("name", ValueConversions<String>::toValue(m_name));
473 2506694 : if (m_value.isJust())
474 10025436 : result->setValue("value", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_value.fromJust()));
475 2506694 : if (m_writable.isJust())
476 10025436 : result->setValue("writable", ValueConversions<bool>::toValue(m_writable.fromJust()));
477 2506694 : if (m_get.isJust())
478 1340 : result->setValue("get", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_get.fromJust()));
479 2506694 : if (m_set.isJust())
480 1320 : result->setValue("set", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_set.fromJust()));
481 12533470 : result->setValue("configurable", ValueConversions<bool>::toValue(m_configurable));
482 12533470 : result->setValue("enumerable", ValueConversions<bool>::toValue(m_enumerable));
483 2506694 : if (m_wasThrown.isJust())
484 0 : result->setValue("wasThrown", ValueConversions<bool>::toValue(m_wasThrown.fromJust()));
485 2506694 : if (m_isOwn.isJust())
486 10026776 : result->setValue("isOwn", ValueConversions<bool>::toValue(m_isOwn.fromJust()));
487 2506694 : if (m_symbol.isJust())
488 73540 : result->setValue("symbol", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_symbol.fromJust()));
489 2506694 : return result;
490 : }
491 :
492 0 : std::unique_ptr<PropertyDescriptor> PropertyDescriptor::clone() const
493 : {
494 0 : ErrorSupport errors;
495 0 : return fromValue(toValue().get(), &errors);
496 : }
497 :
498 0 : std::unique_ptr<InternalPropertyDescriptor> InternalPropertyDescriptor::fromValue(protocol::Value* value, ErrorSupport* errors)
499 : {
500 0 : if (!value || value->type() != protocol::Value::TypeObject) {
501 0 : errors->addError("object expected");
502 : return nullptr;
503 : }
504 :
505 0 : std::unique_ptr<InternalPropertyDescriptor> result(new InternalPropertyDescriptor());
506 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
507 0 : errors->push();
508 0 : protocol::Value* nameValue = object->get("name");
509 0 : errors->setName("name");
510 0 : result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
511 0 : protocol::Value* valueValue = object->get("value");
512 0 : if (valueValue) {
513 0 : errors->setName("value");
514 0 : result->m_value = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(valueValue, errors);
515 : }
516 0 : errors->pop();
517 0 : if (errors->hasErrors())
518 : return nullptr;
519 : return result;
520 : }
521 :
522 1059 : std::unique_ptr<protocol::DictionaryValue> InternalPropertyDescriptor::toValue() const
523 : {
524 1059 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
525 5295 : result->setValue("name", ValueConversions<String>::toValue(m_name));
526 1059 : if (m_value.isJust())
527 4236 : result->setValue("value", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_value.fromJust()));
528 1059 : return result;
529 : }
530 :
531 0 : std::unique_ptr<InternalPropertyDescriptor> InternalPropertyDescriptor::clone() const
532 : {
533 0 : ErrorSupport errors;
534 0 : return fromValue(toValue().get(), &errors);
535 : }
536 :
537 752 : std::unique_ptr<CallArgument> CallArgument::fromValue(protocol::Value* value, ErrorSupport* errors)
538 : {
539 752 : if (!value || value->type() != protocol::Value::TypeObject) {
540 0 : errors->addError("object expected");
541 : return nullptr;
542 : }
543 :
544 376 : std::unique_ptr<CallArgument> result(new CallArgument());
545 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
546 376 : errors->push();
547 752 : protocol::Value* valueValue = object->get("value");
548 376 : if (valueValue) {
549 246 : errors->setName("value");
550 492 : result->m_value = ValueConversions<protocol::Value>::fromValue(valueValue, errors);
551 : }
552 752 : protocol::Value* unserializableValueValue = object->get("unserializableValue");
553 376 : if (unserializableValueValue) {
554 30 : errors->setName("unserializableValue");
555 60 : result->m_unserializableValue = ValueConversions<String>::fromValue(unserializableValueValue, errors);
556 : }
557 752 : protocol::Value* objectIdValue = object->get("objectId");
558 376 : if (objectIdValue) {
559 95 : errors->setName("objectId");
560 190 : result->m_objectId = ValueConversions<String>::fromValue(objectIdValue, errors);
561 : }
562 376 : errors->pop();
563 376 : if (errors->hasErrors())
564 : return nullptr;
565 : return result;
566 : }
567 :
568 0 : std::unique_ptr<protocol::DictionaryValue> CallArgument::toValue() const
569 : {
570 0 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
571 0 : if (m_value.isJust())
572 0 : result->setValue("value", ValueConversions<protocol::Value>::toValue(m_value.fromJust()));
573 0 : if (m_unserializableValue.isJust())
574 0 : result->setValue("unserializableValue", ValueConversions<String>::toValue(m_unserializableValue.fromJust()));
575 0 : if (m_objectId.isJust())
576 0 : result->setValue("objectId", ValueConversions<String>::toValue(m_objectId.fromJust()));
577 0 : return result;
578 : }
579 :
580 0 : std::unique_ptr<CallArgument> CallArgument::clone() const
581 : {
582 0 : ErrorSupport errors;
583 0 : return fromValue(toValue().get(), &errors);
584 : }
585 :
586 0 : std::unique_ptr<ExecutionContextDescription> ExecutionContextDescription::fromValue(protocol::Value* value, ErrorSupport* errors)
587 : {
588 0 : if (!value || value->type() != protocol::Value::TypeObject) {
589 0 : errors->addError("object expected");
590 : return nullptr;
591 : }
592 :
593 0 : std::unique_ptr<ExecutionContextDescription> result(new ExecutionContextDescription());
594 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
595 0 : errors->push();
596 0 : protocol::Value* idValue = object->get("id");
597 0 : errors->setName("id");
598 0 : result->m_id = ValueConversions<int>::fromValue(idValue, errors);
599 0 : protocol::Value* originValue = object->get("origin");
600 0 : errors->setName("origin");
601 0 : result->m_origin = ValueConversions<String>::fromValue(originValue, errors);
602 0 : protocol::Value* nameValue = object->get("name");
603 0 : errors->setName("name");
604 0 : result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
605 0 : protocol::Value* auxDataValue = object->get("auxData");
606 0 : if (auxDataValue) {
607 0 : errors->setName("auxData");
608 0 : result->m_auxData = ValueConversions<protocol::DictionaryValue>::fromValue(auxDataValue, errors);
609 : }
610 0 : errors->pop();
611 0 : if (errors->hasErrors())
612 : return nullptr;
613 : return result;
614 : }
615 :
616 682 : std::unique_ptr<protocol::DictionaryValue> ExecutionContextDescription::toValue() const
617 : {
618 682 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
619 3410 : result->setValue("id", ValueConversions<int>::toValue(m_id));
620 3410 : result->setValue("origin", ValueConversions<String>::toValue(m_origin));
621 3410 : result->setValue("name", ValueConversions<String>::toValue(m_name));
622 682 : if (m_auxData.isJust())
623 0 : result->setValue("auxData", ValueConversions<protocol::DictionaryValue>::toValue(m_auxData.fromJust()));
624 682 : return result;
625 : }
626 :
627 0 : std::unique_ptr<ExecutionContextDescription> ExecutionContextDescription::clone() const
628 : {
629 0 : ErrorSupport errors;
630 0 : return fromValue(toValue().get(), &errors);
631 : }
632 :
633 0 : std::unique_ptr<ExceptionDetails> ExceptionDetails::fromValue(protocol::Value* value, ErrorSupport* errors)
634 : {
635 0 : if (!value || value->type() != protocol::Value::TypeObject) {
636 0 : errors->addError("object expected");
637 : return nullptr;
638 : }
639 :
640 0 : std::unique_ptr<ExceptionDetails> result(new ExceptionDetails());
641 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
642 0 : errors->push();
643 0 : protocol::Value* exceptionIdValue = object->get("exceptionId");
644 0 : errors->setName("exceptionId");
645 0 : result->m_exceptionId = ValueConversions<int>::fromValue(exceptionIdValue, errors);
646 0 : protocol::Value* textValue = object->get("text");
647 0 : errors->setName("text");
648 0 : result->m_text = ValueConversions<String>::fromValue(textValue, errors);
649 0 : protocol::Value* lineNumberValue = object->get("lineNumber");
650 0 : errors->setName("lineNumber");
651 0 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
652 0 : protocol::Value* columnNumberValue = object->get("columnNumber");
653 0 : errors->setName("columnNumber");
654 0 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
655 0 : protocol::Value* scriptIdValue = object->get("scriptId");
656 0 : if (scriptIdValue) {
657 0 : errors->setName("scriptId");
658 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
659 : }
660 0 : protocol::Value* urlValue = object->get("url");
661 0 : if (urlValue) {
662 0 : errors->setName("url");
663 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
664 : }
665 0 : protocol::Value* stackTraceValue = object->get("stackTrace");
666 0 : if (stackTraceValue) {
667 0 : errors->setName("stackTrace");
668 0 : result->m_stackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(stackTraceValue, errors);
669 : }
670 0 : protocol::Value* exceptionValue = object->get("exception");
671 0 : if (exceptionValue) {
672 0 : errors->setName("exception");
673 0 : result->m_exception = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(exceptionValue, errors);
674 : }
675 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
676 0 : if (executionContextIdValue) {
677 0 : errors->setName("executionContextId");
678 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
679 : }
680 0 : errors->pop();
681 0 : if (errors->hasErrors())
682 : return nullptr;
683 : return result;
684 : }
685 :
686 1797 : std::unique_ptr<protocol::DictionaryValue> ExceptionDetails::toValue() const
687 : {
688 1797 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
689 8985 : result->setValue("exceptionId", ValueConversions<int>::toValue(m_exceptionId));
690 8985 : result->setValue("text", ValueConversions<String>::toValue(m_text));
691 8985 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
692 8985 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber));
693 1797 : if (m_scriptId.isJust())
694 8360 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId.fromJust()));
695 1797 : if (m_url.isJust())
696 100 : result->setValue("url", ValueConversions<String>::toValue(m_url.fromJust()));
697 1797 : if (m_stackTrace.isJust())
698 620 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_stackTrace.fromJust()));
699 1797 : if (m_exception.isJust())
700 7148 : result->setValue("exception", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_exception.fromJust()));
701 1797 : if (m_executionContextId.isJust())
702 700 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId.fromJust()));
703 1797 : return result;
704 : }
705 :
706 0 : std::unique_ptr<ExceptionDetails> ExceptionDetails::clone() const
707 : {
708 0 : ErrorSupport errors;
709 0 : return fromValue(toValue().get(), &errors);
710 : }
711 :
712 0 : std::unique_ptr<CallFrame> CallFrame::fromValue(protocol::Value* value, ErrorSupport* errors)
713 : {
714 0 : if (!value || value->type() != protocol::Value::TypeObject) {
715 0 : errors->addError("object expected");
716 : return nullptr;
717 : }
718 :
719 0 : std::unique_ptr<CallFrame> result(new CallFrame());
720 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
721 0 : errors->push();
722 0 : protocol::Value* functionNameValue = object->get("functionName");
723 0 : errors->setName("functionName");
724 0 : result->m_functionName = ValueConversions<String>::fromValue(functionNameValue, errors);
725 0 : protocol::Value* scriptIdValue = object->get("scriptId");
726 0 : errors->setName("scriptId");
727 0 : result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
728 0 : protocol::Value* urlValue = object->get("url");
729 0 : errors->setName("url");
730 0 : result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
731 0 : protocol::Value* lineNumberValue = object->get("lineNumber");
732 0 : errors->setName("lineNumber");
733 0 : result->m_lineNumber = ValueConversions<int>::fromValue(lineNumberValue, errors);
734 0 : protocol::Value* columnNumberValue = object->get("columnNumber");
735 0 : errors->setName("columnNumber");
736 0 : result->m_columnNumber = ValueConversions<int>::fromValue(columnNumberValue, errors);
737 0 : errors->pop();
738 0 : if (errors->hasErrors())
739 : return nullptr;
740 : return result;
741 : }
742 :
743 63883 : std::unique_ptr<protocol::DictionaryValue> CallFrame::toValue() const
744 : {
745 63883 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
746 319415 : result->setValue("functionName", ValueConversions<String>::toValue(m_functionName));
747 319415 : result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
748 319415 : result->setValue("url", ValueConversions<String>::toValue(m_url));
749 319415 : result->setValue("lineNumber", ValueConversions<int>::toValue(m_lineNumber));
750 319415 : result->setValue("columnNumber", ValueConversions<int>::toValue(m_columnNumber));
751 63883 : return result;
752 : }
753 :
754 0 : std::unique_ptr<CallFrame> CallFrame::clone() const
755 : {
756 0 : ErrorSupport errors;
757 0 : return fromValue(toValue().get(), &errors);
758 : }
759 :
760 0 : std::unique_ptr<StackTrace> StackTrace::fromValue(protocol::Value* value, ErrorSupport* errors)
761 : {
762 0 : if (!value || value->type() != protocol::Value::TypeObject) {
763 0 : errors->addError("object expected");
764 : return nullptr;
765 : }
766 :
767 0 : std::unique_ptr<StackTrace> result(new StackTrace());
768 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
769 0 : errors->push();
770 0 : protocol::Value* descriptionValue = object->get("description");
771 0 : if (descriptionValue) {
772 0 : errors->setName("description");
773 0 : result->m_description = ValueConversions<String>::fromValue(descriptionValue, errors);
774 : }
775 0 : protocol::Value* callFramesValue = object->get("callFrames");
776 0 : errors->setName("callFrames");
777 0 : result->m_callFrames = ValueConversions<protocol::Array<protocol::Runtime::CallFrame>>::fromValue(callFramesValue, errors);
778 0 : protocol::Value* parentValue = object->get("parent");
779 0 : if (parentValue) {
780 0 : errors->setName("parent");
781 0 : result->m_parent = ValueConversions<protocol::Runtime::StackTrace>::fromValue(parentValue, errors);
782 : }
783 0 : protocol::Value* parentIdValue = object->get("parentId");
784 0 : if (parentIdValue) {
785 0 : errors->setName("parentId");
786 0 : result->m_parentId = ValueConversions<protocol::Runtime::StackTraceId>::fromValue(parentIdValue, errors);
787 : }
788 0 : errors->pop();
789 0 : if (errors->hasErrors())
790 : return nullptr;
791 : return result;
792 : }
793 :
794 61834 : std::unique_ptr<protocol::DictionaryValue> StackTrace::toValue() const
795 : {
796 61834 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
797 61834 : if (m_description.isJust())
798 8675 : result->setValue("description", ValueConversions<String>::toValue(m_description.fromJust()));
799 247336 : result->setValue("callFrames", ValueConversions<protocol::Array<protocol::Runtime::CallFrame>>::toValue(m_callFrames.get()));
800 61834 : if (m_parent.isJust())
801 4520 : result->setValue("parent", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_parent.fromJust()));
802 61834 : if (m_parentId.isJust())
803 460 : result->setValue("parentId", ValueConversions<protocol::Runtime::StackTraceId>::toValue(m_parentId.fromJust()));
804 61834 : return result;
805 : }
806 :
807 0 : std::unique_ptr<StackTrace> StackTrace::clone() const
808 : {
809 0 : ErrorSupport errors;
810 0 : return fromValue(toValue().get(), &errors);
811 : }
812 :
813 0 : std::unique_ptr<StringBuffer> StackTrace::toJSONString() const
814 : {
815 0 : String json = toValue()->serializeToJSON();
816 0 : return StringBufferImpl::adopt(json);
817 : }
818 :
819 0 : void StackTrace::writeBinary(std::vector<uint8_t>* out) const
820 : {
821 0 : toValue()->writeBinary(out);
822 0 : }
823 :
824 : // static
825 0 : std::unique_ptr<API::StackTrace> API::StackTrace::fromJSONString(const StringView& json)
826 : {
827 0 : ErrorSupport errors;
828 0 : std::unique_ptr<Value> value = StringUtil::parseJSON(json);
829 0 : if (!value)
830 : return nullptr;
831 0 : return protocol::Runtime::StackTrace::fromValue(value.get(), &errors);
832 : }
833 :
834 : // static
835 0 : std::unique_ptr<API::StackTrace> API::StackTrace::fromBinary(const uint8_t* data, size_t length)
836 : {
837 0 : ErrorSupport errors;
838 0 : std::unique_ptr<Value> value = Value::parseBinary(data, length);
839 0 : if (!value)
840 : return nullptr;
841 0 : return protocol::Runtime::StackTrace::fromValue(value.get(), &errors);
842 : }
843 :
844 :
845 260 : std::unique_ptr<StackTraceId> StackTraceId::fromValue(protocol::Value* value, ErrorSupport* errors)
846 : {
847 260 : if (!value || value->type() != protocol::Value::TypeObject) {
848 0 : errors->addError("object expected");
849 : return nullptr;
850 : }
851 :
852 130 : std::unique_ptr<StackTraceId> result(new StackTraceId());
853 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
854 130 : errors->push();
855 260 : protocol::Value* idValue = object->get("id");
856 130 : errors->setName("id");
857 260 : result->m_id = ValueConversions<String>::fromValue(idValue, errors);
858 260 : protocol::Value* debuggerIdValue = object->get("debuggerId");
859 130 : if (debuggerIdValue) {
860 35 : errors->setName("debuggerId");
861 70 : result->m_debuggerId = ValueConversions<String>::fromValue(debuggerIdValue, errors);
862 : }
863 130 : errors->pop();
864 130 : if (errors->hasErrors())
865 : return nullptr;
866 : return result;
867 : }
868 :
869 235 : std::unique_ptr<protocol::DictionaryValue> StackTraceId::toValue() const
870 : {
871 235 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
872 1175 : result->setValue("id", ValueConversions<String>::toValue(m_id));
873 235 : if (m_debuggerId.isJust())
874 300 : result->setValue("debuggerId", ValueConversions<String>::toValue(m_debuggerId.fromJust()));
875 235 : return result;
876 : }
877 :
878 0 : std::unique_ptr<StackTraceId> StackTraceId::clone() const
879 : {
880 0 : ErrorSupport errors;
881 0 : return fromValue(toValue().get(), &errors);
882 : }
883 :
884 0 : std::unique_ptr<StringBuffer> StackTraceId::toJSONString() const
885 : {
886 0 : String json = toValue()->serializeToJSON();
887 0 : return StringBufferImpl::adopt(json);
888 : }
889 :
890 0 : void StackTraceId::writeBinary(std::vector<uint8_t>* out) const
891 : {
892 0 : toValue()->writeBinary(out);
893 0 : }
894 :
895 : // static
896 0 : std::unique_ptr<API::StackTraceId> API::StackTraceId::fromJSONString(const StringView& json)
897 : {
898 0 : ErrorSupport errors;
899 0 : std::unique_ptr<Value> value = StringUtil::parseJSON(json);
900 0 : if (!value)
901 : return nullptr;
902 0 : return protocol::Runtime::StackTraceId::fromValue(value.get(), &errors);
903 : }
904 :
905 : // static
906 0 : std::unique_ptr<API::StackTraceId> API::StackTraceId::fromBinary(const uint8_t* data, size_t length)
907 : {
908 0 : ErrorSupport errors;
909 0 : std::unique_ptr<Value> value = Value::parseBinary(data, length);
910 0 : if (!value)
911 : return nullptr;
912 0 : return protocol::Runtime::StackTraceId::fromValue(value.get(), &errors);
913 : }
914 :
915 :
916 0 : std::unique_ptr<BindingCalledNotification> BindingCalledNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
917 : {
918 0 : if (!value || value->type() != protocol::Value::TypeObject) {
919 0 : errors->addError("object expected");
920 : return nullptr;
921 : }
922 :
923 0 : std::unique_ptr<BindingCalledNotification> result(new BindingCalledNotification());
924 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
925 0 : errors->push();
926 0 : protocol::Value* nameValue = object->get("name");
927 0 : errors->setName("name");
928 0 : result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
929 0 : protocol::Value* payloadValue = object->get("payload");
930 0 : errors->setName("payload");
931 0 : result->m_payload = ValueConversions<String>::fromValue(payloadValue, errors);
932 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
933 0 : errors->setName("executionContextId");
934 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
935 0 : errors->pop();
936 0 : if (errors->hasErrors())
937 : return nullptr;
938 : return result;
939 : }
940 :
941 35 : std::unique_ptr<protocol::DictionaryValue> BindingCalledNotification::toValue() const
942 : {
943 35 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
944 175 : result->setValue("name", ValueConversions<String>::toValue(m_name));
945 175 : result->setValue("payload", ValueConversions<String>::toValue(m_payload));
946 175 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
947 35 : return result;
948 : }
949 :
950 0 : std::unique_ptr<BindingCalledNotification> BindingCalledNotification::clone() const
951 : {
952 0 : ErrorSupport errors;
953 0 : return fromValue(toValue().get(), &errors);
954 : }
955 :
956 : const char* ConsoleAPICalledNotification::TypeEnum::Log = "log";
957 : const char* ConsoleAPICalledNotification::TypeEnum::Debug = "debug";
958 : const char* ConsoleAPICalledNotification::TypeEnum::Info = "info";
959 : const char* ConsoleAPICalledNotification::TypeEnum::Error = "error";
960 : const char* ConsoleAPICalledNotification::TypeEnum::Warning = "warning";
961 : const char* ConsoleAPICalledNotification::TypeEnum::Dir = "dir";
962 : const char* ConsoleAPICalledNotification::TypeEnum::Dirxml = "dirxml";
963 : const char* ConsoleAPICalledNotification::TypeEnum::Table = "table";
964 : const char* ConsoleAPICalledNotification::TypeEnum::Trace = "trace";
965 : const char* ConsoleAPICalledNotification::TypeEnum::Clear = "clear";
966 : const char* ConsoleAPICalledNotification::TypeEnum::StartGroup = "startGroup";
967 : const char* ConsoleAPICalledNotification::TypeEnum::StartGroupCollapsed = "startGroupCollapsed";
968 : const char* ConsoleAPICalledNotification::TypeEnum::EndGroup = "endGroup";
969 : const char* ConsoleAPICalledNotification::TypeEnum::Assert = "assert";
970 : const char* ConsoleAPICalledNotification::TypeEnum::Profile = "profile";
971 : const char* ConsoleAPICalledNotification::TypeEnum::ProfileEnd = "profileEnd";
972 : const char* ConsoleAPICalledNotification::TypeEnum::Count = "count";
973 : const char* ConsoleAPICalledNotification::TypeEnum::TimeEnd = "timeEnd";
974 :
975 0 : std::unique_ptr<ConsoleAPICalledNotification> ConsoleAPICalledNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
976 : {
977 0 : if (!value || value->type() != protocol::Value::TypeObject) {
978 0 : errors->addError("object expected");
979 : return nullptr;
980 : }
981 :
982 0 : std::unique_ptr<ConsoleAPICalledNotification> result(new ConsoleAPICalledNotification());
983 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
984 0 : errors->push();
985 0 : protocol::Value* typeValue = object->get("type");
986 0 : errors->setName("type");
987 0 : result->m_type = ValueConversions<String>::fromValue(typeValue, errors);
988 0 : protocol::Value* argsValue = object->get("args");
989 0 : errors->setName("args");
990 0 : result->m_args = ValueConversions<protocol::Array<protocol::Runtime::RemoteObject>>::fromValue(argsValue, errors);
991 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
992 0 : errors->setName("executionContextId");
993 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
994 0 : protocol::Value* timestampValue = object->get("timestamp");
995 0 : errors->setName("timestamp");
996 0 : result->m_timestamp = ValueConversions<double>::fromValue(timestampValue, errors);
997 0 : protocol::Value* stackTraceValue = object->get("stackTrace");
998 0 : if (stackTraceValue) {
999 0 : errors->setName("stackTrace");
1000 0 : result->m_stackTrace = ValueConversions<protocol::Runtime::StackTrace>::fromValue(stackTraceValue, errors);
1001 : }
1002 0 : protocol::Value* contextValue = object->get("context");
1003 0 : if (contextValue) {
1004 0 : errors->setName("context");
1005 0 : result->m_context = ValueConversions<String>::fromValue(contextValue, errors);
1006 : }
1007 0 : errors->pop();
1008 0 : if (errors->hasErrors())
1009 : return nullptr;
1010 : return result;
1011 : }
1012 :
1013 6635 : std::unique_ptr<protocol::DictionaryValue> ConsoleAPICalledNotification::toValue() const
1014 : {
1015 6635 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1016 33175 : result->setValue("type", ValueConversions<String>::toValue(m_type));
1017 26540 : result->setValue("args", ValueConversions<protocol::Array<protocol::Runtime::RemoteObject>>::toValue(m_args.get()));
1018 33175 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
1019 33175 : result->setValue("timestamp", ValueConversions<double>::toValue(m_timestamp));
1020 6635 : if (m_stackTrace.isJust())
1021 26360 : result->setValue("stackTrace", ValueConversions<protocol::Runtime::StackTrace>::toValue(m_stackTrace.fromJust()));
1022 6635 : if (m_context.isJust())
1023 350 : result->setValue("context", ValueConversions<String>::toValue(m_context.fromJust()));
1024 6635 : return result;
1025 : }
1026 :
1027 0 : std::unique_ptr<ConsoleAPICalledNotification> ConsoleAPICalledNotification::clone() const
1028 : {
1029 0 : ErrorSupport errors;
1030 0 : return fromValue(toValue().get(), &errors);
1031 : }
1032 :
1033 0 : std::unique_ptr<ExceptionRevokedNotification> ExceptionRevokedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
1034 : {
1035 0 : if (!value || value->type() != protocol::Value::TypeObject) {
1036 0 : errors->addError("object expected");
1037 : return nullptr;
1038 : }
1039 :
1040 0 : std::unique_ptr<ExceptionRevokedNotification> result(new ExceptionRevokedNotification());
1041 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
1042 0 : errors->push();
1043 0 : protocol::Value* reasonValue = object->get("reason");
1044 0 : errors->setName("reason");
1045 0 : result->m_reason = ValueConversions<String>::fromValue(reasonValue, errors);
1046 0 : protocol::Value* exceptionIdValue = object->get("exceptionId");
1047 0 : errors->setName("exceptionId");
1048 0 : result->m_exceptionId = ValueConversions<int>::fromValue(exceptionIdValue, errors);
1049 0 : errors->pop();
1050 0 : if (errors->hasErrors())
1051 : return nullptr;
1052 : return result;
1053 : }
1054 :
1055 70 : std::unique_ptr<protocol::DictionaryValue> ExceptionRevokedNotification::toValue() const
1056 : {
1057 70 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1058 350 : result->setValue("reason", ValueConversions<String>::toValue(m_reason));
1059 350 : result->setValue("exceptionId", ValueConversions<int>::toValue(m_exceptionId));
1060 70 : return result;
1061 : }
1062 :
1063 0 : std::unique_ptr<ExceptionRevokedNotification> ExceptionRevokedNotification::clone() const
1064 : {
1065 0 : ErrorSupport errors;
1066 0 : return fromValue(toValue().get(), &errors);
1067 : }
1068 :
1069 0 : std::unique_ptr<ExceptionThrownNotification> ExceptionThrownNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
1070 : {
1071 0 : if (!value || value->type() != protocol::Value::TypeObject) {
1072 0 : errors->addError("object expected");
1073 : return nullptr;
1074 : }
1075 :
1076 0 : std::unique_ptr<ExceptionThrownNotification> result(new ExceptionThrownNotification());
1077 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
1078 0 : errors->push();
1079 0 : protocol::Value* timestampValue = object->get("timestamp");
1080 0 : errors->setName("timestamp");
1081 0 : result->m_timestamp = ValueConversions<double>::fromValue(timestampValue, errors);
1082 0 : protocol::Value* exceptionDetailsValue = object->get("exceptionDetails");
1083 0 : errors->setName("exceptionDetails");
1084 0 : result->m_exceptionDetails = ValueConversions<protocol::Runtime::ExceptionDetails>::fromValue(exceptionDetailsValue, errors);
1085 0 : errors->pop();
1086 0 : if (errors->hasErrors())
1087 : return nullptr;
1088 : return result;
1089 : }
1090 :
1091 175 : std::unique_ptr<protocol::DictionaryValue> ExceptionThrownNotification::toValue() const
1092 : {
1093 175 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1094 875 : result->setValue("timestamp", ValueConversions<double>::toValue(m_timestamp));
1095 700 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(m_exceptionDetails.get()));
1096 175 : return result;
1097 : }
1098 :
1099 0 : std::unique_ptr<ExceptionThrownNotification> ExceptionThrownNotification::clone() const
1100 : {
1101 0 : ErrorSupport errors;
1102 0 : return fromValue(toValue().get(), &errors);
1103 : }
1104 :
1105 0 : std::unique_ptr<ExecutionContextCreatedNotification> ExecutionContextCreatedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
1106 : {
1107 0 : if (!value || value->type() != protocol::Value::TypeObject) {
1108 0 : errors->addError("object expected");
1109 : return nullptr;
1110 : }
1111 :
1112 0 : std::unique_ptr<ExecutionContextCreatedNotification> result(new ExecutionContextCreatedNotification());
1113 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
1114 0 : errors->push();
1115 0 : protocol::Value* contextValue = object->get("context");
1116 0 : errors->setName("context");
1117 0 : result->m_context = ValueConversions<protocol::Runtime::ExecutionContextDescription>::fromValue(contextValue, errors);
1118 0 : errors->pop();
1119 0 : if (errors->hasErrors())
1120 : return nullptr;
1121 : return result;
1122 : }
1123 :
1124 682 : std::unique_ptr<protocol::DictionaryValue> ExecutionContextCreatedNotification::toValue() const
1125 : {
1126 682 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1127 2728 : result->setValue("context", ValueConversions<protocol::Runtime::ExecutionContextDescription>::toValue(m_context.get()));
1128 682 : return result;
1129 : }
1130 :
1131 0 : std::unique_ptr<ExecutionContextCreatedNotification> ExecutionContextCreatedNotification::clone() const
1132 : {
1133 0 : ErrorSupport errors;
1134 0 : return fromValue(toValue().get(), &errors);
1135 : }
1136 :
1137 0 : std::unique_ptr<ExecutionContextDestroyedNotification> ExecutionContextDestroyedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
1138 : {
1139 0 : if (!value || value->type() != protocol::Value::TypeObject) {
1140 0 : errors->addError("object expected");
1141 : return nullptr;
1142 : }
1143 :
1144 0 : std::unique_ptr<ExecutionContextDestroyedNotification> result(new ExecutionContextDestroyedNotification());
1145 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
1146 0 : errors->push();
1147 0 : protocol::Value* executionContextIdValue = object->get("executionContextId");
1148 0 : errors->setName("executionContextId");
1149 0 : result->m_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
1150 0 : errors->pop();
1151 0 : if (errors->hasErrors())
1152 : return nullptr;
1153 : return result;
1154 : }
1155 :
1156 25 : std::unique_ptr<protocol::DictionaryValue> ExecutionContextDestroyedNotification::toValue() const
1157 : {
1158 25 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1159 125 : result->setValue("executionContextId", ValueConversions<int>::toValue(m_executionContextId));
1160 25 : return result;
1161 : }
1162 :
1163 0 : std::unique_ptr<ExecutionContextDestroyedNotification> ExecutionContextDestroyedNotification::clone() const
1164 : {
1165 0 : ErrorSupport errors;
1166 0 : return fromValue(toValue().get(), &errors);
1167 : }
1168 :
1169 0 : std::unique_ptr<InspectRequestedNotification> InspectRequestedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
1170 : {
1171 0 : if (!value || value->type() != protocol::Value::TypeObject) {
1172 0 : errors->addError("object expected");
1173 : return nullptr;
1174 : }
1175 :
1176 0 : std::unique_ptr<InspectRequestedNotification> result(new InspectRequestedNotification());
1177 : protocol::DictionaryValue* object = DictionaryValue::cast(value);
1178 0 : errors->push();
1179 0 : protocol::Value* objectValue = object->get("object");
1180 0 : errors->setName("object");
1181 0 : result->m_object = ValueConversions<protocol::Runtime::RemoteObject>::fromValue(objectValue, errors);
1182 0 : protocol::Value* hintsValue = object->get("hints");
1183 0 : errors->setName("hints");
1184 0 : result->m_hints = ValueConversions<protocol::DictionaryValue>::fromValue(hintsValue, errors);
1185 0 : errors->pop();
1186 0 : if (errors->hasErrors())
1187 : return nullptr;
1188 : return result;
1189 : }
1190 :
1191 80 : std::unique_ptr<protocol::DictionaryValue> InspectRequestedNotification::toValue() const
1192 : {
1193 80 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1194 320 : result->setValue("object", ValueConversions<protocol::Runtime::RemoteObject>::toValue(m_object.get()));
1195 320 : result->setValue("hints", ValueConversions<protocol::DictionaryValue>::toValue(m_hints.get()));
1196 80 : return result;
1197 : }
1198 :
1199 0 : std::unique_ptr<InspectRequestedNotification> InspectRequestedNotification::clone() const
1200 : {
1201 0 : ErrorSupport errors;
1202 0 : return fromValue(toValue().get(), &errors);
1203 : }
1204 :
1205 : // ------------- Enum values from params.
1206 :
1207 :
1208 : namespace ConsoleAPICalled {
1209 : namespace TypeEnum {
1210 : const char* Log = "log";
1211 : const char* Debug = "debug";
1212 : const char* Info = "info";
1213 : const char* Error = "error";
1214 : const char* Warning = "warning";
1215 : const char* Dir = "dir";
1216 : const char* Dirxml = "dirxml";
1217 : const char* Table = "table";
1218 : const char* Trace = "trace";
1219 : const char* Clear = "clear";
1220 : const char* StartGroup = "startGroup";
1221 : const char* StartGroupCollapsed = "startGroupCollapsed";
1222 : const char* EndGroup = "endGroup";
1223 : const char* Assert = "assert";
1224 : const char* Profile = "profile";
1225 : const char* ProfileEnd = "profileEnd";
1226 : const char* Count = "count";
1227 : const char* TimeEnd = "timeEnd";
1228 : } // namespace TypeEnum
1229 : } // namespace ConsoleAPICalled
1230 :
1231 : // ------------- Frontend notifications.
1232 :
1233 35 : void Frontend::bindingCalled(const String& name, const String& payload, int executionContextId)
1234 : {
1235 35 : if (!m_frontendChannel)
1236 35 : return;
1237 : std::unique_ptr<BindingCalledNotification> messageData = BindingCalledNotification::create()
1238 35 : .setName(name)
1239 : .setPayload(payload)
1240 : .setExecutionContextId(executionContextId)
1241 : .build();
1242 245 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Runtime.bindingCalled", std::move(messageData)));
1243 : }
1244 :
1245 6635 : void Frontend::consoleAPICalled(const String& type, std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> args, int executionContextId, double timestamp, Maybe<protocol::Runtime::StackTrace> stackTrace, Maybe<String> context)
1246 : {
1247 6635 : if (!m_frontendChannel)
1248 6635 : return;
1249 : std::unique_ptr<ConsoleAPICalledNotification> messageData = ConsoleAPICalledNotification::create()
1250 6635 : .setType(type)
1251 : .setArgs(std::move(args))
1252 : .setExecutionContextId(executionContextId)
1253 : .setTimestamp(timestamp)
1254 : .build();
1255 6635 : if (stackTrace.isJust())
1256 : messageData->setStackTrace(std::move(stackTrace).takeJust());
1257 6635 : if (context.isJust())
1258 140 : messageData->setContext(std::move(context).takeJust());
1259 46445 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Runtime.consoleAPICalled", std::move(messageData)));
1260 : }
1261 :
1262 70 : void Frontend::exceptionRevoked(const String& reason, int exceptionId)
1263 : {
1264 70 : if (!m_frontendChannel)
1265 70 : return;
1266 : std::unique_ptr<ExceptionRevokedNotification> messageData = ExceptionRevokedNotification::create()
1267 70 : .setReason(reason)
1268 : .setExceptionId(exceptionId)
1269 : .build();
1270 490 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Runtime.exceptionRevoked", std::move(messageData)));
1271 : }
1272 :
1273 175 : void Frontend::exceptionThrown(double timestamp, std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails)
1274 : {
1275 175 : if (!m_frontendChannel)
1276 175 : return;
1277 : std::unique_ptr<ExceptionThrownNotification> messageData = ExceptionThrownNotification::create()
1278 175 : .setTimestamp(timestamp)
1279 : .setExceptionDetails(std::move(exceptionDetails))
1280 : .build();
1281 1225 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Runtime.exceptionThrown", std::move(messageData)));
1282 : }
1283 :
1284 682 : void Frontend::executionContextCreated(std::unique_ptr<protocol::Runtime::ExecutionContextDescription> context)
1285 : {
1286 682 : if (!m_frontendChannel)
1287 682 : return;
1288 : std::unique_ptr<ExecutionContextCreatedNotification> messageData = ExecutionContextCreatedNotification::create()
1289 : .setContext(std::move(context))
1290 : .build();
1291 4774 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Runtime.executionContextCreated", std::move(messageData)));
1292 : }
1293 :
1294 25 : void Frontend::executionContextDestroyed(int executionContextId)
1295 : {
1296 25 : if (!m_frontendChannel)
1297 25 : return;
1298 : std::unique_ptr<ExecutionContextDestroyedNotification> messageData = ExecutionContextDestroyedNotification::create()
1299 : .setExecutionContextId(executionContextId)
1300 : .build();
1301 175 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Runtime.executionContextDestroyed", std::move(messageData)));
1302 : }
1303 :
1304 40 : void Frontend::executionContextsCleared()
1305 : {
1306 40 : if (!m_frontendChannel)
1307 40 : return;
1308 280 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Runtime.executionContextsCleared"));
1309 : }
1310 :
1311 80 : void Frontend::inspectRequested(std::unique_ptr<protocol::Runtime::RemoteObject> object, std::unique_ptr<protocol::DictionaryValue> hints)
1312 : {
1313 80 : if (!m_frontendChannel)
1314 80 : return;
1315 : std::unique_ptr<InspectRequestedNotification> messageData = InspectRequestedNotification::create()
1316 80 : .setObject(std::move(object))
1317 : .setHints(std::move(hints))
1318 : .build();
1319 560 : m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Runtime.inspectRequested", std::move(messageData)));
1320 : }
1321 :
1322 6880 : void Frontend::flush()
1323 : {
1324 6880 : m_frontendChannel->flushProtocolNotifications();
1325 6880 : }
1326 :
1327 0 : void Frontend::sendRawNotification(String notification)
1328 : {
1329 0 : m_frontendChannel->sendProtocolNotification(InternalRawNotification::fromJSON(std::move(notification)));
1330 0 : }
1331 :
1332 0 : void Frontend::sendRawNotification(std::vector<uint8_t> notification)
1333 : {
1334 0 : m_frontendChannel->sendProtocolNotification(InternalRawNotification::fromBinary(std::move(notification)));
1335 0 : }
1336 :
1337 : // --------------------- Dispatcher.
1338 :
1339 : class DispatcherImpl : public protocol::DispatcherBase {
1340 : public:
1341 3832 : DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend)
1342 : : DispatcherBase(frontendChannel)
1343 11496 : , m_backend(backend) {
1344 11496 : m_dispatchMap["Runtime.awaitPromise"] = &DispatcherImpl::awaitPromise;
1345 11496 : m_dispatchMap["Runtime.callFunctionOn"] = &DispatcherImpl::callFunctionOn;
1346 11496 : m_dispatchMap["Runtime.compileScript"] = &DispatcherImpl::compileScript;
1347 11496 : m_dispatchMap["Runtime.disable"] = &DispatcherImpl::disable;
1348 11496 : m_dispatchMap["Runtime.discardConsoleEntries"] = &DispatcherImpl::discardConsoleEntries;
1349 11496 : m_dispatchMap["Runtime.enable"] = &DispatcherImpl::enable;
1350 11496 : m_dispatchMap["Runtime.evaluate"] = &DispatcherImpl::evaluate;
1351 11496 : m_dispatchMap["Runtime.getIsolateId"] = &DispatcherImpl::getIsolateId;
1352 11496 : m_dispatchMap["Runtime.getHeapUsage"] = &DispatcherImpl::getHeapUsage;
1353 11496 : m_dispatchMap["Runtime.getProperties"] = &DispatcherImpl::getProperties;
1354 11496 : m_dispatchMap["Runtime.globalLexicalScopeNames"] = &DispatcherImpl::globalLexicalScopeNames;
1355 11496 : m_dispatchMap["Runtime.queryObjects"] = &DispatcherImpl::queryObjects;
1356 11496 : m_dispatchMap["Runtime.releaseObject"] = &DispatcherImpl::releaseObject;
1357 11496 : m_dispatchMap["Runtime.releaseObjectGroup"] = &DispatcherImpl::releaseObjectGroup;
1358 11496 : m_dispatchMap["Runtime.runIfWaitingForDebugger"] = &DispatcherImpl::runIfWaitingForDebugger;
1359 11496 : m_dispatchMap["Runtime.runScript"] = &DispatcherImpl::runScript;
1360 11496 : m_redirects["Runtime.setAsyncCallStackDepth"] = "Debugger.setAsyncCallStackDepth";
1361 11496 : m_dispatchMap["Runtime.setCustomObjectFormatterEnabled"] = &DispatcherImpl::setCustomObjectFormatterEnabled;
1362 11496 : m_dispatchMap["Runtime.setMaxCallStackSizeToCapture"] = &DispatcherImpl::setMaxCallStackSizeToCapture;
1363 11496 : m_dispatchMap["Runtime.terminateExecution"] = &DispatcherImpl::terminateExecution;
1364 11496 : m_dispatchMap["Runtime.addBinding"] = &DispatcherImpl::addBinding;
1365 11496 : m_dispatchMap["Runtime.removeBinding"] = &DispatcherImpl::removeBinding;
1366 3832 : }
1367 11496 : ~DispatcherImpl() override { }
1368 : bool canDispatch(const String& method) override;
1369 : void dispatch(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<protocol::DictionaryValue> messageObject) override;
1370 : std::unordered_map<String, String>& redirects() { return m_redirects; }
1371 :
1372 : protected:
1373 : using CallHandler = void (DispatcherImpl::*)(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
1374 : using DispatchMap = std::unordered_map<String, CallHandler>;
1375 : DispatchMap m_dispatchMap;
1376 : std::unordered_map<String, String> m_redirects;
1377 :
1378 : void awaitPromise(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1379 : void callFunctionOn(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1380 : void compileScript(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1381 : void disable(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1382 : void discardConsoleEntries(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1383 : void enable(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1384 : void evaluate(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1385 : void getIsolateId(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1386 : void getHeapUsage(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1387 : void getProperties(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1388 : void globalLexicalScopeNames(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1389 : void queryObjects(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1390 : void releaseObject(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1391 : void releaseObjectGroup(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1392 : void runIfWaitingForDebugger(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1393 : void runScript(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1394 : void setCustomObjectFormatterEnabled(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1395 : void setMaxCallStackSizeToCapture(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1396 : void terminateExecution(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1397 : void addBinding(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1398 : void removeBinding(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
1399 :
1400 : Backend* m_backend;
1401 : };
1402 :
1403 79110 : bool DispatcherImpl::canDispatch(const String& method) {
1404 79110 : return m_dispatchMap.find(method) != m_dispatchMap.end();
1405 : }
1406 :
1407 79110 : void DispatcherImpl::dispatch(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<protocol::DictionaryValue> messageObject)
1408 : {
1409 : std::unordered_map<String, CallHandler>::iterator it = m_dispatchMap.find(method);
1410 : DCHECK(it != m_dispatchMap.end());
1411 79110 : protocol::ErrorSupport errors;
1412 237330 : (this->*(it->second))(callId, method, message, std::move(messageObject), &errors);
1413 79110 : }
1414 :
1415 :
1416 70 : class AwaitPromiseCallbackImpl : public Backend::AwaitPromiseCallback, public DispatcherBase::Callback {
1417 : public:
1418 35 : AwaitPromiseCallbackImpl(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId, const String& method, const ProtocolMessage& message)
1419 70 : : DispatcherBase::Callback(std::move(backendImpl), callId, method, message) { }
1420 :
1421 30 : void sendSuccess(std::unique_ptr<protocol::Runtime::RemoteObject> result, Maybe<protocol::Runtime::ExceptionDetails> exceptionDetails) override
1422 : {
1423 30 : std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
1424 120 : resultObject->setValue("result", ValueConversions<protocol::Runtime::RemoteObject>::toValue(result.get()));
1425 30 : if (exceptionDetails.isJust())
1426 60 : resultObject->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(exceptionDetails.fromJust()));
1427 120 : sendIfActive(std::move(resultObject), DispatchResponse::OK());
1428 30 : }
1429 :
1430 0 : void fallThrough() override
1431 : {
1432 0 : fallThroughIfActive();
1433 0 : }
1434 :
1435 5 : void sendFailure(const DispatchResponse& response) override
1436 : {
1437 : DCHECK(response.status() == DispatchResponse::kError);
1438 10 : sendIfActive(nullptr, response);
1439 5 : }
1440 : };
1441 :
1442 35 : void DispatcherImpl::awaitPromise(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1443 : {
1444 : // Prepare input parameters.
1445 105 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1446 35 : errors->push();
1447 70 : protocol::Value* promiseObjectIdValue = object ? object->get("promiseObjectId") : nullptr;
1448 35 : errors->setName("promiseObjectId");
1449 35 : String in_promiseObjectId = ValueConversions<String>::fromValue(promiseObjectIdValue, errors);
1450 70 : protocol::Value* returnByValueValue = object ? object->get("returnByValue") : nullptr;
1451 : Maybe<bool> in_returnByValue;
1452 35 : if (returnByValueValue) {
1453 15 : errors->setName("returnByValue");
1454 15 : in_returnByValue = ValueConversions<bool>::fromValue(returnByValueValue, errors);
1455 : }
1456 70 : protocol::Value* generatePreviewValue = object ? object->get("generatePreview") : nullptr;
1457 : Maybe<bool> in_generatePreview;
1458 35 : if (generatePreviewValue) {
1459 15 : errors->setName("generatePreview");
1460 15 : in_generatePreview = ValueConversions<bool>::fromValue(generatePreviewValue, errors);
1461 : }
1462 35 : errors->pop();
1463 35 : if (errors->hasErrors()) {
1464 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1465 0 : return;
1466 : }
1467 :
1468 35 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1469 70 : std::unique_ptr<AwaitPromiseCallbackImpl> callback(new AwaitPromiseCallbackImpl(weakPtr(), callId, method, message));
1470 105 : m_backend->awaitPromise(in_promiseObjectId, std::move(in_returnByValue), std::move(in_generatePreview), std::move(callback));
1471 : return;
1472 : }
1473 :
1474 1322 : class CallFunctionOnCallbackImpl : public Backend::CallFunctionOnCallback, public DispatcherBase::Callback {
1475 : public:
1476 661 : CallFunctionOnCallbackImpl(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId, const String& method, const ProtocolMessage& message)
1477 1322 : : DispatcherBase::Callback(std::move(backendImpl), callId, method, message) { }
1478 :
1479 656 : void sendSuccess(std::unique_ptr<protocol::Runtime::RemoteObject> result, Maybe<protocol::Runtime::ExceptionDetails> exceptionDetails) override
1480 : {
1481 656 : std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
1482 2624 : resultObject->setValue("result", ValueConversions<protocol::Runtime::RemoteObject>::toValue(result.get()));
1483 656 : if (exceptionDetails.isJust())
1484 80 : resultObject->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(exceptionDetails.fromJust()));
1485 2624 : sendIfActive(std::move(resultObject), DispatchResponse::OK());
1486 656 : }
1487 :
1488 0 : void fallThrough() override
1489 : {
1490 0 : fallThroughIfActive();
1491 0 : }
1492 :
1493 5 : void sendFailure(const DispatchResponse& response) override
1494 : {
1495 : DCHECK(response.status() == DispatchResponse::kError);
1496 10 : sendIfActive(nullptr, response);
1497 5 : }
1498 : };
1499 :
1500 661 : void DispatcherImpl::callFunctionOn(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1501 : {
1502 : // Prepare input parameters.
1503 1983 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1504 661 : errors->push();
1505 1322 : protocol::Value* functionDeclarationValue = object ? object->get("functionDeclaration") : nullptr;
1506 661 : errors->setName("functionDeclaration");
1507 661 : String in_functionDeclaration = ValueConversions<String>::fromValue(functionDeclarationValue, errors);
1508 1322 : protocol::Value* objectIdValue = object ? object->get("objectId") : nullptr;
1509 : Maybe<String> in_objectId;
1510 661 : if (objectIdValue) {
1511 656 : errors->setName("objectId");
1512 1312 : in_objectId = ValueConversions<String>::fromValue(objectIdValue, errors);
1513 : }
1514 1322 : protocol::Value* argumentsValue = object ? object->get("arguments") : nullptr;
1515 : Maybe<protocol::Array<protocol::Runtime::CallArgument>> in_arguments;
1516 661 : if (argumentsValue) {
1517 125 : errors->setName("arguments");
1518 125 : in_arguments = ValueConversions<protocol::Array<protocol::Runtime::CallArgument>>::fromValue(argumentsValue, errors);
1519 : }
1520 1322 : protocol::Value* silentValue = object ? object->get("silent") : nullptr;
1521 : Maybe<bool> in_silent;
1522 661 : if (silentValue) {
1523 0 : errors->setName("silent");
1524 0 : in_silent = ValueConversions<bool>::fromValue(silentValue, errors);
1525 : }
1526 1322 : protocol::Value* returnByValueValue = object ? object->get("returnByValue") : nullptr;
1527 : Maybe<bool> in_returnByValue;
1528 661 : if (returnByValueValue) {
1529 405 : errors->setName("returnByValue");
1530 405 : in_returnByValue = ValueConversions<bool>::fromValue(returnByValueValue, errors);
1531 : }
1532 1322 : protocol::Value* generatePreviewValue = object ? object->get("generatePreview") : nullptr;
1533 : Maybe<bool> in_generatePreview;
1534 661 : if (generatePreviewValue) {
1535 65 : errors->setName("generatePreview");
1536 65 : in_generatePreview = ValueConversions<bool>::fromValue(generatePreviewValue, errors);
1537 : }
1538 1322 : protocol::Value* userGestureValue = object ? object->get("userGesture") : nullptr;
1539 : Maybe<bool> in_userGesture;
1540 661 : if (userGestureValue) {
1541 0 : errors->setName("userGesture");
1542 0 : in_userGesture = ValueConversions<bool>::fromValue(userGestureValue, errors);
1543 : }
1544 1322 : protocol::Value* awaitPromiseValue = object ? object->get("awaitPromise") : nullptr;
1545 : Maybe<bool> in_awaitPromise;
1546 661 : if (awaitPromiseValue) {
1547 55 : errors->setName("awaitPromise");
1548 55 : in_awaitPromise = ValueConversions<bool>::fromValue(awaitPromiseValue, errors);
1549 : }
1550 1322 : protocol::Value* executionContextIdValue = object ? object->get("executionContextId") : nullptr;
1551 : Maybe<int> in_executionContextId;
1552 661 : if (executionContextIdValue) {
1553 10 : errors->setName("executionContextId");
1554 10 : in_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
1555 : }
1556 1322 : protocol::Value* objectGroupValue = object ? object->get("objectGroup") : nullptr;
1557 : Maybe<String> in_objectGroup;
1558 661 : if (objectGroupValue) {
1559 0 : errors->setName("objectGroup");
1560 0 : in_objectGroup = ValueConversions<String>::fromValue(objectGroupValue, errors);
1561 : }
1562 661 : errors->pop();
1563 661 : if (errors->hasErrors()) {
1564 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1565 0 : return;
1566 : }
1567 :
1568 661 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1569 1322 : std::unique_ptr<CallFunctionOnCallbackImpl> callback(new CallFunctionOnCallbackImpl(weakPtr(), callId, method, message));
1570 3966 : m_backend->callFunctionOn(in_functionDeclaration, std::move(in_objectId), std::move(in_arguments), std::move(in_silent), std::move(in_returnByValue), std::move(in_generatePreview), std::move(in_userGesture), std::move(in_awaitPromise), std::move(in_executionContextId), std::move(in_objectGroup), std::move(callback));
1571 : return;
1572 : }
1573 :
1574 232 : void DispatcherImpl::compileScript(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1575 : {
1576 : // Prepare input parameters.
1577 696 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1578 232 : errors->push();
1579 464 : protocol::Value* expressionValue = object ? object->get("expression") : nullptr;
1580 232 : errors->setName("expression");
1581 232 : String in_expression = ValueConversions<String>::fromValue(expressionValue, errors);
1582 464 : protocol::Value* sourceURLValue = object ? object->get("sourceURL") : nullptr;
1583 232 : errors->setName("sourceURL");
1584 232 : String in_sourceURL = ValueConversions<String>::fromValue(sourceURLValue, errors);
1585 464 : protocol::Value* persistScriptValue = object ? object->get("persistScript") : nullptr;
1586 232 : errors->setName("persistScript");
1587 232 : bool in_persistScript = ValueConversions<bool>::fromValue(persistScriptValue, errors);
1588 464 : protocol::Value* executionContextIdValue = object ? object->get("executionContextId") : nullptr;
1589 : Maybe<int> in_executionContextId;
1590 232 : if (executionContextIdValue) {
1591 20 : errors->setName("executionContextId");
1592 20 : in_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
1593 : }
1594 232 : errors->pop();
1595 232 : if (errors->hasErrors()) {
1596 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1597 0 : return;
1598 : }
1599 : // Declare output parameters.
1600 : Maybe<String> out_scriptId;
1601 : Maybe<protocol::Runtime::ExceptionDetails> out_exceptionDetails;
1602 :
1603 232 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1604 464 : DispatchResponse response = m_backend->compileScript(in_expression, in_sourceURL, in_persistScript, std::move(in_executionContextId), &out_scriptId, &out_exceptionDetails);
1605 232 : if (response.status() == DispatchResponse::kFallThrough) {
1606 0 : channel()->fallThrough(callId, method, message);
1607 0 : return;
1608 : }
1609 232 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1610 232 : if (response.status() == DispatchResponse::kSuccess) {
1611 227 : if (out_scriptId.isJust())
1612 960 : result->setValue("scriptId", ValueConversions<String>::toValue(out_scriptId.fromJust()));
1613 227 : if (out_exceptionDetails.isJust())
1614 100 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(out_exceptionDetails.fromJust()));
1615 : }
1616 232 : if (weak->get())
1617 464 : weak->get()->sendResponse(callId, response, std::move(result));
1618 : return;
1619 : }
1620 :
1621 327 : void DispatcherImpl::disable(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1622 : {
1623 :
1624 327 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1625 327 : DispatchResponse response = m_backend->disable();
1626 327 : if (response.status() == DispatchResponse::kFallThrough) {
1627 0 : channel()->fallThrough(callId, method, message);
1628 0 : return;
1629 : }
1630 327 : if (weak->get())
1631 327 : weak->get()->sendResponse(callId, response);
1632 : return;
1633 : }
1634 :
1635 5 : void DispatcherImpl::discardConsoleEntries(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1636 : {
1637 :
1638 5 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1639 5 : DispatchResponse response = m_backend->discardConsoleEntries();
1640 5 : if (response.status() == DispatchResponse::kFallThrough) {
1641 0 : channel()->fallThrough(callId, method, message);
1642 0 : return;
1643 : }
1644 5 : if (weak->get())
1645 5 : weak->get()->sendResponse(callId, response);
1646 : return;
1647 : }
1648 :
1649 632 : void DispatcherImpl::enable(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1650 : {
1651 :
1652 632 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1653 632 : DispatchResponse response = m_backend->enable();
1654 632 : if (response.status() == DispatchResponse::kFallThrough) {
1655 0 : channel()->fallThrough(callId, method, message);
1656 0 : return;
1657 : }
1658 632 : if (weak->get())
1659 632 : weak->get()->sendResponse(callId, response);
1660 : return;
1661 : }
1662 :
1663 16996 : class EvaluateCallbackImpl : public Backend::EvaluateCallback, public DispatcherBase::Callback {
1664 : public:
1665 8498 : EvaluateCallbackImpl(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId, const String& method, const ProtocolMessage& message)
1666 16996 : : DispatcherBase::Callback(std::move(backendImpl), callId, method, message) { }
1667 :
1668 8400 : void sendSuccess(std::unique_ptr<protocol::Runtime::RemoteObject> result, Maybe<protocol::Runtime::ExceptionDetails> exceptionDetails) override
1669 : {
1670 8400 : std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
1671 33600 : resultObject->setValue("result", ValueConversions<protocol::Runtime::RemoteObject>::toValue(result.get()));
1672 8400 : if (exceptionDetails.isJust())
1673 1432 : resultObject->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(exceptionDetails.fromJust()));
1674 33600 : sendIfActive(std::move(resultObject), DispatchResponse::OK());
1675 8400 : }
1676 :
1677 0 : void fallThrough() override
1678 : {
1679 0 : fallThroughIfActive();
1680 0 : }
1681 :
1682 98 : void sendFailure(const DispatchResponse& response) override
1683 : {
1684 : DCHECK(response.status() == DispatchResponse::kError);
1685 196 : sendIfActive(nullptr, response);
1686 98 : }
1687 : };
1688 :
1689 8503 : void DispatcherImpl::evaluate(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1690 : {
1691 : // Prepare input parameters.
1692 25509 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1693 8503 : errors->push();
1694 17006 : protocol::Value* expressionValue = object ? object->get("expression") : nullptr;
1695 8503 : errors->setName("expression");
1696 8503 : String in_expression = ValueConversions<String>::fromValue(expressionValue, errors);
1697 17006 : protocol::Value* objectGroupValue = object ? object->get("objectGroup") : nullptr;
1698 : Maybe<String> in_objectGroup;
1699 8503 : if (objectGroupValue) {
1700 180 : errors->setName("objectGroup");
1701 360 : in_objectGroup = ValueConversions<String>::fromValue(objectGroupValue, errors);
1702 : }
1703 17006 : protocol::Value* includeCommandLineAPIValue = object ? object->get("includeCommandLineAPI") : nullptr;
1704 : Maybe<bool> in_includeCommandLineAPI;
1705 8503 : if (includeCommandLineAPIValue) {
1706 545 : errors->setName("includeCommandLineAPI");
1707 545 : in_includeCommandLineAPI = ValueConversions<bool>::fromValue(includeCommandLineAPIValue, errors);
1708 : }
1709 17006 : protocol::Value* silentValue = object ? object->get("silent") : nullptr;
1710 : Maybe<bool> in_silent;
1711 8503 : if (silentValue) {
1712 20 : errors->setName("silent");
1713 20 : in_silent = ValueConversions<bool>::fromValue(silentValue, errors);
1714 : }
1715 17006 : protocol::Value* contextIdValue = object ? object->get("contextId") : nullptr;
1716 : Maybe<int> in_contextId;
1717 8503 : if (contextIdValue) {
1718 5 : errors->setName("contextId");
1719 5 : in_contextId = ValueConversions<int>::fromValue(contextIdValue, errors);
1720 : }
1721 17006 : protocol::Value* returnByValueValue = object ? object->get("returnByValue") : nullptr;
1722 : Maybe<bool> in_returnByValue;
1723 8503 : if (returnByValueValue) {
1724 250 : errors->setName("returnByValue");
1725 250 : in_returnByValue = ValueConversions<bool>::fromValue(returnByValueValue, errors);
1726 : }
1727 17006 : protocol::Value* generatePreviewValue = object ? object->get("generatePreview") : nullptr;
1728 : Maybe<bool> in_generatePreview;
1729 8503 : if (generatePreviewValue) {
1730 590 : errors->setName("generatePreview");
1731 590 : in_generatePreview = ValueConversions<bool>::fromValue(generatePreviewValue, errors);
1732 : }
1733 17006 : protocol::Value* userGestureValue = object ? object->get("userGesture") : nullptr;
1734 : Maybe<bool> in_userGesture;
1735 8503 : if (userGestureValue) {
1736 0 : errors->setName("userGesture");
1737 0 : in_userGesture = ValueConversions<bool>::fromValue(userGestureValue, errors);
1738 : }
1739 17006 : protocol::Value* awaitPromiseValue = object ? object->get("awaitPromise") : nullptr;
1740 : Maybe<bool> in_awaitPromise;
1741 8503 : if (awaitPromiseValue) {
1742 685 : errors->setName("awaitPromise");
1743 685 : in_awaitPromise = ValueConversions<bool>::fromValue(awaitPromiseValue, errors);
1744 : }
1745 17006 : protocol::Value* throwOnSideEffectValue = object ? object->get("throwOnSideEffect") : nullptr;
1746 : Maybe<bool> in_throwOnSideEffect;
1747 8503 : if (throwOnSideEffectValue) {
1748 512 : errors->setName("throwOnSideEffect");
1749 512 : in_throwOnSideEffect = ValueConversions<bool>::fromValue(throwOnSideEffectValue, errors);
1750 : }
1751 17006 : protocol::Value* timeoutValue = object ? object->get("timeout") : nullptr;
1752 : Maybe<double> in_timeout;
1753 8503 : if (timeoutValue) {
1754 15 : errors->setName("timeout");
1755 15 : in_timeout = ValueConversions<double>::fromValue(timeoutValue, errors);
1756 : }
1757 8503 : errors->pop();
1758 8503 : if (errors->hasErrors()) {
1759 10 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1760 5 : return;
1761 : }
1762 :
1763 8498 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1764 16996 : std::unique_ptr<EvaluateCallbackImpl> callback(new EvaluateCallbackImpl(weakPtr(), callId, method, message));
1765 33992 : m_backend->evaluate(in_expression, std::move(in_objectGroup), std::move(in_includeCommandLineAPI), std::move(in_silent), std::move(in_contextId), std::move(in_returnByValue), std::move(in_generatePreview), std::move(in_userGesture), std::move(in_awaitPromise), std::move(in_throwOnSideEffect), std::move(in_timeout), std::move(callback));
1766 : return;
1767 : }
1768 :
1769 5 : void DispatcherImpl::getIsolateId(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1770 : {
1771 : // Declare output parameters.
1772 : String out_id;
1773 :
1774 5 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1775 5 : DispatchResponse response = m_backend->getIsolateId(&out_id);
1776 5 : if (response.status() == DispatchResponse::kFallThrough) {
1777 0 : channel()->fallThrough(callId, method, message);
1778 0 : return;
1779 : }
1780 5 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1781 5 : if (response.status() == DispatchResponse::kSuccess) {
1782 20 : result->setValue("id", ValueConversions<String>::toValue(out_id));
1783 : }
1784 5 : if (weak->get())
1785 10 : weak->get()->sendResponse(callId, response, std::move(result));
1786 : return;
1787 : }
1788 :
1789 5 : void DispatcherImpl::getHeapUsage(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1790 : {
1791 : // Declare output parameters.
1792 : double out_usedSize;
1793 : double out_totalSize;
1794 :
1795 5 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1796 5 : DispatchResponse response = m_backend->getHeapUsage(&out_usedSize, &out_totalSize);
1797 5 : if (response.status() == DispatchResponse::kFallThrough) {
1798 0 : channel()->fallThrough(callId, method, message);
1799 0 : return;
1800 : }
1801 5 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1802 5 : if (response.status() == DispatchResponse::kSuccess) {
1803 25 : result->setValue("usedSize", ValueConversions<double>::toValue(out_usedSize));
1804 25 : result->setValue("totalSize", ValueConversions<double>::toValue(out_totalSize));
1805 : }
1806 5 : if (weak->get())
1807 10 : weak->get()->sendResponse(callId, response, std::move(result));
1808 : return;
1809 : }
1810 :
1811 68298 : void DispatcherImpl::getProperties(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1812 : {
1813 : // Prepare input parameters.
1814 204894 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1815 68298 : errors->push();
1816 136596 : protocol::Value* objectIdValue = object ? object->get("objectId") : nullptr;
1817 68298 : errors->setName("objectId");
1818 68298 : String in_objectId = ValueConversions<String>::fromValue(objectIdValue, errors);
1819 136596 : protocol::Value* ownPropertiesValue = object ? object->get("ownProperties") : nullptr;
1820 : Maybe<bool> in_ownProperties;
1821 68298 : if (ownPropertiesValue) {
1822 67598 : errors->setName("ownProperties");
1823 67598 : in_ownProperties = ValueConversions<bool>::fromValue(ownPropertiesValue, errors);
1824 : }
1825 136596 : protocol::Value* accessorPropertiesOnlyValue = object ? object->get("accessorPropertiesOnly") : nullptr;
1826 : Maybe<bool> in_accessorPropertiesOnly;
1827 68298 : if (accessorPropertiesOnlyValue) {
1828 5 : errors->setName("accessorPropertiesOnly");
1829 5 : in_accessorPropertiesOnly = ValueConversions<bool>::fromValue(accessorPropertiesOnlyValue, errors);
1830 : }
1831 136596 : protocol::Value* generatePreviewValue = object ? object->get("generatePreview") : nullptr;
1832 : Maybe<bool> in_generatePreview;
1833 68298 : if (generatePreviewValue) {
1834 25 : errors->setName("generatePreview");
1835 25 : in_generatePreview = ValueConversions<bool>::fromValue(generatePreviewValue, errors);
1836 : }
1837 68298 : errors->pop();
1838 68298 : if (errors->hasErrors()) {
1839 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1840 0 : return;
1841 : }
1842 : // Declare output parameters.
1843 68298 : std::unique_ptr<protocol::Array<protocol::Runtime::PropertyDescriptor>> out_result;
1844 : Maybe<protocol::Array<protocol::Runtime::InternalPropertyDescriptor>> out_internalProperties;
1845 : Maybe<protocol::Runtime::ExceptionDetails> out_exceptionDetails;
1846 :
1847 68298 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1848 136596 : DispatchResponse response = m_backend->getProperties(in_objectId, std::move(in_ownProperties), std::move(in_accessorPropertiesOnly), std::move(in_generatePreview), &out_result, &out_internalProperties, &out_exceptionDetails);
1849 68298 : if (response.status() == DispatchResponse::kFallThrough) {
1850 0 : channel()->fallThrough(callId, method, message);
1851 0 : return;
1852 : }
1853 68298 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1854 68298 : if (response.status() == DispatchResponse::kSuccess) {
1855 273192 : result->setValue("result", ValueConversions<protocol::Array<protocol::Runtime::PropertyDescriptor>>::toValue(out_result.get()));
1856 68298 : if (out_internalProperties.isJust())
1857 1768 : result->setValue("internalProperties", ValueConversions<protocol::Array<protocol::Runtime::InternalPropertyDescriptor>>::toValue(out_internalProperties.fromJust()));
1858 68298 : if (out_exceptionDetails.isJust())
1859 0 : result->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(out_exceptionDetails.fromJust()));
1860 : }
1861 68298 : if (weak->get())
1862 136596 : weak->get()->sendResponse(callId, response, std::move(result));
1863 : return;
1864 : }
1865 :
1866 35 : void DispatcherImpl::globalLexicalScopeNames(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1867 : {
1868 : // Prepare input parameters.
1869 105 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1870 35 : errors->push();
1871 70 : protocol::Value* executionContextIdValue = object ? object->get("executionContextId") : nullptr;
1872 : Maybe<int> in_executionContextId;
1873 35 : if (executionContextIdValue) {
1874 0 : errors->setName("executionContextId");
1875 0 : in_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
1876 : }
1877 35 : errors->pop();
1878 35 : if (errors->hasErrors()) {
1879 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1880 0 : return;
1881 : }
1882 : // Declare output parameters.
1883 35 : std::unique_ptr<protocol::Array<String>> out_names;
1884 :
1885 35 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1886 70 : DispatchResponse response = m_backend->globalLexicalScopeNames(std::move(in_executionContextId), &out_names);
1887 35 : if (response.status() == DispatchResponse::kFallThrough) {
1888 0 : channel()->fallThrough(callId, method, message);
1889 0 : return;
1890 : }
1891 35 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1892 35 : if (response.status() == DispatchResponse::kSuccess) {
1893 140 : result->setValue("names", ValueConversions<protocol::Array<String>>::toValue(out_names.get()));
1894 : }
1895 35 : if (weak->get())
1896 70 : weak->get()->sendResponse(callId, response, std::move(result));
1897 : return;
1898 : }
1899 :
1900 85 : void DispatcherImpl::queryObjects(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1901 : {
1902 : // Prepare input parameters.
1903 255 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1904 85 : errors->push();
1905 170 : protocol::Value* prototypeObjectIdValue = object ? object->get("prototypeObjectId") : nullptr;
1906 85 : errors->setName("prototypeObjectId");
1907 85 : String in_prototypeObjectId = ValueConversions<String>::fromValue(prototypeObjectIdValue, errors);
1908 170 : protocol::Value* objectGroupValue = object ? object->get("objectGroup") : nullptr;
1909 : Maybe<String> in_objectGroup;
1910 85 : if (objectGroupValue) {
1911 20 : errors->setName("objectGroup");
1912 40 : in_objectGroup = ValueConversions<String>::fromValue(objectGroupValue, errors);
1913 : }
1914 85 : errors->pop();
1915 85 : if (errors->hasErrors()) {
1916 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1917 0 : return;
1918 : }
1919 : // Declare output parameters.
1920 85 : std::unique_ptr<protocol::Runtime::RemoteObject> out_objects;
1921 :
1922 85 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1923 255 : DispatchResponse response = m_backend->queryObjects(in_prototypeObjectId, std::move(in_objectGroup), &out_objects);
1924 85 : if (response.status() == DispatchResponse::kFallThrough) {
1925 0 : channel()->fallThrough(callId, method, message);
1926 0 : return;
1927 : }
1928 85 : std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
1929 85 : if (response.status() == DispatchResponse::kSuccess) {
1930 340 : result->setValue("objects", ValueConversions<protocol::Runtime::RemoteObject>::toValue(out_objects.get()));
1931 : }
1932 85 : if (weak->get())
1933 170 : weak->get()->sendResponse(callId, response, std::move(result));
1934 : return;
1935 : }
1936 :
1937 5 : void DispatcherImpl::releaseObject(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1938 : {
1939 : // Prepare input parameters.
1940 15 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1941 5 : errors->push();
1942 10 : protocol::Value* objectIdValue = object ? object->get("objectId") : nullptr;
1943 5 : errors->setName("objectId");
1944 5 : String in_objectId = ValueConversions<String>::fromValue(objectIdValue, errors);
1945 5 : errors->pop();
1946 5 : if (errors->hasErrors()) {
1947 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1948 0 : return;
1949 : }
1950 :
1951 5 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1952 5 : DispatchResponse response = m_backend->releaseObject(in_objectId);
1953 5 : if (response.status() == DispatchResponse::kFallThrough) {
1954 0 : channel()->fallThrough(callId, method, message);
1955 0 : return;
1956 : }
1957 5 : if (weak->get())
1958 5 : weak->get()->sendResponse(callId, response);
1959 : return;
1960 : }
1961 :
1962 5 : void DispatcherImpl::releaseObjectGroup(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1963 : {
1964 : // Prepare input parameters.
1965 15 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
1966 5 : errors->push();
1967 10 : protocol::Value* objectGroupValue = object ? object->get("objectGroup") : nullptr;
1968 5 : errors->setName("objectGroup");
1969 5 : String in_objectGroup = ValueConversions<String>::fromValue(objectGroupValue, errors);
1970 5 : errors->pop();
1971 5 : if (errors->hasErrors()) {
1972 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
1973 0 : return;
1974 : }
1975 :
1976 5 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1977 5 : DispatchResponse response = m_backend->releaseObjectGroup(in_objectGroup);
1978 5 : if (response.status() == DispatchResponse::kFallThrough) {
1979 0 : channel()->fallThrough(callId, method, message);
1980 0 : return;
1981 : }
1982 5 : if (weak->get())
1983 5 : weak->get()->sendResponse(callId, response);
1984 : return;
1985 : }
1986 :
1987 0 : void DispatcherImpl::runIfWaitingForDebugger(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
1988 : {
1989 :
1990 0 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
1991 0 : DispatchResponse response = m_backend->runIfWaitingForDebugger();
1992 0 : if (response.status() == DispatchResponse::kFallThrough) {
1993 0 : channel()->fallThrough(callId, method, message);
1994 0 : return;
1995 : }
1996 0 : if (weak->get())
1997 0 : weak->get()->sendResponse(callId, response);
1998 : return;
1999 : }
2000 :
2001 364 : class RunScriptCallbackImpl : public Backend::RunScriptCallback, public DispatcherBase::Callback {
2002 : public:
2003 182 : RunScriptCallbackImpl(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId, const String& method, const ProtocolMessage& message)
2004 364 : : DispatcherBase::Callback(std::move(backendImpl), callId, method, message) { }
2005 :
2006 162 : void sendSuccess(std::unique_ptr<protocol::Runtime::RemoteObject> result, Maybe<protocol::Runtime::ExceptionDetails> exceptionDetails) override
2007 : {
2008 162 : std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
2009 648 : resultObject->setValue("result", ValueConversions<protocol::Runtime::RemoteObject>::toValue(result.get()));
2010 162 : if (exceptionDetails.isJust())
2011 40 : resultObject->setValue("exceptionDetails", ValueConversions<protocol::Runtime::ExceptionDetails>::toValue(exceptionDetails.fromJust()));
2012 648 : sendIfActive(std::move(resultObject), DispatchResponse::OK());
2013 162 : }
2014 :
2015 0 : void fallThrough() override
2016 : {
2017 0 : fallThroughIfActive();
2018 0 : }
2019 :
2020 20 : void sendFailure(const DispatchResponse& response) override
2021 : {
2022 : DCHECK(response.status() == DispatchResponse::kError);
2023 40 : sendIfActive(nullptr, response);
2024 20 : }
2025 : };
2026 :
2027 182 : void DispatcherImpl::runScript(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
2028 : {
2029 : // Prepare input parameters.
2030 546 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
2031 182 : errors->push();
2032 364 : protocol::Value* scriptIdValue = object ? object->get("scriptId") : nullptr;
2033 182 : errors->setName("scriptId");
2034 182 : String in_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
2035 364 : protocol::Value* executionContextIdValue = object ? object->get("executionContextId") : nullptr;
2036 : Maybe<int> in_executionContextId;
2037 182 : if (executionContextIdValue) {
2038 0 : errors->setName("executionContextId");
2039 0 : in_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
2040 : }
2041 364 : protocol::Value* objectGroupValue = object ? object->get("objectGroup") : nullptr;
2042 : Maybe<String> in_objectGroup;
2043 182 : if (objectGroupValue) {
2044 0 : errors->setName("objectGroup");
2045 0 : in_objectGroup = ValueConversions<String>::fromValue(objectGroupValue, errors);
2046 : }
2047 364 : protocol::Value* silentValue = object ? object->get("silent") : nullptr;
2048 : Maybe<bool> in_silent;
2049 182 : if (silentValue) {
2050 0 : errors->setName("silent");
2051 0 : in_silent = ValueConversions<bool>::fromValue(silentValue, errors);
2052 : }
2053 364 : protocol::Value* includeCommandLineAPIValue = object ? object->get("includeCommandLineAPI") : nullptr;
2054 : Maybe<bool> in_includeCommandLineAPI;
2055 182 : if (includeCommandLineAPIValue) {
2056 0 : errors->setName("includeCommandLineAPI");
2057 0 : in_includeCommandLineAPI = ValueConversions<bool>::fromValue(includeCommandLineAPIValue, errors);
2058 : }
2059 364 : protocol::Value* returnByValueValue = object ? object->get("returnByValue") : nullptr;
2060 : Maybe<bool> in_returnByValue;
2061 182 : if (returnByValueValue) {
2062 20 : errors->setName("returnByValue");
2063 20 : in_returnByValue = ValueConversions<bool>::fromValue(returnByValueValue, errors);
2064 : }
2065 364 : protocol::Value* generatePreviewValue = object ? object->get("generatePreview") : nullptr;
2066 : Maybe<bool> in_generatePreview;
2067 182 : if (generatePreviewValue) {
2068 5 : errors->setName("generatePreview");
2069 5 : in_generatePreview = ValueConversions<bool>::fromValue(generatePreviewValue, errors);
2070 : }
2071 364 : protocol::Value* awaitPromiseValue = object ? object->get("awaitPromise") : nullptr;
2072 : Maybe<bool> in_awaitPromise;
2073 182 : if (awaitPromiseValue) {
2074 15 : errors->setName("awaitPromise");
2075 15 : in_awaitPromise = ValueConversions<bool>::fromValue(awaitPromiseValue, errors);
2076 : }
2077 182 : errors->pop();
2078 182 : if (errors->hasErrors()) {
2079 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
2080 0 : return;
2081 : }
2082 :
2083 182 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
2084 364 : std::unique_ptr<RunScriptCallbackImpl> callback(new RunScriptCallbackImpl(weakPtr(), callId, method, message));
2085 728 : m_backend->runScript(in_scriptId, std::move(in_executionContextId), std::move(in_objectGroup), std::move(in_silent), std::move(in_includeCommandLineAPI), std::move(in_returnByValue), std::move(in_generatePreview), std::move(in_awaitPromise), std::move(callback));
2086 : return;
2087 : }
2088 :
2089 10 : void DispatcherImpl::setCustomObjectFormatterEnabled(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
2090 : {
2091 : // Prepare input parameters.
2092 30 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
2093 10 : errors->push();
2094 20 : protocol::Value* enabledValue = object ? object->get("enabled") : nullptr;
2095 10 : errors->setName("enabled");
2096 10 : bool in_enabled = ValueConversions<bool>::fromValue(enabledValue, errors);
2097 10 : errors->pop();
2098 10 : if (errors->hasErrors()) {
2099 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
2100 0 : return;
2101 : }
2102 :
2103 10 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
2104 10 : DispatchResponse response = m_backend->setCustomObjectFormatterEnabled(in_enabled);
2105 10 : if (response.status() == DispatchResponse::kFallThrough) {
2106 0 : channel()->fallThrough(callId, method, message);
2107 0 : return;
2108 : }
2109 10 : if (weak->get())
2110 10 : weak->get()->sendResponse(callId, response);
2111 : return;
2112 : }
2113 :
2114 15 : void DispatcherImpl::setMaxCallStackSizeToCapture(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
2115 : {
2116 : // Prepare input parameters.
2117 45 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
2118 15 : errors->push();
2119 30 : protocol::Value* sizeValue = object ? object->get("size") : nullptr;
2120 15 : errors->setName("size");
2121 15 : int in_size = ValueConversions<int>::fromValue(sizeValue, errors);
2122 15 : errors->pop();
2123 15 : if (errors->hasErrors()) {
2124 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
2125 0 : return;
2126 : }
2127 :
2128 15 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
2129 15 : DispatchResponse response = m_backend->setMaxCallStackSizeToCapture(in_size);
2130 15 : if (response.status() == DispatchResponse::kFallThrough) {
2131 0 : channel()->fallThrough(callId, method, message);
2132 0 : return;
2133 : }
2134 15 : if (weak->get())
2135 15 : weak->get()->sendResponse(callId, response);
2136 : return;
2137 : }
2138 :
2139 80 : class TerminateExecutionCallbackImpl : public Backend::TerminateExecutionCallback, public DispatcherBase::Callback {
2140 : public:
2141 40 : TerminateExecutionCallbackImpl(std::unique_ptr<DispatcherBase::WeakPtr> backendImpl, int callId, const String& method, const ProtocolMessage& message)
2142 80 : : DispatcherBase::Callback(std::move(backendImpl), callId, method, message) { }
2143 :
2144 40 : void sendSuccess() override
2145 : {
2146 40 : std::unique_ptr<protocol::DictionaryValue> resultObject = DictionaryValue::create();
2147 160 : sendIfActive(std::move(resultObject), DispatchResponse::OK());
2148 40 : }
2149 :
2150 0 : void fallThrough() override
2151 : {
2152 0 : fallThroughIfActive();
2153 0 : }
2154 :
2155 0 : void sendFailure(const DispatchResponse& response) override
2156 : {
2157 : DCHECK(response.status() == DispatchResponse::kError);
2158 0 : sendIfActive(nullptr, response);
2159 0 : }
2160 : };
2161 :
2162 40 : void DispatcherImpl::terminateExecution(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
2163 : {
2164 :
2165 40 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
2166 80 : std::unique_ptr<TerminateExecutionCallbackImpl> callback(new TerminateExecutionCallbackImpl(weakPtr(), callId, method, message));
2167 120 : m_backend->terminateExecution(std::move(callback));
2168 40 : return;
2169 : }
2170 :
2171 25 : void DispatcherImpl::addBinding(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
2172 : {
2173 : // Prepare input parameters.
2174 75 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
2175 25 : errors->push();
2176 50 : protocol::Value* nameValue = object ? object->get("name") : nullptr;
2177 25 : errors->setName("name");
2178 25 : String in_name = ValueConversions<String>::fromValue(nameValue, errors);
2179 50 : protocol::Value* executionContextIdValue = object ? object->get("executionContextId") : nullptr;
2180 : Maybe<int> in_executionContextId;
2181 25 : if (executionContextIdValue) {
2182 0 : errors->setName("executionContextId");
2183 0 : in_executionContextId = ValueConversions<int>::fromValue(executionContextIdValue, errors);
2184 : }
2185 25 : errors->pop();
2186 25 : if (errors->hasErrors()) {
2187 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
2188 0 : return;
2189 : }
2190 :
2191 25 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
2192 50 : DispatchResponse response = m_backend->addBinding(in_name, std::move(in_executionContextId));
2193 25 : if (response.status() == DispatchResponse::kFallThrough) {
2194 0 : channel()->fallThrough(callId, method, message);
2195 0 : return;
2196 : }
2197 25 : if (weak->get())
2198 25 : weak->get()->sendResponse(callId, response);
2199 : return;
2200 : }
2201 :
2202 5 : void DispatcherImpl::removeBinding(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
2203 : {
2204 : // Prepare input parameters.
2205 15 : protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
2206 5 : errors->push();
2207 10 : protocol::Value* nameValue = object ? object->get("name") : nullptr;
2208 5 : errors->setName("name");
2209 5 : String in_name = ValueConversions<String>::fromValue(nameValue, errors);
2210 5 : errors->pop();
2211 5 : if (errors->hasErrors()) {
2212 0 : reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
2213 0 : return;
2214 : }
2215 :
2216 5 : std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
2217 5 : DispatchResponse response = m_backend->removeBinding(in_name);
2218 5 : if (response.status() == DispatchResponse::kFallThrough) {
2219 0 : channel()->fallThrough(callId, method, message);
2220 0 : return;
2221 : }
2222 5 : if (weak->get())
2223 5 : weak->get()->sendResponse(callId, response);
2224 : return;
2225 : }
2226 :
2227 : // static
2228 3832 : void Dispatcher::wire(UberDispatcher* uber, Backend* backend)
2229 : {
2230 3832 : std::unique_ptr<DispatcherImpl> dispatcher(new DispatcherImpl(uber->channel(), backend));
2231 3832 : uber->setupRedirects(dispatcher->redirects());
2232 11496 : uber->registerBackend("Runtime", std::move(dispatcher));
2233 3832 : }
2234 :
2235 : } // Runtime
2236 : } // namespace v8_inspector
2237 : } // namespace protocol
|