LCOV - code coverage report
Current view: top level - out/Release/gen/src/inspector/protocol - Schema.cpp (source / functions) Hit Total Coverage
Test: app.info Lines: 8 61 13.1 %
Date: 2017-04-26 Functions: 4 13 30.8 %

          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/Schema.h"
       8             : 
       9             : #include "src/inspector/protocol/Protocol.h"
      10             : 
      11             : namespace v8_inspector {
      12             : namespace protocol {
      13             : namespace Schema {
      14             : 
      15             : // ------------- Enum values from types.
      16             : 
      17             : const char Metainfo::domainName[] = "Schema";
      18             : const char Metainfo::commandPrefix[] = "Schema.";
      19             : const char Metainfo::version[] = "1.2";
      20             : 
      21           0 : std::unique_ptr<Domain> Domain::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<Domain> result(new Domain());
      29             :     protocol::DictionaryValue* object = DictionaryValue::cast(value);
      30           0 :     errors->push();
      31           0 :     protocol::Value* nameValue = object->get("name");
      32           0 :     errors->setName("name");
      33           0 :     result->m_name = ValueConversions<String>::fromValue(nameValue, errors);
      34           0 :     protocol::Value* versionValue = object->get("version");
      35           0 :     errors->setName("version");
      36           0 :     result->m_version = ValueConversions<String>::fromValue(versionValue, errors);
      37           0 :     errors->pop();
      38           0 :     if (errors->hasErrors())
      39             :         return nullptr;
      40             :     return result;
      41             : }
      42             : 
      43           0 : std::unique_ptr<protocol::DictionaryValue> Domain::toValue() const
      44             : {
      45           0 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
      46           0 :     result->setValue("name", ValueConversions<String>::toValue(m_name));
      47           0 :     result->setValue("version", ValueConversions<String>::toValue(m_version));
      48           0 :     return result;
      49             : }
      50             : 
      51           0 : std::unique_ptr<Domain> Domain::clone() const
      52             : {
      53           0 :     ErrorSupport errors;
      54           0 :     return fromValue(toValue().get(), &errors);
      55             : }
      56             : 
      57           0 : std::unique_ptr<StringBuffer> Domain::toJSONString() const
      58             : {
      59           0 :     String json = toValue()->serialize();
      60           0 :     return StringBufferImpl::adopt(json);
      61             : }
      62             : 
      63             : // static
      64           0 : std::unique_ptr<API::Domain> API::Domain::fromJSONString(const StringView& json)
      65             : {
      66           0 :     ErrorSupport errors;
      67           0 :     std::unique_ptr<Value> value = StringUtil::parseJSON(json);
      68           0 :     if (!value)
      69             :         return nullptr;
      70           0 :     return protocol::Schema::Domain::fromValue(value.get(), &errors);
      71             : }
      72             : 
      73             : // ------------- Enum values from params.
      74             : 
      75             : 
      76             : // ------------- Frontend notifications.
      77             : 
      78           0 : void Frontend::flush()
      79             : {
      80           0 :     m_frontendChannel->flushProtocolNotifications();
      81           0 : }
      82             : 
      83           0 : void Frontend::sendRawNotification(const String& notification)
      84             : {
      85           0 :     m_frontendChannel->sendProtocolNotification(InternalRawNotification::create(notification));
      86           0 : }
      87             : 
      88             : // --------------------- Dispatcher.
      89             : 
      90             : class DispatcherImpl : public protocol::DispatcherBase {
      91             : public:
      92        4573 :     DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend, bool fallThroughForNotFound)
      93             :         : DispatcherBase(frontendChannel)
      94             :         , m_backend(backend)
      95        9146 :         , m_fallThroughForNotFound(fallThroughForNotFound) {
      96       13719 :         m_dispatchMap["Schema.getDomains"] = &DispatcherImpl::getDomains;
      97        4573 :     }
      98       13719 :     ~DispatcherImpl() override { }
      99             :     DispatchResponse::Status dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject) override;
     100             : 
     101             : protected:
     102             :     using CallHandler = DispatchResponse::Status (DispatcherImpl::*)(int callId, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors);
     103             :     using DispatchMap = protocol::HashMap<String, CallHandler>;
     104             :     DispatchMap m_dispatchMap;
     105             : 
     106             :     DispatchResponse::Status getDomains(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*);
     107             : 
     108             :     Backend* m_backend;
     109             :     bool m_fallThroughForNotFound;
     110             : };
     111             : 
     112           0 : DispatchResponse::Status DispatcherImpl::dispatch(int callId, const String& method, std::unique_ptr<protocol::DictionaryValue> messageObject)
     113             : {
     114             :     protocol::HashMap<String, CallHandler>::iterator it = m_dispatchMap.find(method);
     115           0 :     if (it == m_dispatchMap.end()) {
     116           0 :         if (m_fallThroughForNotFound)
     117             :             return DispatchResponse::kFallThrough;
     118           0 :         reportProtocolError(callId, DispatchResponse::kMethodNotFound, "'" + method + "' wasn't found", nullptr);
     119           0 :         return DispatchResponse::kError;
     120             :     }
     121             : 
     122           0 :     protocol::ErrorSupport errors;
     123           0 :     return (this->*(it->second))(callId, std::move(messageObject), &errors);
     124             : }
     125             : 
     126             : 
     127           0 : DispatchResponse::Status DispatcherImpl::getDomains(int callId, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors)
     128             : {
     129             :     // Declare output parameters.
     130           0 :     std::unique_ptr<protocol::Array<protocol::Schema::Domain>> out_domains;
     131             : 
     132           0 :     std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr();
     133           0 :     DispatchResponse response = m_backend->getDomains(&out_domains);
     134           0 :     if (response.status() == DispatchResponse::kFallThrough)
     135             :         return response.status();
     136           0 :     std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create();
     137           0 :     if (response.status() == DispatchResponse::kSuccess) {
     138           0 :         result->setValue("domains", ValueConversions<protocol::Array<protocol::Schema::Domain>>::toValue(out_domains.get()));
     139             :     }
     140           0 :     if (weak->get())
     141           0 :         weak->get()->sendResponse(callId, response, std::move(result));
     142           0 :     return response.status();
     143             : }
     144             : 
     145             : // static
     146        4573 : void Dispatcher::wire(UberDispatcher* dispatcher, Backend* backend)
     147             : {
     148       18292 :     dispatcher->registerBackend("Schema", std::unique_ptr<protocol::DispatcherBase>(new DispatcherImpl(dispatcher->channel(), backend, dispatcher->fallThroughForNotFound())));
     149        4573 : }
     150             : 
     151             : } // Schema
     152             : } // namespace v8_inspector
     153             : } // namespace protocol

Generated by: LCOV version 1.10