chromium/third_party/inspector_protocol/crdtp/dispatch.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "dispatch.h"

#include <cassert>
#include "cbor.h"
#include "error_support.h"
#include "find_by_first.h"
#include "frontend_channel.h"
#include "protocol_core.h"

namespace crdtp {
// =============================================================================
// DispatchResponse - Error status and chaining / fall through
// =============================================================================

// static
DispatchResponse DispatchResponse::Success() {}

// static
DispatchResponse DispatchResponse::FallThrough() {}

// static
DispatchResponse DispatchResponse::ParseError(std::string message) {}

// static
DispatchResponse DispatchResponse::InvalidRequest(std::string message) {}

// static
DispatchResponse DispatchResponse::MethodNotFound(std::string message) {}

// static
DispatchResponse DispatchResponse::InvalidParams(std::string message) {}

// static
DispatchResponse DispatchResponse::InternalError() {}

// static
DispatchResponse DispatchResponse::ServerError(std::string message) {}

// static
DispatchResponse DispatchResponse::SessionNotFound(std::string message) {}

// =============================================================================
// Dispatchable - a shallow parser for CBOR encoded DevTools messages
// =============================================================================
Dispatchable::Dispatchable(span<uint8_t> serialized) :{}

bool Dispatchable::ok() const {}

DispatchResponse Dispatchable::DispatchError() const {}

bool Dispatchable::MaybeParseProperty(cbor::CBORTokenizer* tokenizer) {}

bool Dispatchable::MaybeParseCallId(cbor::CBORTokenizer* tokenizer) {}

bool Dispatchable::MaybeParseMethod(cbor::CBORTokenizer* tokenizer) {}

bool Dispatchable::MaybeParseParams(cbor::CBORTokenizer* tokenizer) {}

bool Dispatchable::MaybeParseSessionId(cbor::CBORTokenizer* tokenizer) {}

namespace {
class ProtocolError : public Serializable {};
}  // namespace

// =============================================================================
// Helpers for creating protocol cresponses and notifications.
// =============================================================================

std::unique_ptr<Serializable> CreateErrorResponse(
    int call_id,
    DispatchResponse dispatch_response) {}

std::unique_ptr<Serializable> CreateErrorResponse(
    int call_id,
    DispatchResponse dispatch_response,
    const DeserializerState& state) {}

std::unique_ptr<Serializable> CreateErrorNotification(
    DispatchResponse dispatch_response) {}

namespace {
class Response : public Serializable {};

class Notification : public Serializable {};
}  // namespace

std::unique_ptr<Serializable> CreateResponse(
    int call_id,
    std::unique_ptr<Serializable> params) {}

std::unique_ptr<Serializable> CreateNotification(
    const char* method,
    std::unique_ptr<Serializable> params) {}

// =============================================================================
// DomainDispatcher - Dispatching betwen protocol methods within a domain.
// =============================================================================
DomainDispatcher::WeakPtr::WeakPtr(DomainDispatcher* dispatcher)
    :{}

DomainDispatcher::WeakPtr::~WeakPtr() {}

DomainDispatcher::Callback::~Callback() = default;

void DomainDispatcher::Callback::dispose() {}

DomainDispatcher::Callback::Callback(
    std::unique_ptr<DomainDispatcher::WeakPtr> backend_impl,
    int call_id,
    span<uint8_t> method,
    span<uint8_t> message)
    :{}

void DomainDispatcher::Callback::sendIfActive(
    std::unique_ptr<Serializable> partialMessage,
    const DispatchResponse& response) {}

void DomainDispatcher::Callback::fallThroughIfActive() {}

DomainDispatcher::DomainDispatcher(FrontendChannel* frontendChannel)
    :{}

DomainDispatcher::~DomainDispatcher() {}

void DomainDispatcher::sendResponse(int call_id,
                                    const DispatchResponse& response,
                                    std::unique_ptr<Serializable> result) {}

void DomainDispatcher::ReportInvalidParams(const Dispatchable& dispatchable,
                                           const DeserializerState& state) {}

void DomainDispatcher::clearFrontend() {}

std::unique_ptr<DomainDispatcher::WeakPtr> DomainDispatcher::weakPtr() {}

// =============================================================================
// UberDispatcher - dispatches between domains (backends).
// =============================================================================
UberDispatcher::DispatchResult::DispatchResult(bool method_found,
                                               std::function<void()> runnable)
    :{}

void UberDispatcher::DispatchResult::Run() {}

UberDispatcher::UberDispatcher(FrontendChannel* frontend_channel)
    :{}

UberDispatcher::~UberDispatcher() = default;

constexpr size_t kNotFound =;

namespace {
size_t DotIdx(span<uint8_t> method) {}
}  // namespace

UberDispatcher::DispatchResult UberDispatcher::Dispatch(
    const Dispatchable& dispatchable) const {}

template <typename T>
struct FirstLessThan {};

void UberDispatcher::WireBackend(
    span<uint8_t> domain,
    const std::vector<std::pair<span<uint8_t>, span<uint8_t>>>&
        sorted_redirects,
    std::unique_ptr<DomainDispatcher> dispatcher) {}

}  // namespace crdtp