#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 DispatchResponse::Success() { … }
DispatchResponse DispatchResponse::FallThrough() { … }
DispatchResponse DispatchResponse::ParseError(std::string message) { … }
DispatchResponse DispatchResponse::InvalidRequest(std::string message) { … }
DispatchResponse DispatchResponse::MethodNotFound(std::string message) { … }
DispatchResponse DispatchResponse::InvalidParams(std::string message) { … }
DispatchResponse DispatchResponse::InternalError() { … }
DispatchResponse DispatchResponse::ServerError(std::string message) { … }
DispatchResponse DispatchResponse::SessionNotFound(std::string message) { … }
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 { … };
}
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 { … };
}
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::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::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) { … }
}
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) { … }
}