LCOV - code coverage report
Current view: top level - out/Release/gen/src/inspector/protocol - Profiler.cpp (source / functions) Hit Total Coverage
Test: app.info Lines: 222 470 47.2 %
Date: 2017-10-20 Functions: 29 54 53.7 %

          Line data    Source code
       1             : // This file is generated
       2             : 
       3             : // Copyright (c) 2016 The Chromium Authors. All rights reserved.
       4             : // Use of this source code is governed by a BSD-style license that can be
       5             : // found in the LICENSE file.
       6             : 
       7             : #include "src/inspector/protocol/Profiler.h"
       8             : 
       9             : #include "src/inspector/protocol/Protocol.h"
      10             : 
      11             : namespace v8_inspector {
      12             : namespace protocol {
      13             : namespace Profiler {
      14             : 
      15             : // ------------- Enum values from types.
      16             : 
      17             : const char Metainfo::domainName[] = "Profiler";
      18             : const char Metainfo::commandPrefix[] = "Profiler.";
      19             : const char Metainfo::version[] = "1.2";
      20             : 
      21           0 : std::unique_ptr<ProfileNode> ProfileNode::fromValue(protocol::Value* value, ErrorSupport* errors)
      22             : {
      23           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
      24           0 :         errors->addError("object expected");
      25             :         return nullptr;
      26             :     }
      27             : 
      28           0 :     std::unique_ptr<ProfileNode> result(new ProfileNode());
      29             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
      30           0 :     errors->push();
      31           0 :     protocol::Value* idValue = object->get("id");
      32           0 :     errors->setName("id");
      33           0 :     result->m_id = ValueConversions<int>::fromValue(idValue, errors);
      34           0 :     protocol::Value* callFrameValue = object->get("callFrame");
      35           0 :     errors->setName("callFrame");
      36           0 :     result->m_callFrame = ValueConversions<protocol::Runtime::CallFrame>::fromValue(callFrameValue, errors);
      37           0 :     protocol::Value* hitCountValue = object->get("hitCount");
      38           0 :     if (hitCountValue) {
      39           0 :         errors->setName("hitCount");
      40           0 :         result->m_hitCount = ValueConversions<int>::fromValue(hitCountValue, errors);
      41             :     }
      42           0 :     protocol::Value* childrenValue = object->get("children");
      43           0 :     if (childrenValue) {
      44           0 :         errors->setName("children");
      45           0 :         result->m_children = ValueConversions<protocol::Array<int>>::fromValue(childrenValue, errors);
      46             :     }
      47           0 :     protocol::Value* deoptReasonValue = object->get("deoptReason");
      48           0 :     if (deoptReasonValue) {
      49           0 :         errors->setName("deoptReason");
      50           0 :         result->m_deoptReason = ValueConversions<String>::fromValue(deoptReasonValue, errors);
      51             :     }
      52           0 :     protocol::Value* positionTicksValue = object->get("positionTicks");
      53           0 :     if (positionTicksValue) {
      54           0 :         errors->setName("positionTicks");
      55           0 :         result->m_positionTicks = ValueConversions<protocol::Array<protocol::Profiler::PositionTickInfo>>::fromValue(positionTicksValue, errors);
      56             :     }
      57           0 :     errors->pop();
      58           0 :     if (errors->hasErrors())
      59             :         return nullptr;
      60             :     return result;
      61             : }
      62             : 
      63          93 : std::unique_ptr<protocol::DictionaryValue> ProfileNode::toValue() const
      64             : {
      65          93 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
      66         465 :     result->setValue("id", ValueConversions<int>::toValue(m_id));
      67         372 :     result->setValue("callFrame", ValueConversions<protocol::Runtime::CallFrame>::toValue(m_callFrame.get()));
      68          93 :     if (m_hitCount.isJust())
      69         372 :         result->setValue("hitCount", ValueConversions<int>::toValue(m_hitCount.fromJust()));
      70          93 :     if (m_children.isJust())
      71         184 :         result->setValue("children", ValueConversions<protocol::Array<int>>::toValue(m_children.fromJust()));
      72          93 :     if (m_deoptReason.isJust())
      73           0 :         result->setValue("deoptReason", ValueConversions<String>::toValue(m_deoptReason.fromJust()));
      74          93 :     if (m_positionTicks.isJust())
      75          64 :         result->setValue("positionTicks", ValueConversions<protocol::Array<protocol::Profiler::PositionTickInfo>>::toValue(m_positionTicks.fromJust()));
      76          93 :     return result;
      77             : }
      78             : 
      79           0 : std::unique_ptr<ProfileNode> ProfileNode::clone() const
      80             : {
      81           0 :     ErrorSupport errors;
      82           0 :     return fromValue(toValue().get(), &errors);
      83             : }
      84             : 
      85           0 : std::unique_ptr<Profile> Profile::fromValue(protocol::Value* value, ErrorSupport* errors)
      86             : {
      87           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
      88           0 :         errors->addError("object expected");
      89             :         return nullptr;
      90             :     }
      91             : 
      92           0 :     std::unique_ptr<Profile> result(new Profile());
      93             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
      94           0 :     errors->push();
      95           0 :     protocol::Value* nodesValue = object->get("nodes");
      96           0 :     errors->setName("nodes");
      97           0 :     result->m_nodes = ValueConversions<protocol::Array<protocol::Profiler::ProfileNode>>::fromValue(nodesValue, errors);
      98           0 :     protocol::Value* startTimeValue = object->get("startTime");
      99           0 :     errors->setName("startTime");
     100           0 :     result->m_startTime = ValueConversions<double>::fromValue(startTimeValue, errors);
     101           0 :     protocol::Value* endTimeValue = object->get("endTime");
     102           0 :     errors->setName("endTime");
     103           0 :     result->m_endTime = ValueConversions<double>::fromValue(endTimeValue, errors);
     104           0 :     protocol::Value* samplesValue = object->get("samples");
     105           0 :     if (samplesValue) {
     106           0 :         errors->setName("samples");
     107           0 :         result->m_samples = ValueConversions<protocol::Array<int>>::fromValue(samplesValue, errors);
     108             :     }
     109           0 :     protocol::Value* timeDeltasValue = object->get("timeDeltas");
     110           0 :     if (timeDeltasValue) {
     111           0 :         errors->setName("timeDeltas");
     112           0 :         result->m_timeDeltas = ValueConversions<protocol::Array<int>>::fromValue(timeDeltasValue, errors);
     113             :     }
     114           0 :     errors->pop();
     115           0 :     if (errors->hasErrors())
     116             :         return nullptr;
     117             :     return result;
     118             : }
     119             : 
     120          29 : std::unique_ptr<protocol::DictionaryValue> Profile::toValue() const
     121             : {
     122          29 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     123         116 :     result->setValue("nodes", ValueConversions<protocol::Array<protocol::Profiler::ProfileNode>>::toValue(m_nodes.get()));
     124         145 :     result->setValue("startTime", ValueConversions<double>::toValue(m_startTime));
     125         145 :     result->setValue("endTime", ValueConversions<double>::toValue(m_endTime));
     126          29 :     if (m_samples.isJust())
     127         116 :         result->setValue("samples", ValueConversions<protocol::Array<int>>::toValue(m_samples.fromJust()));
     128          29 :     if (m_timeDeltas.isJust())
     129         116 :         result->setValue("timeDeltas", ValueConversions<protocol::Array<int>>::toValue(m_timeDeltas.fromJust()));
     130          29 :     return result;
     131             : }
     132             : 
     133           0 : std::unique_ptr<Profile> Profile::clone() const
     134             : {
     135           0 :     ErrorSupport errors;
     136           0 :     return fromValue(toValue().get(), &errors);
     137             : }
     138             : 
     139           0 : std::unique_ptr<PositionTickInfo> PositionTickInfo::fromValue(protocol::Value* value, ErrorSupport* errors)
     140             : {
     141           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     142           0 :         errors->addError("object expected");
     143             :         return nullptr;
     144             :     }
     145             : 
     146           0 :     std::unique_ptr<PositionTickInfo> result(new PositionTickInfo());
     147             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     148           0 :     errors->push();
     149           0 :     protocol::Value* lineValue = object->get("line");
     150           0 :     errors->setName("line");
     151           0 :     result->m_line = ValueConversions<int>::fromValue(lineValue, errors);
     152           0 :     protocol::Value* ticksValue = object->get("ticks");
     153           0 :     errors->setName("ticks");
     154           0 :     result->m_ticks = ValueConversions<int>::fromValue(ticksValue, errors);
     155           0 :     errors->pop();
     156           0 :     if (errors->hasErrors())
     157             :         return nullptr;
     158             :     return result;
     159             : }
     160             : 
     161          19 : std::unique_ptr<protocol::DictionaryValue> PositionTickInfo::toValue() const
     162             : {
     163          19 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     164          95 :     result->setValue("line", ValueConversions<int>::toValue(m_line));
     165          95 :     result->setValue("ticks", ValueConversions<int>::toValue(m_ticks));
     166          19 :     return result;
     167             : }
     168             : 
     169           0 : std::unique_ptr<PositionTickInfo> PositionTickInfo::clone() const
     170             : {
     171           0 :     ErrorSupport errors;
     172           0 :     return fromValue(toValue().get(), &errors);
     173             : }
     174             : 
     175           0 : std::unique_ptr<CoverageRange> CoverageRange::fromValue(protocol::Value* value, ErrorSupport* errors)
     176             : {
     177           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     178           0 :         errors->addError("object expected");
     179             :         return nullptr;
     180             :     }
     181             : 
     182           0 :     std::unique_ptr<CoverageRange> result(new CoverageRange());
     183             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     184           0 :     errors->push();
     185           0 :     protocol::Value* startOffsetValue = object->get("startOffset");
     186           0 :     errors->setName("startOffset");
     187           0 :     result->m_startOffset = ValueConversions<int>::fromValue(startOffsetValue, errors);
     188           0 :     protocol::Value* endOffsetValue = object->get("endOffset");
     189           0 :     errors->setName("endOffset");
     190           0 :     result->m_endOffset = ValueConversions<int>::fromValue(endOffsetValue, errors);
     191           0 :     protocol::Value* countValue = object->get("count");
     192           0 :     errors->setName("count");
     193           0 :     result->m_count = ValueConversions<int>::fromValue(countValue, errors);
     194           0 :     errors->pop();
     195           0 :     if (errors->hasErrors())
     196             :         return nullptr;
     197             :     return result;
     198             : }
     199             : 
     200         585 : std::unique_ptr<protocol::DictionaryValue> CoverageRange::toValue() const
     201             : {
     202         585 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     203        2925 :     result->setValue("startOffset", ValueConversions<int>::toValue(m_startOffset));
     204        2925 :     result->setValue("endOffset", ValueConversions<int>::toValue(m_endOffset));
     205        2925 :     result->setValue("count", ValueConversions<int>::toValue(m_count));
     206         585 :     return result;
     207             : }
     208             : 
     209           0 : std::unique_ptr<CoverageRange> CoverageRange::clone() const
     210             : {
     211           0 :     ErrorSupport errors;
     212           0 :     return fromValue(toValue().get(), &errors);
     213             : }
     214             : 
     215           0 : std::unique_ptr<FunctionCoverage> FunctionCoverage::fromValue(protocol::Value* value, ErrorSupport* errors)
     216             : {
     217           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     218           0 :         errors->addError("object expected");
     219             :         return nullptr;
     220             :     }
     221             : 
     222           0 :     std::unique_ptr<FunctionCoverage> result(new FunctionCoverage());
     223             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     224           0 :     errors->push();
     225           0 :     protocol::Value* functionNameValue = object->get("functionName");
     226           0 :     errors->setName("functionName");
     227           0 :     result->m_functionName = ValueConversions<String>::fromValue(functionNameValue, errors);
     228           0 :     protocol::Value* rangesValue = object->get("ranges");
     229           0 :     errors->setName("ranges");
     230           0 :     result->m_ranges = ValueConversions<protocol::Array<protocol::Profiler::CoverageRange>>::fromValue(rangesValue, errors);
     231           0 :     protocol::Value* isBlockCoverageValue = object->get("isBlockCoverage");
     232           0 :     errors->setName("isBlockCoverage");
     233           0 :     result->m_isBlockCoverage = ValueConversions<bool>::fromValue(isBlockCoverageValue, errors);
     234           0 :     errors->pop();
     235           0 :     if (errors->hasErrors())
     236             :         return nullptr;
     237             :     return result;
     238             : }
     239             : 
     240         475 : std::unique_ptr<protocol::DictionaryValue> FunctionCoverage::toValue() const
     241             : {
     242         475 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     243        2375 :     result->setValue("functionName", ValueConversions<String>::toValue(m_functionName));
     244        1900 :     result->setValue("ranges", ValueConversions<protocol::Array<protocol::Profiler::CoverageRange>>::toValue(m_ranges.get()));
     245        2375 :     result->setValue("isBlockCoverage", ValueConversions<bool>::toValue(m_isBlockCoverage));
     246         475 :     return result;
     247             : }
     248             : 
     249           0 : std::unique_ptr<FunctionCoverage> FunctionCoverage::clone() const
     250             : {
     251           0 :     ErrorSupport errors;
     252           0 :     return fromValue(toValue().get(), &errors);
     253             : }
     254             : 
     255           0 : std::unique_ptr<ScriptCoverage> ScriptCoverage::fromValue(protocol::Value* value, ErrorSupport* errors)
     256             : {
     257           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     258           0 :         errors->addError("object expected");
     259             :         return nullptr;
     260             :     }
     261             : 
     262           0 :     std::unique_ptr<ScriptCoverage> result(new ScriptCoverage());
     263             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     264           0 :     errors->push();
     265           0 :     protocol::Value* scriptIdValue = object->get("scriptId");
     266           0 :     errors->setName("scriptId");
     267           0 :     result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
     268           0 :     protocol::Value* urlValue = object->get("url");
     269           0 :     errors->setName("url");
     270           0 :     result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
     271           0 :     protocol::Value* functionsValue = object->get("functions");
     272           0 :     errors->setName("functions");
     273           0 :     result->m_functions = ValueConversions<protocol::Array<protocol::Profiler::FunctionCoverage>>::fromValue(functionsValue, errors);
     274           0 :     errors->pop();
     275           0 :     if (errors->hasErrors())
     276             :         return nullptr;
     277             :     return result;
     278             : }
     279             : 
     280         200 : std::unique_ptr<protocol::DictionaryValue> ScriptCoverage::toValue() const
     281             : {
     282         200 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     283        1000 :     result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
     284        1000 :     result->setValue("url", ValueConversions<String>::toValue(m_url));
     285         800 :     result->setValue("functions", ValueConversions<protocol::Array<protocol::Profiler::FunctionCoverage>>::toValue(m_functions.get()));
     286         200 :     return result;
     287             : }
     288             : 
     289           0 : std::unique_ptr<ScriptCoverage> ScriptCoverage::clone() const
     290             : {
     291           0 :     ErrorSupport errors;
     292           0 :     return fromValue(toValue().get(), &errors);
     293             : }
     294             : 
     295           0 : std::unique_ptr<TypeObject> TypeObject::fromValue(protocol::Value* value, ErrorSupport* errors)
     296             : {
     297           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     298           0 :         errors->addError("object expected");
     299             :         return nullptr;
     300             :     }
     301             : 
     302           0 :     std::unique_ptr<TypeObject> result(new TypeObject());
     303             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     304           0 :     errors->push();
     305           0 :     protocol::Value* nameValue = object->get("name");
     306           0 :     errors->setName("name");
     307           0 :     result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
     308           0 :     errors->pop();
     309           0 :     if (errors->hasErrors())
     310             :         return nullptr;
     311             :     return result;
     312             : }
     313             : 
     314         245 : std::unique_ptr<protocol::DictionaryValue> TypeObject::toValue() const
     315             : {
     316         245 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     317        1225 :     result->setValue("name", ValueConversions<String>::toValue(m_name));
     318         245 :     return result;
     319             : }
     320             : 
     321           0 : std::unique_ptr<TypeObject> TypeObject::clone() const
     322             : {
     323           0 :     ErrorSupport errors;
     324           0 :     return fromValue(toValue().get(), &errors);
     325             : }
     326             : 
     327           0 : std::unique_ptr<TypeProfileEntry> TypeProfileEntry::fromValue(protocol::Value* value, ErrorSupport* errors)
     328             : {
     329           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     330           0 :         errors->addError("object expected");
     331             :         return nullptr;
     332             :     }
     333             : 
     334           0 :     std::unique_ptr<TypeProfileEntry> result(new TypeProfileEntry());
     335             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     336           0 :     errors->push();
     337           0 :     protocol::Value* offsetValue = object->get("offset");
     338           0 :     errors->setName("offset");
     339           0 :     result->m_offset = ValueConversions<int>::fromValue(offsetValue, errors);
     340           0 :     protocol::Value* typesValue = object->get("types");
     341           0 :     errors->setName("types");
     342           0 :     result->m_types = ValueConversions<protocol::Array<protocol::Profiler::TypeObject>>::fromValue(typesValue, errors);
     343           0 :     errors->pop();
     344           0 :     if (errors->hasErrors())
     345             :         return nullptr;
     346             :     return result;
     347             : }
     348             : 
     349         185 : std::unique_ptr<protocol::DictionaryValue> TypeProfileEntry::toValue() const
     350             : {
     351         185 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     352         925 :     result->setValue("offset", ValueConversions<int>::toValue(m_offset));
     353         740 :     result->setValue("types", ValueConversions<protocol::Array<protocol::Profiler::TypeObject>>::toValue(m_types.get()));
     354         185 :     return result;
     355             : }
     356             : 
     357           0 : std::unique_ptr<TypeProfileEntry> TypeProfileEntry::clone() const
     358             : {
     359           0 :     ErrorSupport errors;
     360           0 :     return fromValue(toValue().get(), &errors);
     361             : }
     362             : 
     363           0 : std::unique_ptr<ScriptTypeProfile> ScriptTypeProfile::fromValue(protocol::Value* value, ErrorSupport* errors)
     364             : {
     365           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     366           0 :         errors->addError("object expected");
     367             :         return nullptr;
     368             :     }
     369             : 
     370           0 :     std::unique_ptr<ScriptTypeProfile> result(new ScriptTypeProfile());
     371             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     372           0 :     errors->push();
     373           0 :     protocol::Value* scriptIdValue = object->get("scriptId");
     374           0 :     errors->setName("scriptId");
     375           0 :     result->m_scriptId = ValueConversions<String>::fromValue(scriptIdValue, errors);
     376           0 :     protocol::Value* urlValue = object->get("url");
     377           0 :     errors->setName("url");
     378           0 :     result->m_url = ValueConversions<String>::fromValue(urlValue, errors);
     379           0 :     protocol::Value* entriesValue = object->get("entries");
     380           0 :     errors->setName("entries");
     381           0 :     result->m_entries = ValueConversions<protocol::Array<protocol::Profiler::TypeProfileEntry>>::fromValue(entriesValue, errors);
     382           0 :     errors->pop();
     383           0 :     if (errors->hasErrors())
     384             :         return nullptr;
     385             :     return result;
     386             : }
     387             : 
     388          40 : std::unique_ptr<protocol::DictionaryValue> ScriptTypeProfile::toValue() const
     389             : {
     390          40 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     391         200 :     result->setValue("scriptId", ValueConversions<String>::toValue(m_scriptId));
     392         200 :     result->setValue("url", ValueConversions<String>::toValue(m_url));
     393         160 :     result->setValue("entries", ValueConversions<protocol::Array<protocol::Profiler::TypeProfileEntry>>::toValue(m_entries.get()));
     394          40 :     return result;
     395             : }
     396             : 
     397           0 : std::unique_ptr<ScriptTypeProfile> ScriptTypeProfile::clone() const
     398             : {
     399           0 :     ErrorSupport errors;
     400           0 :     return fromValue(toValue().get(), &errors);
     401             : }
     402             : 
     403           0 : std::unique_ptr<ConsoleProfileStartedNotification> ConsoleProfileStartedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
     404             : {
     405           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     406           0 :         errors->addError("object expected");
     407             :         return nullptr;
     408             :     }
     409             : 
     410           0 :     std::unique_ptr<ConsoleProfileStartedNotification> result(new ConsoleProfileStartedNotification());
     411             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     412           0 :     errors->push();
     413           0 :     protocol::Value* idValue = object->get("id");
     414           0 :     errors->setName("id");
     415           0 :     result->m_id = ValueConversions<String>::fromValue(idValue, errors);
     416           0 :     protocol::Value* locationValue = object->get("location");
     417           0 :     errors->setName("location");
     418           0 :     result->m_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
     419           0 :     protocol::Value* titleValue = object->get("title");
     420           0 :     if (titleValue) {
     421           0 :         errors->setName("title");
     422           0 :         result->m_title = ValueConversions<String>::fromValue(titleValue, errors);
     423             :     }
     424           0 :     errors->pop();
     425           0 :     if (errors->hasErrors())
     426             :         return nullptr;
     427             :     return result;
     428             : }
     429             : 
     430          24 : std::unique_ptr<protocol::DictionaryValue> ConsoleProfileStartedNotification::toValue() const
     431             : {
     432          24 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     433         120 :     result->setValue("id", ValueConversions<String>::toValue(m_id));
     434          96 :     result->setValue("location", ValueConversions<protocol::Debugger::Location>::toValue(m_location.get()));
     435          24 :     if (m_title.isJust())
     436         120 :         result->setValue("title", ValueConversions<String>::toValue(m_title.fromJust()));
     437          24 :     return result;
     438             : }
     439             : 
     440           0 : std::unique_ptr<ConsoleProfileStartedNotification> ConsoleProfileStartedNotification::clone() const
     441             : {
     442           0 :     ErrorSupport errors;
     443           0 :     return fromValue(toValue().get(), &errors);
     444             : }
     445             : 
     446           0 : std::unique_ptr<ConsoleProfileFinishedNotification> ConsoleProfileFinishedNotification::fromValue(protocol::Value* value, ErrorSupport* errors)
     447             : {
     448           0 :     if (!value || value->type() != protocol::Value::TypeObject) {
     449           0 :         errors->addError("object expected");
     450             :         return nullptr;
     451             :     }
     452             : 
     453           0 :     std::unique_ptr<ConsoleProfileFinishedNotification> result(new ConsoleProfileFinishedNotification());
     454             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
     455           0 :     errors->push();
     456           0 :     protocol::Value* idValue = object->get("id");
     457           0 :     errors->setName("id");
     458           0 :     result->m_id = ValueConversions<String>::fromValue(idValue, errors);
     459           0 :     protocol::Value* locationValue = object->get("location");
     460           0 :     errors->setName("location");
     461           0 :     result->m_location = ValueConversions<protocol::Debugger::Location>::fromValue(locationValue, errors);
     462           0 :     protocol::Value* profileValue = object->get("profile");
     463           0 :     errors->setName("profile");
     464           0 :     result->m_profile = ValueConversions<protocol::Profiler::Profile>::fromValue(profileValue, errors);
     465           0 :     protocol::Value* titleValue = object->get("title");
     466           0 :     if (titleValue) {
     467           0 :         errors->setName("title");
     468           0 :         result->m_title = ValueConversions<String>::fromValue(titleValue, errors);
     469             :     }
     470           0 :     errors->pop();
     471           0 :     if (errors->hasErrors())
     472             :         return nullptr;
     473             :     return result;
     474             : }
     475             : 
     476          19 : std::unique_ptr<protocol::DictionaryValue> ConsoleProfileFinishedNotification::toValue() const
     477             : {
     478          19 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     479          95 :     result->setValue("id", ValueConversions<String>::toValue(m_id));
     480          76 :     result->setValue("location", ValueConversions<protocol::Debugger::Location>::toValue(m_location.get()));
     481          76 :     result->setValue("profile", ValueConversions<protocol::Profiler::Profile>::toValue(m_profile.get()));
     482          19 :     if (m_title.isJust())
     483          95 :         result->setValue("title", ValueConversions<String>::toValue(m_title.fromJust()));
     484          19 :     return result;
     485             : }
     486             : 
     487           0 : std::unique_ptr<ConsoleProfileFinishedNotification> ConsoleProfileFinishedNotification::clone() const
     488             : {
     489           0 :     ErrorSupport errors;
     490           0 :     return fromValue(toValue().get(), &errors);
     491             : }
     492             : 
     493             : // ------------- Enum values from params.
     494             : 
     495             : 
     496             : // ------------- Frontend notifications.
     497             : 
     498          24 : void Frontend::consoleProfileStarted(const String& id, std::unique_ptr<protocol::Debugger::Location> location, Maybe<String> title)
     499             : {
     500          24 :     if (!m_frontendChannel)
     501          24 :         return;
     502             :     std::unique_ptr<ConsoleProfileStartedNotification> messageData = ConsoleProfileStartedNotification::create()
     503          24 :         .setId(id)
     504             :         .setLocation(std::move(location))
     505             :         .build();
     506          24 :     if (title.isJust())
     507          48 :         messageData->setTitle(std::move(title).takeJust());
     508         168 :     m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Profiler.consoleProfileStarted", std::move(messageData)));
     509             : }
     510             : 
     511          19 : void Frontend::consoleProfileFinished(const String& id, std::unique_ptr<protocol::Debugger::Location> location, std::unique_ptr<protocol::Profiler::Profile> profile, Maybe<String> title)
     512             : {
     513          19 :     if (!m_frontendChannel)
     514          19 :         return;
     515             :     std::unique_ptr<ConsoleProfileFinishedNotification> messageData = ConsoleProfileFinishedNotification::create()
     516          19 :         .setId(id)
     517             :         .setLocation(std::move(location))
     518             :         .setProfile(std::move(profile))
     519             :         .build();
     520          19 :     if (title.isJust())
     521          38 :         messageData->setTitle(std::move(title).takeJust());
     522         133 :     m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("Profiler.consoleProfileFinished", std::move(messageData)));
     523             : }
     524             : 
     525           0 : void Frontend::flush()
     526             : {
     527           0 :     m_frontendChannel->flushProtocolNotifications();
     528           0 : }
     529             : 
     530           0 : void Frontend::sendRawNotification(const String& notification)
     531             : {
     532           0 :     m_frontendChannel->sendProtocolNotification(InternalRawNotification::create(notification));
     533           0 : }
     534             : 
     535             : // --------------------- Dispatcher.
     536             : 
     537             : class DispatcherImpl : public protocol::DispatcherBase {
     538             : public:
     539        3406 :     DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend, bool fallThroughForNotFound)
     540             :         : DispatcherBase(frontendChannel)
     541             :         , m_backend(backend)
     542       10218 :         , m_fallThroughForNotFound(fallThroughForNotFound) {
     543       10218 :         m_dispatchMap["Profiler.enable"] = &DispatcherImpl::enable;
     544       10218 :         m_dispatchMap["Profiler.disable"] = &DispatcherImpl::disable;
     545       10218 :         m_dispatchMap["Profiler.setSamplingInterval"] = &DispatcherImpl::setSamplingInterval;
     546       10218 :         m_dispatchMap["Profiler.start"] = &DispatcherImpl::start;
     547       10218 :         m_dispatchMap["Profiler.stop"] = &DispatcherImpl::stop;
     548       10218 :         m_dispatchMap["Profiler.startPreciseCoverage"] = &DispatcherImpl::startPreciseCoverage;
     549       10218 :         m_dispatchMap["Profiler.stopPreciseCoverage"] = &DispatcherImpl::stopPreciseCoverage;
     550       10218 :         m_dispatchMap["Profiler.takePreciseCoverage"] = &DispatcherImpl::takePreciseCoverage;
     551       10218 :         m_dispatchMap["Profiler.getBestEffortCoverage"] = &DispatcherImpl::getBestEffortCoverage;
     552       10218 :         m_dispatchMap["Profiler.startTypeProfile"] = &DispatcherImpl::startTypeProfile;
     553       10218 :         m_dispatchMap["Profiler.stopTypeProfile"] = &DispatcherImpl::stopTypeProfile;
     554       10218 :         m_dispatchMap["Profiler.takeTypeProfile"] = &DispatcherImpl::takeTypeProfile;
     555        3406 :     }
     556       10218 :     ~DispatcherImpl() override { }
     557             :     DispatchResponse::Status dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) override;
     558             :     HashMap<String, String>& redirects() { return m_redirects; }
     559             : 
     560             : protected:
     561             :     using CallHandler = DispatchResponse::Status (DispatcherImpl::*)(int callId, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
     562             :     using DispatchMap = protocol::HashMap<String, CallHandler>;
     563             :     DispatchMap m_dispatchMap;
     564             :     HashMap<String, String> m_redirects;
     565             : 
     566             :     DispatchResponse::Status enable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     567             :     DispatchResponse::Status disable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     568             :     DispatchResponse::Status setSamplingInterval(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     569             :     DispatchResponse::Status start(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     570             :     DispatchResponse::Status stop(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     571             :     DispatchResponse::Status startPreciseCoverage(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     572             :     DispatchResponse::Status stopPreciseCoverage(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     573             :     DispatchResponse::Status takePreciseCoverage(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     574             :     DispatchResponse::Status getBestEffortCoverage(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     575             :     DispatchResponse::Status startTypeProfile(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     576             :     DispatchResponse::Status stopTypeProfile(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     577             :     DispatchResponse::Status takeTypeProfile(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     578             : 
     579             :     Backend* m_backend;
     580             :     bool m_fallThroughForNotFound;
     581             : };
     582             : 
     583         922 : DispatchResponse::Status DispatcherImpl::dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject)
     584             : {
     585             :     protocol::HashMap<String, CallHandler>::iterator it = m_dispatchMap.find(method);
     586         922 :     if (it == m_dispatchMap.end()) {
     587           5 :         if (m_fallThroughForNotFound)
     588             :             return DispatchResponse::kFallThrough;
     589          20 :         reportProtocolError(callId, DispatchResponse::kMethodNotFound, "'" + method + "' wasn't found", nullptr);
     590           5 :         return DispatchResponse::kError;
     591             :     }
     592             : 
     593         917 :     protocol::ErrorSupport errors;
     594        2751 :     return (this->*(it->second))(callId, std::move(messageObject), &errors);
     595             : }
     596             : 
     597             : 
     598         177 : DispatchResponse::Status DispatcherImpl::enable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     599             : {
     600             : 
     601         177 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     602         177 :     DispatchResponse response = m_backend->enable();
     603         177 :     if (response.status() == DispatchResponse::kFallThrough)
     604             :         return response.status();
     605         177 :     if (weak->get())
     606         177 :         weak->get()->sendResponse(callId, response);
     607         177 :     return response.status();
     608             : }
     609             : 
     610         165 : DispatchResponse::Status DispatcherImpl::disable(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     611             : {
     612             : 
     613         165 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     614         165 :     DispatchResponse response = m_backend->disable();
     615         165 :     if (response.status() == DispatchResponse::kFallThrough)
     616             :         return response.status();
     617         165 :     if (weak->get())
     618         165 :         weak->get()->sendResponse(callId, response);
     619         165 :     return response.status();
     620             : }
     621             : 
     622           0 : DispatchResponse::Status DispatcherImpl::setSamplingInterval(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     623             : {
     624             :     // Prepare input parameters.
     625           0 :     protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
     626           0 :     errors->push();
     627           0 :     protocol::Value* intervalValue = object ? object->get("interval") : nullptr;
     628           0 :     errors->setName("interval");
     629           0 :     int in_interval = ValueConversions<int>::fromValue(intervalValue, errors);
     630           0 :     errors->pop();
     631           0 :     if (errors->hasErrors()) {
     632           0 :         reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
     633           0 :         return DispatchResponse::kError;
     634             :     }
     635             : 
     636           0 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     637           0 :     DispatchResponse response = m_backend->setSamplingInterval(in_interval);
     638           0 :     if (response.status() == DispatchResponse::kFallThrough)
     639             :         return response.status();
     640           0 :     if (weak->get())
     641           0 :         weak->get()->sendResponse(callId, response);
     642           0 :     return response.status();
     643             : }
     644             : 
     645          20 : DispatchResponse::Status DispatcherImpl::start(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     646             : {
     647             : 
     648          20 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     649          20 :     DispatchResponse response = m_backend->start();
     650          20 :     if (response.status() == DispatchResponse::kFallThrough)
     651             :         return response.status();
     652          20 :     if (weak->get())
     653          20 :         weak->get()->sendResponse(callId, response);
     654          20 :     return response.status();
     655             : }
     656             : 
     657          20 : DispatchResponse::Status DispatcherImpl::stop(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     658             : {
     659             :     // Declare output parameters.
     660          20 :     std::unique_ptr<protocol::Profiler::Profile> out_profile;
     661             : 
     662          20 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     663          20 :     DispatchResponse response = m_backend->stop(&out_profile);
     664          20 :     if (response.status() == DispatchResponse::kFallThrough)
     665             :         return response.status();
     666          20 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     667          20 :     if (response.status() == DispatchResponse::kSuccess) {
     668          40 :         result->setValue("profile", ValueConversions<protocol::Profiler::Profile>::toValue(out_profile.get()));
     669             :     }
     670          20 :     if (weak->get())
     671          40 :         weak->get()->sendResponse(callId, response, std::move(result));
     672          20 :     return response.status();
     673             : }
     674             : 
     675          85 : DispatchResponse::Status DispatcherImpl::startPreciseCoverage(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     676             : {
     677             :     // Prepare input parameters.
     678         255 :     protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params"));
     679          85 :     errors->push();
     680         170 :     protocol::Value* callCountValue = object ? object->get("callCount") : nullptr;
     681             :     Maybe<bool> in_callCount;
     682          85 :     if (callCountValue) {
     683          55 :         errors->setName("callCount");
     684          55 :         in_callCount = ValueConversions<bool>::fromValue(callCountValue, errors);
     685             :     }
     686         170 :     protocol::Value* detailedValue = object ? object->get("detailed") : nullptr;
     687             :     Maybe<bool> in_detailed;
     688          85 :     if (detailedValue) {
     689          85 :         errors->setName("detailed");
     690          85 :         in_detailed = ValueConversions<bool>::fromValue(detailedValue, errors);
     691             :     }
     692          85 :     errors->pop();
     693          85 :     if (errors->hasErrors()) {
     694           0 :         reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
     695           0 :         return DispatchResponse::kError;
     696             :     }
     697             : 
     698          85 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     699         170 :     DispatchResponse response = m_backend->startPreciseCoverage(std::move(in_callCount), std::move(in_detailed));
     700          85 :     if (response.status() == DispatchResponse::kFallThrough)
     701             :         return response.status();
     702          85 :     if (weak->get())
     703          85 :         weak->get()->sendResponse(callId, response);
     704          85 :     return response.status();
     705             : }
     706             : 
     707          85 : DispatchResponse::Status DispatcherImpl::stopPreciseCoverage(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     708             : {
     709             : 
     710          85 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     711          85 :     DispatchResponse response = m_backend->stopPreciseCoverage();
     712          85 :     if (response.status() == DispatchResponse::kFallThrough)
     713             :         return response.status();
     714          85 :     if (weak->get())
     715          85 :         weak->get()->sendResponse(callId, response);
     716          85 :     return response.status();
     717             : }
     718             : 
     719         120 : DispatchResponse::Status DispatcherImpl::takePreciseCoverage(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     720             : {
     721             :     // Declare output parameters.
     722         120 :     std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>> out_result;
     723             : 
     724         120 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     725         120 :     DispatchResponse response = m_backend->takePreciseCoverage(&out_result);
     726         120 :     if (response.status() == DispatchResponse::kFallThrough)
     727             :         return response.status();
     728         120 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     729         120 :     if (response.status() == DispatchResponse::kSuccess) {
     730         440 :         result->setValue("result", ValueConversions<protocol::Array<protocol::Profiler::ScriptCoverage>>::toValue(out_result.get()));
     731             :     }
     732         120 :     if (weak->get())
     733         240 :         weak->get()->sendResponse(callId, response, std::move(result));
     734         120 :     return response.status();
     735             : }
     736             : 
     737          60 : DispatchResponse::Status DispatcherImpl::getBestEffortCoverage(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     738             : {
     739             :     // Declare output parameters.
     740          60 :     std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>> out_result;
     741             : 
     742          60 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     743          60 :     DispatchResponse response = m_backend->getBestEffortCoverage(&out_result);
     744          60 :     if (response.status() == DispatchResponse::kFallThrough)
     745             :         return response.status();
     746          60 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     747          60 :     if (response.status() == DispatchResponse::kSuccess) {
     748         240 :         result->setValue("result", ValueConversions<protocol::Array<protocol::Profiler::ScriptCoverage>>::toValue(out_result.get()));
     749             :     }
     750          60 :     if (weak->get())
     751         120 :         weak->get()->sendResponse(callId, response, std::move(result));
     752          60 :     return response.status();
     753             : }
     754             : 
     755          65 : DispatchResponse::Status DispatcherImpl::startTypeProfile(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     756             : {
     757             : 
     758          65 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     759          65 :     DispatchResponse response = m_backend->startTypeProfile();
     760          65 :     if (response.status() == DispatchResponse::kFallThrough)
     761             :         return response.status();
     762          65 :     if (weak->get())
     763          65 :         weak->get()->sendResponse(callId, response);
     764          65 :     return response.status();
     765             : }
     766             : 
     767          60 : DispatchResponse::Status DispatcherImpl::stopTypeProfile(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     768             : {
     769             : 
     770          60 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     771          60 :     DispatchResponse response = m_backend->stopTypeProfile();
     772          60 :     if (response.status() == DispatchResponse::kFallThrough)
     773             :         return response.status();
     774          60 :     if (weak->get())
     775          60 :         weak->get()->sendResponse(callId, response);
     776          60 :     return response.status();
     777             : }
     778             : 
     779          60 : DispatchResponse::Status DispatcherImpl::takeTypeProfile(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     780             : {
     781             :     // Declare output parameters.
     782          60 :     std::unique_ptr<protocol::Array<protocol::Profiler::ScriptTypeProfile>> out_result;
     783             : 
     784          60 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     785          60 :     DispatchResponse response = m_backend->takeTypeProfile(&out_result);
     786          60 :     if (response.status() == DispatchResponse::kFallThrough)
     787             :         return response.status();
     788          60 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     789          60 :     if (response.status() == DispatchResponse::kSuccess) {
     790         200 :         result->setValue("result", ValueConversions<protocol::Array<protocol::Profiler::ScriptTypeProfile>>::toValue(out_result.get()));
     791             :     }
     792          60 :     if (weak->get())
     793         120 :         weak->get()->sendResponse(callId, response, std::move(result));
     794          60 :     return response.status();
     795             : }
     796             : 
     797             : // static
     798        3406 : void Dispatcher::wire(UberDispatcher* uber, Backend* backend)
     799             : {
     800        3406 :     std::unique_ptr<DispatcherImpl> dispatcher(new DispatcherImpl(uber->channel(), backend, uber->fallThroughForNotFound()));
     801        3406 :     uber->setupRedirects(dispatcher->redirects());
     802       10218 :     uber->registerBackend("Profiler", std::move(dispatcher));
     803        3406 : }
     804             : 
     805             : } // Profiler
     806             : } // namespace v8_inspector
     807             : } // namespace protocol

Generated by: LCOV version 1.10