%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
// This file is generated by TypeBuilder_cpp.template. // Copyright (c) 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/node/inspector/protocol/NodeTracing.h" #include "src/node/inspector/protocol/Protocol.h" namespace node { namespace inspector { namespace protocol { namespace NodeTracing { // ------------- Enum values from types. const char Metainfo::domainName[] = "NodeTracing"; const char Metainfo::commandPrefix[] = "NodeTracing."; const char Metainfo::version[] = "1.0"; const char* TraceConfig::RecordModeEnum::RecordUntilFull = "recordUntilFull"; const char* TraceConfig::RecordModeEnum::RecordContinuously = "recordContinuously"; const char* TraceConfig::RecordModeEnum::RecordAsMuchAsPossible = "recordAsMuchAsPossible"; std::unique_ptr<TraceConfig> TraceConfig::fromValue(protocol::Value* value, ErrorSupport* errors) { if (!value || value->type() != protocol::Value::TypeObject) { errors->addError("object expected"); return nullptr; } std::unique_ptr<TraceConfig> result(new TraceConfig()); protocol::DictionaryValue* object = DictionaryValue::cast(value); errors->push(); protocol::Value* recordModeValue = object->get("recordMode"); if (recordModeValue) { errors->setName("recordMode"); result->m_recordMode = ValueConversions<String>::fromValue(recordModeValue, errors); } protocol::Value* includedCategoriesValue = object->get("includedCategories"); errors->setName("includedCategories"); result->m_includedCategories = ValueConversions<protocol::Array<String>>::fromValue(includedCategoriesValue, errors); errors->pop(); if (errors->hasErrors()) return nullptr; return result; } std::unique_ptr<protocol::DictionaryValue> TraceConfig::toValue() const { std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create(); if (m_recordMode.isJust()) result->setValue("recordMode", ValueConversions<String>::toValue(m_recordMode.fromJust())); result->setValue("includedCategories", ValueConversions<protocol::Array<String>>::toValue(m_includedCategories.get())); return result; } std::unique_ptr<TraceConfig> TraceConfig::clone() const { ErrorSupport errors; return fromValue(toValue().get(), &errors); } std::unique_ptr<DataCollectedNotification> DataCollectedNotification::fromValue(protocol::Value* value, ErrorSupport* errors) { if (!value || value->type() != protocol::Value::TypeObject) { errors->addError("object expected"); return nullptr; } std::unique_ptr<DataCollectedNotification> result(new DataCollectedNotification()); protocol::DictionaryValue* object = DictionaryValue::cast(value); errors->push(); protocol::Value* valueValue = object->get("value"); errors->setName("value"); result->m_value = ValueConversions<protocol::Array<protocol::DictionaryValue>>::fromValue(valueValue, errors); errors->pop(); if (errors->hasErrors()) return nullptr; return result; } std::unique_ptr<protocol::DictionaryValue> DataCollectedNotification::toValue() const { std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create(); result->setValue("value", ValueConversions<protocol::Array<protocol::DictionaryValue>>::toValue(m_value.get())); return result; } std::unique_ptr<DataCollectedNotification> DataCollectedNotification::clone() const { ErrorSupport errors; return fromValue(toValue().get(), &errors); } // ------------- Enum values from params. // ------------- Frontend notifications. void Frontend::dataCollected(std::unique_ptr<protocol::Array<protocol::DictionaryValue>> value) { if (!m_frontendChannel) return; std::unique_ptr<DataCollectedNotification> messageData = DataCollectedNotification::create() .setValue(std::move(value)) .build(); m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("NodeTracing.dataCollected", std::move(messageData))); } void Frontend::tracingComplete() { if (!m_frontendChannel) return; m_frontendChannel->sendProtocolNotification(InternalResponse::createNotification("NodeTracing.tracingComplete")); } void Frontend::flush() { m_frontendChannel->flushProtocolNotifications(); } void Frontend::sendRawJSONNotification(String notification) { m_frontendChannel->sendProtocolNotification(InternalRawNotification::fromJSON(std::move(notification))); } void Frontend::sendRawCBORNotification(std::vector<uint8_t> notification) { m_frontendChannel->sendProtocolNotification(InternalRawNotification::fromBinary(std::move(notification))); } // --------------------- Dispatcher. class DispatcherImpl : public protocol::DispatcherBase { public: DispatcherImpl(FrontendChannel* frontendChannel, Backend* backend) : DispatcherBase(frontendChannel) , m_backend(backend) { m_dispatchMap["NodeTracing.getCategories"] = &DispatcherImpl::getCategories; m_dispatchMap["NodeTracing.start"] = &DispatcherImpl::start; m_dispatchMap["NodeTracing.stop"] = &DispatcherImpl::stop; } ~DispatcherImpl() override { } bool canDispatch(const String& method) override; void dispatch(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<protocol::DictionaryValue> messageObject) override; std::unordered_map<String, String>& redirects() { return m_redirects; } protected: using CallHandler = void (DispatcherImpl::*)(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> messageObject, ErrorSupport* errors); using DispatchMap = std::unordered_map<String, CallHandler>; DispatchMap m_dispatchMap; std::unordered_map<String, String> m_redirects; void getCategories(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*); void start(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*); void stop(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport*); Backend* m_backend; }; bool DispatcherImpl::canDispatch(const String& method) { return m_dispatchMap.find(method) != m_dispatchMap.end(); } void DispatcherImpl::dispatch(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<protocol::DictionaryValue> messageObject) { std::unordered_map<String, CallHandler>::iterator it = m_dispatchMap.find(method); DCHECK(it != m_dispatchMap.end()); protocol::ErrorSupport errors; (this->*(it->second))(callId, method, message, std::move(messageObject), &errors); } void DispatcherImpl::getCategories(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors) { // Declare output parameters. std::unique_ptr<protocol::Array<String>> out_categories; std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr(); DispatchResponse response = m_backend->getCategories(&out_categories); if (response.status() == DispatchResponse::kFallThrough) { channel()->fallThrough(callId, method, message); return; } std::unique_ptr<protocol::DictionaryValue> result = DictionaryValue::create(); if (response.status() == DispatchResponse::kSuccess) { result->setValue("categories", ValueConversions<protocol::Array<String>>::toValue(out_categories.get())); } if (weak->get()) weak->get()->sendResponse(callId, response, std::move(result)); return; } void DispatcherImpl::start(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors) { // Prepare input parameters. protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params")); errors->push(); protocol::Value* traceConfigValue = object ? object->get("traceConfig") : nullptr; errors->setName("traceConfig"); std::unique_ptr<protocol::NodeTracing::TraceConfig> in_traceConfig = ValueConversions<protocol::NodeTracing::TraceConfig>::fromValue(traceConfigValue, errors); errors->pop(); if (errors->hasErrors()) { reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors); return; } std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr(); DispatchResponse response = m_backend->start(std::move(in_traceConfig)); if (response.status() == DispatchResponse::kFallThrough) { channel()->fallThrough(callId, method, message); return; } if (weak->get()) weak->get()->sendResponse(callId, response); return; } void DispatcherImpl::stop(int callId, const String& method, const ProtocolMessage& message, std::unique_ptr<DictionaryValue> requestMessageObject, ErrorSupport* errors) { std::unique_ptr<DispatcherBase::WeakPtr> weak = weakPtr(); DispatchResponse response = m_backend->stop(); if (response.status() == DispatchResponse::kFallThrough) { channel()->fallThrough(callId, method, message); return; } if (weak->get()) weak->get()->sendResponse(callId, response); return; } // static void Dispatcher::wire(UberDispatcher* uber, Backend* backend) { std::unique_ptr<DispatcherImpl> dispatcher(new DispatcherImpl(uber->channel(), backend)); uber->setupRedirects(dispatcher->redirects()); uber->registerBackend("NodeTracing", std::move(dispatcher)); } } // NodeTracing } // namespace node } // namespace inspector } // namespace protocol