LCOV - code coverage report
Current view: top level - out/Release/gen/src/inspector/protocol - Debugger.cpp (source / functions) Hit Total Coverage
Test: app.info Lines: 645 1103 58.5 %
Date: 2019-04-17 Functions: 48 76 63.2 %

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

Generated by: LCOV version 1.10