// This file is generated by TypeBuilder_cpp.template.

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

#include "content/browser/devtools/protocol/network.h"

#include "content/browser/devtools/protocol/protocol.h"

#include "third_party/inspector_protocol/crdtp/cbor.h"
#include "third_party/inspector_protocol/crdtp/find_by_first.h"
#include "third_party/inspector_protocol/crdtp/span.h"

namespace content {
namespace protocol {
namespace Network {

using crdtp::DeserializerState;
using crdtp::FallthroughCallback;
using crdtp::ProtocolTypeTraits;

// ------------- Enum values from types.

const char Metainfo::domainName[] = "Network";
const char Metainfo::commandPrefix[] = "Network.";
const char Metainfo::version[] = "1.3";












CRDTP_BEGIN_DESERIALIZER(ResourceTiming)
    CRDTP_DESERIALIZE_FIELD("connectEnd", m_connectEnd),
    CRDTP_DESERIALIZE_FIELD("connectStart", m_connectStart),
    CRDTP_DESERIALIZE_FIELD("dnsEnd", m_dnsEnd),
    CRDTP_DESERIALIZE_FIELD("dnsStart", m_dnsStart),
    CRDTP_DESERIALIZE_FIELD("proxyEnd", m_proxyEnd),
    CRDTP_DESERIALIZE_FIELD("proxyStart", m_proxyStart),
    CRDTP_DESERIALIZE_FIELD("pushEnd", m_pushEnd),
    CRDTP_DESERIALIZE_FIELD("pushStart", m_pushStart),
    CRDTP_DESERIALIZE_FIELD("receiveHeadersEnd", m_receiveHeadersEnd),
    CRDTP_DESERIALIZE_FIELD("receiveHeadersStart", m_receiveHeadersStart),
    CRDTP_DESERIALIZE_FIELD("requestTime", m_requestTime),
    CRDTP_DESERIALIZE_FIELD("sendEnd", m_sendEnd),
    CRDTP_DESERIALIZE_FIELD("sendStart", m_sendStart),
    CRDTP_DESERIALIZE_FIELD("sslEnd", m_sslEnd),
    CRDTP_DESERIALIZE_FIELD("sslStart", m_sslStart),
    CRDTP_DESERIALIZE_FIELD_OPT("workerCacheLookupStart", m_workerCacheLookupStart),
    CRDTP_DESERIALIZE_FIELD("workerFetchStart", m_workerFetchStart),
    CRDTP_DESERIALIZE_FIELD("workerReady", m_workerReady),
    CRDTP_DESERIALIZE_FIELD("workerRespondWithSettled", m_workerRespondWithSettled),
    CRDTP_DESERIALIZE_FIELD_OPT("workerRouterEvaluationStart", m_workerRouterEvaluationStart),
    CRDTP_DESERIALIZE_FIELD("workerStart", m_workerStart),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ResourceTiming)
    CRDTP_SERIALIZE_FIELD("requestTime", m_requestTime);
    CRDTP_SERIALIZE_FIELD("proxyStart", m_proxyStart);
    CRDTP_SERIALIZE_FIELD("proxyEnd", m_proxyEnd);
    CRDTP_SERIALIZE_FIELD("dnsStart", m_dnsStart);
    CRDTP_SERIALIZE_FIELD("dnsEnd", m_dnsEnd);
    CRDTP_SERIALIZE_FIELD("connectStart", m_connectStart);
    CRDTP_SERIALIZE_FIELD("connectEnd", m_connectEnd);
    CRDTP_SERIALIZE_FIELD("sslStart", m_sslStart);
    CRDTP_SERIALIZE_FIELD("sslEnd", m_sslEnd);
    CRDTP_SERIALIZE_FIELD("workerStart", m_workerStart);
    CRDTP_SERIALIZE_FIELD("workerReady", m_workerReady);
    CRDTP_SERIALIZE_FIELD("workerFetchStart", m_workerFetchStart);
    CRDTP_SERIALIZE_FIELD("workerRespondWithSettled", m_workerRespondWithSettled);
    CRDTP_SERIALIZE_FIELD("workerRouterEvaluationStart", m_workerRouterEvaluationStart);
    CRDTP_SERIALIZE_FIELD("workerCacheLookupStart", m_workerCacheLookupStart);
    CRDTP_SERIALIZE_FIELD("sendStart", m_sendStart);
    CRDTP_SERIALIZE_FIELD("sendEnd", m_sendEnd);
    CRDTP_SERIALIZE_FIELD("pushStart", m_pushStart);
    CRDTP_SERIALIZE_FIELD("pushEnd", m_pushEnd);
    CRDTP_SERIALIZE_FIELD("receiveHeadersStart", m_receiveHeadersStart);
    CRDTP_SERIALIZE_FIELD("receiveHeadersEnd", m_receiveHeadersEnd);
CRDTP_END_SERIALIZER();




CRDTP_BEGIN_DESERIALIZER(PostDataEntry)
    CRDTP_DESERIALIZE_FIELD_OPT("bytes", m_bytes),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(PostDataEntry)
    CRDTP_SERIALIZE_FIELD("bytes", m_bytes);
CRDTP_END_SERIALIZER();



const char* Request::ReferrerPolicyEnum::UnsafeUrl = "unsafe-url";
const char* Request::ReferrerPolicyEnum::NoReferrerWhenDowngrade = "no-referrer-when-downgrade";
const char* Request::ReferrerPolicyEnum::NoReferrer = "no-referrer";
const char* Request::ReferrerPolicyEnum::Origin = "origin";
const char* Request::ReferrerPolicyEnum::OriginWhenCrossOrigin = "origin-when-cross-origin";
const char* Request::ReferrerPolicyEnum::SameOrigin = "same-origin";
const char* Request::ReferrerPolicyEnum::StrictOrigin = "strict-origin";
const char* Request::ReferrerPolicyEnum::StrictOriginWhenCrossOrigin = "strict-origin-when-cross-origin";
CRDTP_BEGIN_DESERIALIZER(Request)
    CRDTP_DESERIALIZE_FIELD_OPT("hasPostData", m_hasPostData),
    CRDTP_DESERIALIZE_FIELD("headers", m_headers),
    CRDTP_DESERIALIZE_FIELD("initialPriority", m_initialPriority),
    CRDTP_DESERIALIZE_FIELD_OPT("isAdRelated", m_isAdRelated),
    CRDTP_DESERIALIZE_FIELD_OPT("isLinkPreload", m_isLinkPreload),
    CRDTP_DESERIALIZE_FIELD_OPT("isSameSite", m_isSameSite),
    CRDTP_DESERIALIZE_FIELD("method", m_method),
    CRDTP_DESERIALIZE_FIELD_OPT("mixedContentType", m_mixedContentType),
    CRDTP_DESERIALIZE_FIELD_OPT("postData", m_postData),
    CRDTP_DESERIALIZE_FIELD_OPT("postDataEntries", m_postDataEntries),
    CRDTP_DESERIALIZE_FIELD("referrerPolicy", m_referrerPolicy),
    CRDTP_DESERIALIZE_FIELD_OPT("trustTokenParams", m_trustTokenParams),
    CRDTP_DESERIALIZE_FIELD("url", m_url),
    CRDTP_DESERIALIZE_FIELD_OPT("urlFragment", m_urlFragment),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(Request)
    CRDTP_SERIALIZE_FIELD("url", m_url);
    CRDTP_SERIALIZE_FIELD("urlFragment", m_urlFragment);
    CRDTP_SERIALIZE_FIELD("method", m_method);
    CRDTP_SERIALIZE_FIELD("headers", m_headers);
    CRDTP_SERIALIZE_FIELD("postData", m_postData);
    CRDTP_SERIALIZE_FIELD("hasPostData", m_hasPostData);
    CRDTP_SERIALIZE_FIELD("postDataEntries", m_postDataEntries);
    CRDTP_SERIALIZE_FIELD("mixedContentType", m_mixedContentType);
    CRDTP_SERIALIZE_FIELD("initialPriority", m_initialPriority);
    CRDTP_SERIALIZE_FIELD("referrerPolicy", m_referrerPolicy);
    CRDTP_SERIALIZE_FIELD("isLinkPreload", m_isLinkPreload);
    CRDTP_SERIALIZE_FIELD("trustTokenParams", m_trustTokenParams);
    CRDTP_SERIALIZE_FIELD("isSameSite", m_isSameSite);
    CRDTP_SERIALIZE_FIELD("isAdRelated", m_isAdRelated);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(SignedCertificateTimestamp)
    CRDTP_DESERIALIZE_FIELD("hashAlgorithm", m_hashAlgorithm),
    CRDTP_DESERIALIZE_FIELD("logDescription", m_logDescription),
    CRDTP_DESERIALIZE_FIELD("logId", m_logId),
    CRDTP_DESERIALIZE_FIELD("origin", m_origin),
    CRDTP_DESERIALIZE_FIELD("signatureAlgorithm", m_signatureAlgorithm),
    CRDTP_DESERIALIZE_FIELD("signatureData", m_signatureData),
    CRDTP_DESERIALIZE_FIELD("status", m_status),
    CRDTP_DESERIALIZE_FIELD("timestamp", m_timestamp),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(SignedCertificateTimestamp)
    CRDTP_SERIALIZE_FIELD("status", m_status);
    CRDTP_SERIALIZE_FIELD("origin", m_origin);
    CRDTP_SERIALIZE_FIELD("logDescription", m_logDescription);
    CRDTP_SERIALIZE_FIELD("logId", m_logId);
    CRDTP_SERIALIZE_FIELD("timestamp", m_timestamp);
    CRDTP_SERIALIZE_FIELD("hashAlgorithm", m_hashAlgorithm);
    CRDTP_SERIALIZE_FIELD("signatureAlgorithm", m_signatureAlgorithm);
    CRDTP_SERIALIZE_FIELD("signatureData", m_signatureData);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(SecurityDetails)
    CRDTP_DESERIALIZE_FIELD("certificateId", m_certificateId),
    CRDTP_DESERIALIZE_FIELD("certificateTransparencyCompliance", m_certificateTransparencyCompliance),
    CRDTP_DESERIALIZE_FIELD("cipher", m_cipher),
    CRDTP_DESERIALIZE_FIELD("encryptedClientHello", m_encryptedClientHello),
    CRDTP_DESERIALIZE_FIELD("issuer", m_issuer),
    CRDTP_DESERIALIZE_FIELD("keyExchange", m_keyExchange),
    CRDTP_DESERIALIZE_FIELD_OPT("keyExchangeGroup", m_keyExchangeGroup),
    CRDTP_DESERIALIZE_FIELD_OPT("mac", m_mac),
    CRDTP_DESERIALIZE_FIELD("protocol", m_protocol),
    CRDTP_DESERIALIZE_FIELD("sanList", m_sanList),
    CRDTP_DESERIALIZE_FIELD_OPT("serverSignatureAlgorithm", m_serverSignatureAlgorithm),
    CRDTP_DESERIALIZE_FIELD("signedCertificateTimestampList", m_signedCertificateTimestampList),
    CRDTP_DESERIALIZE_FIELD("subjectName", m_subjectName),
    CRDTP_DESERIALIZE_FIELD("validFrom", m_validFrom),
    CRDTP_DESERIALIZE_FIELD("validTo", m_validTo),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(SecurityDetails)
    CRDTP_SERIALIZE_FIELD("protocol", m_protocol);
    CRDTP_SERIALIZE_FIELD("keyExchange", m_keyExchange);
    CRDTP_SERIALIZE_FIELD("keyExchangeGroup", m_keyExchangeGroup);
    CRDTP_SERIALIZE_FIELD("cipher", m_cipher);
    CRDTP_SERIALIZE_FIELD("mac", m_mac);
    CRDTP_SERIALIZE_FIELD("certificateId", m_certificateId);
    CRDTP_SERIALIZE_FIELD("subjectName", m_subjectName);
    CRDTP_SERIALIZE_FIELD("sanList", m_sanList);
    CRDTP_SERIALIZE_FIELD("issuer", m_issuer);
    CRDTP_SERIALIZE_FIELD("validFrom", m_validFrom);
    CRDTP_SERIALIZE_FIELD("validTo", m_validTo);
    CRDTP_SERIALIZE_FIELD("signedCertificateTimestampList", m_signedCertificateTimestampList);
    CRDTP_SERIALIZE_FIELD("certificateTransparencyCompliance", m_certificateTransparencyCompliance);
    CRDTP_SERIALIZE_FIELD("serverSignatureAlgorithm", m_serverSignatureAlgorithm);
    CRDTP_SERIALIZE_FIELD("encryptedClientHello", m_encryptedClientHello);
CRDTP_END_SERIALIZER();





CRDTP_BEGIN_DESERIALIZER(CorsErrorStatus)
    CRDTP_DESERIALIZE_FIELD("corsError", m_corsError),
    CRDTP_DESERIALIZE_FIELD("failedParameter", m_failedParameter),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(CorsErrorStatus)
    CRDTP_SERIALIZE_FIELD("corsError", m_corsError);
    CRDTP_SERIALIZE_FIELD("failedParameter", m_failedParameter);
CRDTP_END_SERIALIZER();




const char* TrustTokenParams::RefreshPolicyEnum::UseCached = "UseCached";
const char* TrustTokenParams::RefreshPolicyEnum::Refresh = "Refresh";
CRDTP_BEGIN_DESERIALIZER(TrustTokenParams)
    CRDTP_DESERIALIZE_FIELD_OPT("issuers", m_issuers),
    CRDTP_DESERIALIZE_FIELD("operation", m_operation),
    CRDTP_DESERIALIZE_FIELD("refreshPolicy", m_refreshPolicy),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(TrustTokenParams)
    CRDTP_SERIALIZE_FIELD("operation", m_operation);
    CRDTP_SERIALIZE_FIELD("refreshPolicy", m_refreshPolicy);
    CRDTP_SERIALIZE_FIELD("issuers", m_issuers);
CRDTP_END_SERIALIZER();





CRDTP_BEGIN_DESERIALIZER(ServiceWorkerRouterInfo)
    CRDTP_DESERIALIZE_FIELD_OPT("actualSourceType", m_actualSourceType),
    CRDTP_DESERIALIZE_FIELD_OPT("matchedSourceType", m_matchedSourceType),
    CRDTP_DESERIALIZE_FIELD_OPT("ruleIdMatched", m_ruleIdMatched),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ServiceWorkerRouterInfo)
    CRDTP_SERIALIZE_FIELD("ruleIdMatched", m_ruleIdMatched);
    CRDTP_SERIALIZE_FIELD("matchedSourceType", m_matchedSourceType);
    CRDTP_SERIALIZE_FIELD("actualSourceType", m_actualSourceType);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(Response)
    CRDTP_DESERIALIZE_FIELD_OPT("alternateProtocolUsage", m_alternateProtocolUsage),
    CRDTP_DESERIALIZE_FIELD_OPT("cacheStorageCacheName", m_cacheStorageCacheName),
    CRDTP_DESERIALIZE_FIELD("charset", m_charset),
    CRDTP_DESERIALIZE_FIELD("connectionId", m_connectionId),
    CRDTP_DESERIALIZE_FIELD("connectionReused", m_connectionReused),
    CRDTP_DESERIALIZE_FIELD("encodedDataLength", m_encodedDataLength),
    CRDTP_DESERIALIZE_FIELD_OPT("fromDiskCache", m_fromDiskCache),
    CRDTP_DESERIALIZE_FIELD_OPT("fromEarlyHints", m_fromEarlyHints),
    CRDTP_DESERIALIZE_FIELD_OPT("fromPrefetchCache", m_fromPrefetchCache),
    CRDTP_DESERIALIZE_FIELD_OPT("fromServiceWorker", m_fromServiceWorker),
    CRDTP_DESERIALIZE_FIELD("headers", m_headers),
    CRDTP_DESERIALIZE_FIELD_OPT("headersText", m_headersText),
    CRDTP_DESERIALIZE_FIELD("mimeType", m_mimeType),
    CRDTP_DESERIALIZE_FIELD_OPT("protocol", m_protocol),
    CRDTP_DESERIALIZE_FIELD_OPT("remoteIPAddress", m_remoteIPAddress),
    CRDTP_DESERIALIZE_FIELD_OPT("remotePort", m_remotePort),
    CRDTP_DESERIALIZE_FIELD_OPT("requestHeaders", m_requestHeaders),
    CRDTP_DESERIALIZE_FIELD_OPT("requestHeadersText", m_requestHeadersText),
    CRDTP_DESERIALIZE_FIELD_OPT("responseTime", m_responseTime),
    CRDTP_DESERIALIZE_FIELD_OPT("securityDetails", m_securityDetails),
    CRDTP_DESERIALIZE_FIELD("securityState", m_securityState),
    CRDTP_DESERIALIZE_FIELD_OPT("serviceWorkerResponseSource", m_serviceWorkerResponseSource),
    CRDTP_DESERIALIZE_FIELD_OPT("serviceWorkerRouterInfo", m_serviceWorkerRouterInfo),
    CRDTP_DESERIALIZE_FIELD("status", m_status),
    CRDTP_DESERIALIZE_FIELD("statusText", m_statusText),
    CRDTP_DESERIALIZE_FIELD_OPT("timing", m_timing),
    CRDTP_DESERIALIZE_FIELD("url", m_url),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(Response)
    CRDTP_SERIALIZE_FIELD("url", m_url);
    CRDTP_SERIALIZE_FIELD("status", m_status);
    CRDTP_SERIALIZE_FIELD("statusText", m_statusText);
    CRDTP_SERIALIZE_FIELD("headers", m_headers);
    CRDTP_SERIALIZE_FIELD("headersText", m_headersText);
    CRDTP_SERIALIZE_FIELD("mimeType", m_mimeType);
    CRDTP_SERIALIZE_FIELD("charset", m_charset);
    CRDTP_SERIALIZE_FIELD("requestHeaders", m_requestHeaders);
    CRDTP_SERIALIZE_FIELD("requestHeadersText", m_requestHeadersText);
    CRDTP_SERIALIZE_FIELD("connectionReused", m_connectionReused);
    CRDTP_SERIALIZE_FIELD("connectionId", m_connectionId);
    CRDTP_SERIALIZE_FIELD("remoteIPAddress", m_remoteIPAddress);
    CRDTP_SERIALIZE_FIELD("remotePort", m_remotePort);
    CRDTP_SERIALIZE_FIELD("fromDiskCache", m_fromDiskCache);
    CRDTP_SERIALIZE_FIELD("fromServiceWorker", m_fromServiceWorker);
    CRDTP_SERIALIZE_FIELD("fromPrefetchCache", m_fromPrefetchCache);
    CRDTP_SERIALIZE_FIELD("fromEarlyHints", m_fromEarlyHints);
    CRDTP_SERIALIZE_FIELD("serviceWorkerRouterInfo", m_serviceWorkerRouterInfo);
    CRDTP_SERIALIZE_FIELD("encodedDataLength", m_encodedDataLength);
    CRDTP_SERIALIZE_FIELD("timing", m_timing);
    CRDTP_SERIALIZE_FIELD("serviceWorkerResponseSource", m_serviceWorkerResponseSource);
    CRDTP_SERIALIZE_FIELD("responseTime", m_responseTime);
    CRDTP_SERIALIZE_FIELD("cacheStorageCacheName", m_cacheStorageCacheName);
    CRDTP_SERIALIZE_FIELD("protocol", m_protocol);
    CRDTP_SERIALIZE_FIELD("alternateProtocolUsage", m_alternateProtocolUsage);
    CRDTP_SERIALIZE_FIELD("securityState", m_securityState);
    CRDTP_SERIALIZE_FIELD("securityDetails", m_securityDetails);
CRDTP_END_SERIALIZER();



const char* Initiator::TypeEnum::Parser = "parser";
const char* Initiator::TypeEnum::Script = "script";
const char* Initiator::TypeEnum::Preload = "preload";
const char* Initiator::TypeEnum::SignedExchange = "SignedExchange";
const char* Initiator::TypeEnum::Preflight = "preflight";
const char* Initiator::TypeEnum::FedCM = "FedCM";
const char* Initiator::TypeEnum::Other = "other";
CRDTP_BEGIN_DESERIALIZER(Initiator)
    CRDTP_DESERIALIZE_FIELD_OPT("columnNumber", m_columnNumber),
    CRDTP_DESERIALIZE_FIELD_OPT("lineNumber", m_lineNumber),
    CRDTP_DESERIALIZE_FIELD_OPT("requestId", m_requestId),
    CRDTP_DESERIALIZE_FIELD_OPT("stack", m_stack),
    CRDTP_DESERIALIZE_FIELD("type", m_type),
    CRDTP_DESERIALIZE_FIELD_OPT("url", m_url),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(Initiator)
    CRDTP_SERIALIZE_FIELD("type", m_type);
    CRDTP_SERIALIZE_FIELD("stack", m_stack);
    CRDTP_SERIALIZE_FIELD("url", m_url);
    CRDTP_SERIALIZE_FIELD("lineNumber", m_lineNumber);
    CRDTP_SERIALIZE_FIELD("columnNumber", m_columnNumber);
    CRDTP_SERIALIZE_FIELD("requestId", m_requestId);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(CookiePartitionKey)
    CRDTP_DESERIALIZE_FIELD("hasCrossSiteAncestor", m_hasCrossSiteAncestor),
    CRDTP_DESERIALIZE_FIELD("topLevelSite", m_topLevelSite),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(CookiePartitionKey)
    CRDTP_SERIALIZE_FIELD("topLevelSite", m_topLevelSite);
    CRDTP_SERIALIZE_FIELD("hasCrossSiteAncestor", m_hasCrossSiteAncestor);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(Cookie)
    CRDTP_DESERIALIZE_FIELD("domain", m_domain),
    CRDTP_DESERIALIZE_FIELD("expires", m_expires),
    CRDTP_DESERIALIZE_FIELD("httpOnly", m_httpOnly),
    CRDTP_DESERIALIZE_FIELD("name", m_name),
    CRDTP_DESERIALIZE_FIELD_OPT("partitionKey", m_partitionKey),
    CRDTP_DESERIALIZE_FIELD_OPT("partitionKeyOpaque", m_partitionKeyOpaque),
    CRDTP_DESERIALIZE_FIELD("path", m_path),
    CRDTP_DESERIALIZE_FIELD("priority", m_priority),
    CRDTP_DESERIALIZE_FIELD_OPT("sameSite", m_sameSite),
    CRDTP_DESERIALIZE_FIELD("secure", m_secure),
    CRDTP_DESERIALIZE_FIELD("session", m_session),
    CRDTP_DESERIALIZE_FIELD("size", m_size),
    CRDTP_DESERIALIZE_FIELD("sourcePort", m_sourcePort),
    CRDTP_DESERIALIZE_FIELD("sourceScheme", m_sourceScheme),
    CRDTP_DESERIALIZE_FIELD("value", m_value),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(Cookie)
    CRDTP_SERIALIZE_FIELD("name", m_name);
    CRDTP_SERIALIZE_FIELD("value", m_value);
    CRDTP_SERIALIZE_FIELD("domain", m_domain);
    CRDTP_SERIALIZE_FIELD("path", m_path);
    CRDTP_SERIALIZE_FIELD("expires", m_expires);
    CRDTP_SERIALIZE_FIELD("size", m_size);
    CRDTP_SERIALIZE_FIELD("httpOnly", m_httpOnly);
    CRDTP_SERIALIZE_FIELD("secure", m_secure);
    CRDTP_SERIALIZE_FIELD("session", m_session);
    CRDTP_SERIALIZE_FIELD("sameSite", m_sameSite);
    CRDTP_SERIALIZE_FIELD("priority", m_priority);
    CRDTP_SERIALIZE_FIELD("sourceScheme", m_sourceScheme);
    CRDTP_SERIALIZE_FIELD("sourcePort", m_sourcePort);
    CRDTP_SERIALIZE_FIELD("partitionKey", m_partitionKey);
    CRDTP_SERIALIZE_FIELD("partitionKeyOpaque", m_partitionKeyOpaque);
CRDTP_END_SERIALIZER();





CRDTP_BEGIN_DESERIALIZER(BlockedSetCookieWithReason)
    CRDTP_DESERIALIZE_FIELD("blockedReasons", m_blockedReasons),
    CRDTP_DESERIALIZE_FIELD_OPT("cookie", m_cookie),
    CRDTP_DESERIALIZE_FIELD("cookieLine", m_cookieLine),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(BlockedSetCookieWithReason)
    CRDTP_SERIALIZE_FIELD("blockedReasons", m_blockedReasons);
    CRDTP_SERIALIZE_FIELD("cookieLine", m_cookieLine);
    CRDTP_SERIALIZE_FIELD("cookie", m_cookie);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(ExemptedSetCookieWithReason)
    CRDTP_DESERIALIZE_FIELD("cookie", m_cookie),
    CRDTP_DESERIALIZE_FIELD("cookieLine", m_cookieLine),
    CRDTP_DESERIALIZE_FIELD("exemptionReason", m_exemptionReason),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ExemptedSetCookieWithReason)
    CRDTP_SERIALIZE_FIELD("exemptionReason", m_exemptionReason);
    CRDTP_SERIALIZE_FIELD("cookieLine", m_cookieLine);
    CRDTP_SERIALIZE_FIELD("cookie", m_cookie);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(AssociatedCookie)
    CRDTP_DESERIALIZE_FIELD("blockedReasons", m_blockedReasons),
    CRDTP_DESERIALIZE_FIELD("cookie", m_cookie),
    CRDTP_DESERIALIZE_FIELD_OPT("exemptionReason", m_exemptionReason),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(AssociatedCookie)
    CRDTP_SERIALIZE_FIELD("cookie", m_cookie);
    CRDTP_SERIALIZE_FIELD("blockedReasons", m_blockedReasons);
    CRDTP_SERIALIZE_FIELD("exemptionReason", m_exemptionReason);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(CookieParam)
    CRDTP_DESERIALIZE_FIELD_OPT("domain", m_domain),
    CRDTP_DESERIALIZE_FIELD_OPT("expires", m_expires),
    CRDTP_DESERIALIZE_FIELD_OPT("httpOnly", m_httpOnly),
    CRDTP_DESERIALIZE_FIELD("name", m_name),
    CRDTP_DESERIALIZE_FIELD_OPT("partitionKey", m_partitionKey),
    CRDTP_DESERIALIZE_FIELD_OPT("path", m_path),
    CRDTP_DESERIALIZE_FIELD_OPT("priority", m_priority),
    CRDTP_DESERIALIZE_FIELD_OPT("sameSite", m_sameSite),
    CRDTP_DESERIALIZE_FIELD_OPT("secure", m_secure),
    CRDTP_DESERIALIZE_FIELD_OPT("sourcePort", m_sourcePort),
    CRDTP_DESERIALIZE_FIELD_OPT("sourceScheme", m_sourceScheme),
    CRDTP_DESERIALIZE_FIELD_OPT("url", m_url),
    CRDTP_DESERIALIZE_FIELD("value", m_value),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(CookieParam)
    CRDTP_SERIALIZE_FIELD("name", m_name);
    CRDTP_SERIALIZE_FIELD("value", m_value);
    CRDTP_SERIALIZE_FIELD("url", m_url);
    CRDTP_SERIALIZE_FIELD("domain", m_domain);
    CRDTP_SERIALIZE_FIELD("path", m_path);
    CRDTP_SERIALIZE_FIELD("secure", m_secure);
    CRDTP_SERIALIZE_FIELD("httpOnly", m_httpOnly);
    CRDTP_SERIALIZE_FIELD("sameSite", m_sameSite);
    CRDTP_SERIALIZE_FIELD("expires", m_expires);
    CRDTP_SERIALIZE_FIELD("priority", m_priority);
    CRDTP_SERIALIZE_FIELD("sourceScheme", m_sourceScheme);
    CRDTP_SERIALIZE_FIELD("sourcePort", m_sourcePort);
    CRDTP_SERIALIZE_FIELD("partitionKey", m_partitionKey);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(SignedExchangeSignature)
    CRDTP_DESERIALIZE_FIELD_OPT("certSha256", m_certSha256),
    CRDTP_DESERIALIZE_FIELD_OPT("certUrl", m_certUrl),
    CRDTP_DESERIALIZE_FIELD_OPT("certificates", m_certificates),
    CRDTP_DESERIALIZE_FIELD("date", m_date),
    CRDTP_DESERIALIZE_FIELD("expires", m_expires),
    CRDTP_DESERIALIZE_FIELD("integrity", m_integrity),
    CRDTP_DESERIALIZE_FIELD("label", m_label),
    CRDTP_DESERIALIZE_FIELD("signature", m_signature),
    CRDTP_DESERIALIZE_FIELD("validityUrl", m_validityUrl),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(SignedExchangeSignature)
    CRDTP_SERIALIZE_FIELD("label", m_label);
    CRDTP_SERIALIZE_FIELD("signature", m_signature);
    CRDTP_SERIALIZE_FIELD("integrity", m_integrity);
    CRDTP_SERIALIZE_FIELD("certUrl", m_certUrl);
    CRDTP_SERIALIZE_FIELD("certSha256", m_certSha256);
    CRDTP_SERIALIZE_FIELD("validityUrl", m_validityUrl);
    CRDTP_SERIALIZE_FIELD("date", m_date);
    CRDTP_SERIALIZE_FIELD("expires", m_expires);
    CRDTP_SERIALIZE_FIELD("certificates", m_certificates);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(SignedExchangeHeader)
    CRDTP_DESERIALIZE_FIELD("headerIntegrity", m_headerIntegrity),
    CRDTP_DESERIALIZE_FIELD("requestUrl", m_requestUrl),
    CRDTP_DESERIALIZE_FIELD("responseCode", m_responseCode),
    CRDTP_DESERIALIZE_FIELD("responseHeaders", m_responseHeaders),
    CRDTP_DESERIALIZE_FIELD("signatures", m_signatures),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(SignedExchangeHeader)
    CRDTP_SERIALIZE_FIELD("requestUrl", m_requestUrl);
    CRDTP_SERIALIZE_FIELD("responseCode", m_responseCode);
    CRDTP_SERIALIZE_FIELD("responseHeaders", m_responseHeaders);
    CRDTP_SERIALIZE_FIELD("signatures", m_signatures);
    CRDTP_SERIALIZE_FIELD("headerIntegrity", m_headerIntegrity);
CRDTP_END_SERIALIZER();



CRDTP_BEGIN_DESERIALIZER(SignedExchangeError)
    CRDTP_DESERIALIZE_FIELD_OPT("errorField", m_errorField),
    CRDTP_DESERIALIZE_FIELD("message", m_message),
    CRDTP_DESERIALIZE_FIELD_OPT("signatureIndex", m_signatureIndex),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(SignedExchangeError)
    CRDTP_SERIALIZE_FIELD("message", m_message);
    CRDTP_SERIALIZE_FIELD("signatureIndex", m_signatureIndex);
    CRDTP_SERIALIZE_FIELD("errorField", m_errorField);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(SignedExchangeInfo)
    CRDTP_DESERIALIZE_FIELD_OPT("errors", m_errors),
    CRDTP_DESERIALIZE_FIELD("hasExtraInfo", m_hasExtraInfo),
    CRDTP_DESERIALIZE_FIELD_OPT("header", m_header),
    CRDTP_DESERIALIZE_FIELD("outerResponse", m_outerResponse),
    CRDTP_DESERIALIZE_FIELD_OPT("securityDetails", m_securityDetails),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(SignedExchangeInfo)
    CRDTP_SERIALIZE_FIELD("outerResponse", m_outerResponse);
    CRDTP_SERIALIZE_FIELD("hasExtraInfo", m_hasExtraInfo);
    CRDTP_SERIALIZE_FIELD("header", m_header);
    CRDTP_SERIALIZE_FIELD("securityDetails", m_securityDetails);
    CRDTP_SERIALIZE_FIELD("errors", m_errors);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(NetworkConditions)
    CRDTP_DESERIALIZE_FIELD_OPT("connectionType", m_connectionType),
    CRDTP_DESERIALIZE_FIELD("downloadThroughput", m_downloadThroughput),
    CRDTP_DESERIALIZE_FIELD("latency", m_latency),
    CRDTP_DESERIALIZE_FIELD_OPT("offline", m_offline),
    CRDTP_DESERIALIZE_FIELD_OPT("packetLoss", m_packetLoss),
    CRDTP_DESERIALIZE_FIELD_OPT("packetQueueLength", m_packetQueueLength),
    CRDTP_DESERIALIZE_FIELD_OPT("packetReordering", m_packetReordering),
    CRDTP_DESERIALIZE_FIELD("uploadThroughput", m_uploadThroughput),
    CRDTP_DESERIALIZE_FIELD("urlPattern", m_urlPattern),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(NetworkConditions)
    CRDTP_SERIALIZE_FIELD("urlPattern", m_urlPattern);
    CRDTP_SERIALIZE_FIELD("latency", m_latency);
    CRDTP_SERIALIZE_FIELD("downloadThroughput", m_downloadThroughput);
    CRDTP_SERIALIZE_FIELD("uploadThroughput", m_uploadThroughput);
    CRDTP_SERIALIZE_FIELD("connectionType", m_connectionType);
    CRDTP_SERIALIZE_FIELD("packetLoss", m_packetLoss);
    CRDTP_SERIALIZE_FIELD("packetQueueLength", m_packetQueueLength);
    CRDTP_SERIALIZE_FIELD("packetReordering", m_packetReordering);
    CRDTP_SERIALIZE_FIELD("offline", m_offline);
CRDTP_END_SERIALIZER();




CRDTP_BEGIN_DESERIALIZER(ConnectTiming)
    CRDTP_DESERIALIZE_FIELD("requestTime", m_requestTime),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ConnectTiming)
    CRDTP_SERIALIZE_FIELD("requestTime", m_requestTime);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(ClientSecurityState)
    CRDTP_DESERIALIZE_FIELD("initiatorIPAddressSpace", m_initiatorIPAddressSpace),
    CRDTP_DESERIALIZE_FIELD("initiatorIsSecureContext", m_initiatorIsSecureContext),
    CRDTP_DESERIALIZE_FIELD("localNetworkAccessRequestPolicy", m_localNetworkAccessRequestPolicy),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ClientSecurityState)
    CRDTP_SERIALIZE_FIELD("initiatorIsSecureContext", m_initiatorIsSecureContext);
    CRDTP_SERIALIZE_FIELD("initiatorIPAddressSpace", m_initiatorIPAddressSpace);
    CRDTP_SERIALIZE_FIELD("localNetworkAccessRequestPolicy", m_localNetworkAccessRequestPolicy);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(AdScriptIdentifier)
    CRDTP_DESERIALIZE_FIELD("debuggerId", m_debuggerId),
    CRDTP_DESERIALIZE_FIELD("name", m_name),
    CRDTP_DESERIALIZE_FIELD("scriptId", m_scriptId),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(AdScriptIdentifier)
    CRDTP_SERIALIZE_FIELD("scriptId", m_scriptId);
    CRDTP_SERIALIZE_FIELD("debuggerId", m_debuggerId);
    CRDTP_SERIALIZE_FIELD("name", m_name);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(AdAncestry)
    CRDTP_DESERIALIZE_FIELD("ancestryChain", m_ancestryChain),
    CRDTP_DESERIALIZE_FIELD_OPT("rootScriptFilterlistRule", m_rootScriptFilterlistRule),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(AdAncestry)
    CRDTP_SERIALIZE_FIELD("ancestryChain", m_ancestryChain);
    CRDTP_SERIALIZE_FIELD("rootScriptFilterlistRule", m_rootScriptFilterlistRule);
CRDTP_END_SERIALIZER();



CRDTP_BEGIN_DESERIALIZER(CrossOriginOpenerPolicyStatus)
    CRDTP_DESERIALIZE_FIELD_OPT("reportOnlyReportingEndpoint", m_reportOnlyReportingEndpoint),
    CRDTP_DESERIALIZE_FIELD("reportOnlyValue", m_reportOnlyValue),
    CRDTP_DESERIALIZE_FIELD_OPT("reportingEndpoint", m_reportingEndpoint),
    CRDTP_DESERIALIZE_FIELD("value", m_value),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(CrossOriginOpenerPolicyStatus)
    CRDTP_SERIALIZE_FIELD("value", m_value);
    CRDTP_SERIALIZE_FIELD("reportOnlyValue", m_reportOnlyValue);
    CRDTP_SERIALIZE_FIELD("reportingEndpoint", m_reportingEndpoint);
    CRDTP_SERIALIZE_FIELD("reportOnlyReportingEndpoint", m_reportOnlyReportingEndpoint);
CRDTP_END_SERIALIZER();



CRDTP_BEGIN_DESERIALIZER(CrossOriginEmbedderPolicyStatus)
    CRDTP_DESERIALIZE_FIELD_OPT("reportOnlyReportingEndpoint", m_reportOnlyReportingEndpoint),
    CRDTP_DESERIALIZE_FIELD("reportOnlyValue", m_reportOnlyValue),
    CRDTP_DESERIALIZE_FIELD_OPT("reportingEndpoint", m_reportingEndpoint),
    CRDTP_DESERIALIZE_FIELD("value", m_value),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(CrossOriginEmbedderPolicyStatus)
    CRDTP_SERIALIZE_FIELD("value", m_value);
    CRDTP_SERIALIZE_FIELD("reportOnlyValue", m_reportOnlyValue);
    CRDTP_SERIALIZE_FIELD("reportingEndpoint", m_reportingEndpoint);
    CRDTP_SERIALIZE_FIELD("reportOnlyReportingEndpoint", m_reportOnlyReportingEndpoint);
CRDTP_END_SERIALIZER();



CRDTP_BEGIN_DESERIALIZER(ContentSecurityPolicyStatus)
    CRDTP_DESERIALIZE_FIELD("effectiveDirectives", m_effectiveDirectives),
    CRDTP_DESERIALIZE_FIELD("isEnforced", m_isEnforced),
    CRDTP_DESERIALIZE_FIELD("source", m_source),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ContentSecurityPolicyStatus)
    CRDTP_SERIALIZE_FIELD("effectiveDirectives", m_effectiveDirectives);
    CRDTP_SERIALIZE_FIELD("isEnforced", m_isEnforced);
    CRDTP_SERIALIZE_FIELD("source", m_source);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(SecurityIsolationStatus)
    CRDTP_DESERIALIZE_FIELD_OPT("coep", m_coep),
    CRDTP_DESERIALIZE_FIELD_OPT("coop", m_coop),
    CRDTP_DESERIALIZE_FIELD_OPT("csp", m_csp),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(SecurityIsolationStatus)
    CRDTP_SERIALIZE_FIELD("coop", m_coop);
    CRDTP_SERIALIZE_FIELD("coep", m_coep);
    CRDTP_SERIALIZE_FIELD("csp", m_csp);
CRDTP_END_SERIALIZER();




CRDTP_BEGIN_DESERIALIZER(ReportingApiReport)
    CRDTP_DESERIALIZE_FIELD("body", m_body),
    CRDTP_DESERIALIZE_FIELD("completedAttempts", m_completedAttempts),
    CRDTP_DESERIALIZE_FIELD("depth", m_depth),
    CRDTP_DESERIALIZE_FIELD("destination", m_destination),
    CRDTP_DESERIALIZE_FIELD("id", m_id),
    CRDTP_DESERIALIZE_FIELD("initiatorUrl", m_initiatorUrl),
    CRDTP_DESERIALIZE_FIELD("status", m_status),
    CRDTP_DESERIALIZE_FIELD("timestamp", m_timestamp),
    CRDTP_DESERIALIZE_FIELD("type", m_type),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ReportingApiReport)
    CRDTP_SERIALIZE_FIELD("id", m_id);
    CRDTP_SERIALIZE_FIELD("initiatorUrl", m_initiatorUrl);
    CRDTP_SERIALIZE_FIELD("destination", m_destination);
    CRDTP_SERIALIZE_FIELD("type", m_type);
    CRDTP_SERIALIZE_FIELD("timestamp", m_timestamp);
    CRDTP_SERIALIZE_FIELD("depth", m_depth);
    CRDTP_SERIALIZE_FIELD("completedAttempts", m_completedAttempts);
    CRDTP_SERIALIZE_FIELD("body", m_body);
    CRDTP_SERIALIZE_FIELD("status", m_status);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(ReportingApiEndpoint)
    CRDTP_DESERIALIZE_FIELD("groupName", m_groupName),
    CRDTP_DESERIALIZE_FIELD("url", m_url),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ReportingApiEndpoint)
    CRDTP_SERIALIZE_FIELD("url", m_url);
    CRDTP_SERIALIZE_FIELD("groupName", m_groupName);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(DeviceBoundSessionKey)
    CRDTP_DESERIALIZE_FIELD("id", m_id),
    CRDTP_DESERIALIZE_FIELD("site", m_site),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(DeviceBoundSessionKey)
    CRDTP_SERIALIZE_FIELD("site", m_site);
    CRDTP_SERIALIZE_FIELD("id", m_id);
CRDTP_END_SERIALIZER();



const char* DeviceBoundSessionWithUsage::UsageEnum::NotInScope = "NotInScope";
const char* DeviceBoundSessionWithUsage::UsageEnum::InScopeRefreshNotYetNeeded = "InScopeRefreshNotYetNeeded";
const char* DeviceBoundSessionWithUsage::UsageEnum::InScopeRefreshNotAllowed = "InScopeRefreshNotAllowed";
const char* DeviceBoundSessionWithUsage::UsageEnum::ProactiveRefreshNotPossible = "ProactiveRefreshNotPossible";
const char* DeviceBoundSessionWithUsage::UsageEnum::ProactiveRefreshAttempted = "ProactiveRefreshAttempted";
const char* DeviceBoundSessionWithUsage::UsageEnum::Deferred = "Deferred";
CRDTP_BEGIN_DESERIALIZER(DeviceBoundSessionWithUsage)
    CRDTP_DESERIALIZE_FIELD("sessionKey", m_sessionKey),
    CRDTP_DESERIALIZE_FIELD("usage", m_usage),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(DeviceBoundSessionWithUsage)
    CRDTP_SERIALIZE_FIELD("sessionKey", m_sessionKey);
    CRDTP_SERIALIZE_FIELD("usage", m_usage);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(DeviceBoundSessionCookieCraving)
    CRDTP_DESERIALIZE_FIELD("domain", m_domain),
    CRDTP_DESERIALIZE_FIELD("httpOnly", m_httpOnly),
    CRDTP_DESERIALIZE_FIELD("name", m_name),
    CRDTP_DESERIALIZE_FIELD("path", m_path),
    CRDTP_DESERIALIZE_FIELD_OPT("sameSite", m_sameSite),
    CRDTP_DESERIALIZE_FIELD("secure", m_secure),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(DeviceBoundSessionCookieCraving)
    CRDTP_SERIALIZE_FIELD("name", m_name);
    CRDTP_SERIALIZE_FIELD("domain", m_domain);
    CRDTP_SERIALIZE_FIELD("path", m_path);
    CRDTP_SERIALIZE_FIELD("secure", m_secure);
    CRDTP_SERIALIZE_FIELD("httpOnly", m_httpOnly);
    CRDTP_SERIALIZE_FIELD("sameSite", m_sameSite);
CRDTP_END_SERIALIZER();



const char* DeviceBoundSessionUrlRule::RuleTypeEnum::Exclude = "Exclude";
const char* DeviceBoundSessionUrlRule::RuleTypeEnum::Include = "Include";
CRDTP_BEGIN_DESERIALIZER(DeviceBoundSessionUrlRule)
    CRDTP_DESERIALIZE_FIELD("hostPattern", m_hostPattern),
    CRDTP_DESERIALIZE_FIELD("pathPrefix", m_pathPrefix),
    CRDTP_DESERIALIZE_FIELD("ruleType", m_ruleType),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(DeviceBoundSessionUrlRule)
    CRDTP_SERIALIZE_FIELD("ruleType", m_ruleType);
    CRDTP_SERIALIZE_FIELD("hostPattern", m_hostPattern);
    CRDTP_SERIALIZE_FIELD("pathPrefix", m_pathPrefix);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(DeviceBoundSessionInclusionRules)
    CRDTP_DESERIALIZE_FIELD("includeSite", m_includeSite),
    CRDTP_DESERIALIZE_FIELD("origin", m_origin),
    CRDTP_DESERIALIZE_FIELD("urlRules", m_urlRules),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(DeviceBoundSessionInclusionRules)
    CRDTP_SERIALIZE_FIELD("origin", m_origin);
    CRDTP_SERIALIZE_FIELD("includeSite", m_includeSite);
    CRDTP_SERIALIZE_FIELD("urlRules", m_urlRules);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(DeviceBoundSession)
    CRDTP_DESERIALIZE_FIELD("allowedRefreshInitiators", m_allowedRefreshInitiators),
    CRDTP_DESERIALIZE_FIELD_OPT("cachedChallenge", m_cachedChallenge),
    CRDTP_DESERIALIZE_FIELD("cookieCravings", m_cookieCravings),
    CRDTP_DESERIALIZE_FIELD("expiryDate", m_expiryDate),
    CRDTP_DESERIALIZE_FIELD("inclusionRules", m_inclusionRules),
    CRDTP_DESERIALIZE_FIELD("key", m_key),
    CRDTP_DESERIALIZE_FIELD("refreshUrl", m_refreshUrl),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(DeviceBoundSession)
    CRDTP_SERIALIZE_FIELD("key", m_key);
    CRDTP_SERIALIZE_FIELD("refreshUrl", m_refreshUrl);
    CRDTP_SERIALIZE_FIELD("inclusionRules", m_inclusionRules);
    CRDTP_SERIALIZE_FIELD("cookieCravings", m_cookieCravings);
    CRDTP_SERIALIZE_FIELD("expiryDate", m_expiryDate);
    CRDTP_SERIALIZE_FIELD("cachedChallenge", m_cachedChallenge);
    CRDTP_SERIALIZE_FIELD("allowedRefreshInitiators", m_allowedRefreshInitiators);
CRDTP_END_SERIALIZER();




CRDTP_BEGIN_DESERIALIZER(DeviceBoundSessionFailedRequest)
    CRDTP_DESERIALIZE_FIELD_OPT("netError", m_netError),
    CRDTP_DESERIALIZE_FIELD("requestUrl", m_requestUrl),
    CRDTP_DESERIALIZE_FIELD_OPT("responseError", m_responseError),
    CRDTP_DESERIALIZE_FIELD_OPT("responseErrorBody", m_responseErrorBody),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(DeviceBoundSessionFailedRequest)
    CRDTP_SERIALIZE_FIELD("requestUrl", m_requestUrl);
    CRDTP_SERIALIZE_FIELD("netError", m_netError);
    CRDTP_SERIALIZE_FIELD("responseError", m_responseError);
    CRDTP_SERIALIZE_FIELD("responseErrorBody", m_responseErrorBody);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(CreationEventDetails)
    CRDTP_DESERIALIZE_FIELD_OPT("failedRequest", m_failedRequest),
    CRDTP_DESERIALIZE_FIELD("fetchResult", m_fetchResult),
    CRDTP_DESERIALIZE_FIELD_OPT("newSession", m_newSession),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(CreationEventDetails)
    CRDTP_SERIALIZE_FIELD("fetchResult", m_fetchResult);
    CRDTP_SERIALIZE_FIELD("newSession", m_newSession);
    CRDTP_SERIALIZE_FIELD("failedRequest", m_failedRequest);
CRDTP_END_SERIALIZER();



const char* RefreshEventDetails::RefreshResultEnum::Refreshed = "Refreshed";
const char* RefreshEventDetails::RefreshResultEnum::InitializedService = "InitializedService";
const char* RefreshEventDetails::RefreshResultEnum::Unreachable = "Unreachable";
const char* RefreshEventDetails::RefreshResultEnum::ServerError = "ServerError";
const char* RefreshEventDetails::RefreshResultEnum::FatalError = "FatalError";
const char* RefreshEventDetails::RefreshResultEnum::SigningQuotaExceeded = "SigningQuotaExceeded";
const char* RefreshEventDetails::RefreshResultEnum::RefreshedAsWaiter = "RefreshedAsWaiter";
const char* RefreshEventDetails::RefreshResultEnum::TransientSigningError = "TransientSigningError";
const char* RefreshEventDetails::RefreshResultEnum::InScopeRefreshNotYetNeeded = "InScopeRefreshNotYetNeeded";
CRDTP_BEGIN_DESERIALIZER(RefreshEventDetails)
    CRDTP_DESERIALIZE_FIELD_OPT("failedRequest", m_failedRequest),
    CRDTP_DESERIALIZE_FIELD_OPT("fetchResult", m_fetchResult),
    CRDTP_DESERIALIZE_FIELD_OPT("newSession", m_newSession),
    CRDTP_DESERIALIZE_FIELD("refreshResult", m_refreshResult),
    CRDTP_DESERIALIZE_FIELD("wasFullyProactiveRefresh", m_wasFullyProactiveRefresh),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(RefreshEventDetails)
    CRDTP_SERIALIZE_FIELD("refreshResult", m_refreshResult);
    CRDTP_SERIALIZE_FIELD("fetchResult", m_fetchResult);
    CRDTP_SERIALIZE_FIELD("newSession", m_newSession);
    CRDTP_SERIALIZE_FIELD("wasFullyProactiveRefresh", m_wasFullyProactiveRefresh);
    CRDTP_SERIALIZE_FIELD("failedRequest", m_failedRequest);
CRDTP_END_SERIALIZER();



const char* TerminationEventDetails::DeletionReasonEnum::Expired = "Expired";
const char* TerminationEventDetails::DeletionReasonEnum::FailedToRestoreKey = "FailedToRestoreKey";
const char* TerminationEventDetails::DeletionReasonEnum::FailedToUnwrapKey = "FailedToUnwrapKey";
const char* TerminationEventDetails::DeletionReasonEnum::StoragePartitionCleared = "StoragePartitionCleared";
const char* TerminationEventDetails::DeletionReasonEnum::ClearBrowsingData = "ClearBrowsingData";
const char* TerminationEventDetails::DeletionReasonEnum::ServerRequested = "ServerRequested";
const char* TerminationEventDetails::DeletionReasonEnum::InvalidSessionParams = "InvalidSessionParams";
const char* TerminationEventDetails::DeletionReasonEnum::RefreshFatalError = "RefreshFatalError";
const char* TerminationEventDetails::DeletionReasonEnum::DevTools = "DevTools";
CRDTP_BEGIN_DESERIALIZER(TerminationEventDetails)
    CRDTP_DESERIALIZE_FIELD("deletionReason", m_deletionReason),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(TerminationEventDetails)
    CRDTP_SERIALIZE_FIELD("deletionReason", m_deletionReason);
CRDTP_END_SERIALIZER();



const char* ChallengeEventDetails::ChallengeResultEnum::Success = "Success";
const char* ChallengeEventDetails::ChallengeResultEnum::NoSessionId = "NoSessionId";
const char* ChallengeEventDetails::ChallengeResultEnum::NoSessionMatch = "NoSessionMatch";
const char* ChallengeEventDetails::ChallengeResultEnum::CantSetBoundCookie = "CantSetBoundCookie";
CRDTP_BEGIN_DESERIALIZER(ChallengeEventDetails)
    CRDTP_DESERIALIZE_FIELD("challenge", m_challenge),
    CRDTP_DESERIALIZE_FIELD("challengeResult", m_challengeResult),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(ChallengeEventDetails)
    CRDTP_SERIALIZE_FIELD("challengeResult", m_challengeResult);
    CRDTP_SERIALIZE_FIELD("challenge", m_challenge);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(LoadNetworkResourcePageResult)
    CRDTP_DESERIALIZE_FIELD_OPT("headers", m_headers),
    CRDTP_DESERIALIZE_FIELD_OPT("httpStatusCode", m_httpStatusCode),
    CRDTP_DESERIALIZE_FIELD_OPT("netError", m_netError),
    CRDTP_DESERIALIZE_FIELD_OPT("netErrorName", m_netErrorName),
    CRDTP_DESERIALIZE_FIELD_OPT("stream", m_stream),
    CRDTP_DESERIALIZE_FIELD("success", m_success),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(LoadNetworkResourcePageResult)
    CRDTP_SERIALIZE_FIELD("success", m_success);
    CRDTP_SERIALIZE_FIELD("netError", m_netError);
    CRDTP_SERIALIZE_FIELD("netErrorName", m_netErrorName);
    CRDTP_SERIALIZE_FIELD("httpStatusCode", m_httpStatusCode);
    CRDTP_SERIALIZE_FIELD("stream", m_stream);
    CRDTP_SERIALIZE_FIELD("headers", m_headers);
CRDTP_END_SERIALIZER();


CRDTP_BEGIN_DESERIALIZER(LoadNetworkResourceOptions)
    CRDTP_DESERIALIZE_FIELD("disableCache", m_disableCache),
    CRDTP_DESERIALIZE_FIELD("includeCredentials", m_includeCredentials),
CRDTP_END_DESERIALIZER()

CRDTP_BEGIN_SERIALIZER(LoadNetworkResourceOptions)
    CRDTP_SERIALIZE_FIELD("disableCache", m_disableCache);
    CRDTP_SERIALIZE_FIELD("includeCredentials", m_includeCredentials);
CRDTP_END_SERIALIZER();


// ------------- Enum values from params.


// ------------- Frontend notifications.

void Frontend::LoadingFailed(const String& requestId, double timestamp, const String& type, const String& errorText, std::optional<bool> canceled, std::optional<String> blockedReason, std::unique_ptr<protocol::Network::CorsErrorStatus> corsErrorStatus)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("timestamp"), timestamp);
    serializer.AddField(crdtp::MakeSpan("type"), type);
    serializer.AddField(crdtp::MakeSpan("errorText"), errorText);
    serializer.AddField(crdtp::MakeSpan("canceled"), canceled);
    serializer.AddField(crdtp::MakeSpan("blockedReason"), blockedReason);
    serializer.AddField(crdtp::MakeSpan("corsErrorStatus"), corsErrorStatus);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.loadingFailed", serializer.Finish()));
}

void Frontend::LoadingFinished(const String& requestId, double timestamp, double encodedDataLength)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("timestamp"), timestamp);
    serializer.AddField(crdtp::MakeSpan("encodedDataLength"), encodedDataLength);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.loadingFinished", serializer.Finish()));
}

void Frontend::RequestWillBeSent(const String& requestId, const String& loaderId, const String& documentURL, std::unique_ptr<protocol::Network::Request> request, double timestamp, double wallTime, std::unique_ptr<protocol::Network::Initiator> initiator, bool redirectHasExtraInfo, std::unique_ptr<protocol::Network::Response> redirectResponse, std::optional<String> type, std::optional<String> frameId, std::optional<bool> hasUserGesture, std::optional<String> renderBlockingBehavior)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("loaderId"), loaderId);
    serializer.AddField(crdtp::MakeSpan("documentURL"), documentURL);
    serializer.AddField(crdtp::MakeSpan("request"), request);
    serializer.AddField(crdtp::MakeSpan("timestamp"), timestamp);
    serializer.AddField(crdtp::MakeSpan("wallTime"), wallTime);
    serializer.AddField(crdtp::MakeSpan("initiator"), initiator);
    serializer.AddField(crdtp::MakeSpan("redirectHasExtraInfo"), redirectHasExtraInfo);
    serializer.AddField(crdtp::MakeSpan("redirectResponse"), redirectResponse);
    serializer.AddField(crdtp::MakeSpan("type"), type);
    serializer.AddField(crdtp::MakeSpan("frameId"), frameId);
    serializer.AddField(crdtp::MakeSpan("hasUserGesture"), hasUserGesture);
    serializer.AddField(crdtp::MakeSpan("renderBlockingBehavior"), renderBlockingBehavior);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.requestWillBeSent", serializer.Finish()));
}

void Frontend::SignedExchangeReceived(const String& requestId, std::unique_ptr<protocol::Network::SignedExchangeInfo> info)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("info"), info);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.signedExchangeReceived", serializer.Finish()));
}

void Frontend::ResponseReceived(const String& requestId, const String& loaderId, double timestamp, const String& type, std::unique_ptr<protocol::Network::Response> response, bool hasExtraInfo, std::optional<String> frameId)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("loaderId"), loaderId);
    serializer.AddField(crdtp::MakeSpan("timestamp"), timestamp);
    serializer.AddField(crdtp::MakeSpan("type"), type);
    serializer.AddField(crdtp::MakeSpan("response"), response);
    serializer.AddField(crdtp::MakeSpan("hasExtraInfo"), hasExtraInfo);
    serializer.AddField(crdtp::MakeSpan("frameId"), frameId);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.responseReceived", serializer.Finish()));
}

void Frontend::RequestWillBeSentExtraInfo(const String& requestId, std::unique_ptr<protocol::Array<protocol::Network::AssociatedCookie>> associatedCookies, std::unique_ptr<protocol::Network::Headers> headers, std::unique_ptr<protocol::Network::ConnectTiming> connectTiming, std::unique_ptr<protocol::Array<protocol::Network::DeviceBoundSessionWithUsage>> deviceBoundSessionUsages, std::unique_ptr<protocol::Network::ClientSecurityState> clientSecurityState, std::optional<bool> siteHasCookieInOtherPartition, std::optional<String> appliedNetworkConditionsId)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("associatedCookies"), associatedCookies);
    serializer.AddField(crdtp::MakeSpan("headers"), headers);
    serializer.AddField(crdtp::MakeSpan("connectTiming"), connectTiming);
    serializer.AddField(crdtp::MakeSpan("deviceBoundSessionUsages"), deviceBoundSessionUsages);
    serializer.AddField(crdtp::MakeSpan("clientSecurityState"), clientSecurityState);
    serializer.AddField(crdtp::MakeSpan("siteHasCookieInOtherPartition"), siteHasCookieInOtherPartition);
    serializer.AddField(crdtp::MakeSpan("appliedNetworkConditionsId"), appliedNetworkConditionsId);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.requestWillBeSentExtraInfo", serializer.Finish()));
}

void Frontend::ResponseReceivedExtraInfo(const String& requestId, std::unique_ptr<protocol::Array<protocol::Network::BlockedSetCookieWithReason>> blockedCookies, std::unique_ptr<protocol::Network::Headers> headers, const String& resourceIPAddressSpace, int statusCode, std::optional<String> headersText, std::unique_ptr<protocol::Network::CookiePartitionKey> cookiePartitionKey, std::optional<bool> cookiePartitionKeyOpaque, std::unique_ptr<protocol::Array<protocol::Network::ExemptedSetCookieWithReason>> exemptedCookies)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("blockedCookies"), blockedCookies);
    serializer.AddField(crdtp::MakeSpan("headers"), headers);
    serializer.AddField(crdtp::MakeSpan("resourceIPAddressSpace"), resourceIPAddressSpace);
    serializer.AddField(crdtp::MakeSpan("statusCode"), statusCode);
    serializer.AddField(crdtp::MakeSpan("headersText"), headersText);
    serializer.AddField(crdtp::MakeSpan("cookiePartitionKey"), cookiePartitionKey);
    serializer.AddField(crdtp::MakeSpan("cookiePartitionKeyOpaque"), cookiePartitionKeyOpaque);
    serializer.AddField(crdtp::MakeSpan("exemptedCookies"), exemptedCookies);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.responseReceivedExtraInfo", serializer.Finish()));
}

void Frontend::ResponseReceivedEarlyHints(const String& requestId, std::unique_ptr<protocol::Network::Headers> headers)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("headers"), headers);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.responseReceivedEarlyHints", serializer.Finish()));
}

void Frontend::TrustTokenOperationDone(const String& status, const String& type, const String& requestId, std::optional<String> topLevelOrigin, std::optional<String> issuerOrigin, std::optional<int> issuedTokenCount)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("status"), status);
    serializer.AddField(crdtp::MakeSpan("type"), type);
    serializer.AddField(crdtp::MakeSpan("requestId"), requestId);
    serializer.AddField(crdtp::MakeSpan("topLevelOrigin"), topLevelOrigin);
    serializer.AddField(crdtp::MakeSpan("issuerOrigin"), issuerOrigin);
    serializer.AddField(crdtp::MakeSpan("issuedTokenCount"), issuedTokenCount);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.trustTokenOperationDone", serializer.Finish()));
}

void Frontend::PolicyUpdated()
{
    if (!frontend_channel_)
        return;
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.policyUpdated"));
}

void Frontend::ReportingApiReportAdded(std::unique_ptr<protocol::Network::ReportingApiReport> report)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("report"), report);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.reportingApiReportAdded", serializer.Finish()));
}

void Frontend::ReportingApiReportUpdated(std::unique_ptr<protocol::Network::ReportingApiReport> report)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("report"), report);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.reportingApiReportUpdated", serializer.Finish()));
}

void Frontend::ReportingApiEndpointsChangedForOrigin(const String& origin, std::unique_ptr<protocol::Array<protocol::Network::ReportingApiEndpoint>> endpoints)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("origin"), origin);
    serializer.AddField(crdtp::MakeSpan("endpoints"), endpoints);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.reportingApiEndpointsChangedForOrigin", serializer.Finish()));
}

void Frontend::DeviceBoundSessionsAdded(std::unique_ptr<protocol::Array<protocol::Network::DeviceBoundSession>> sessions)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("sessions"), sessions);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.deviceBoundSessionsAdded", serializer.Finish()));
}

void Frontend::DeviceBoundSessionEventOccurred(const String& eventId, const String& site, bool succeeded, std::optional<String> sessionId, std::unique_ptr<protocol::Network::CreationEventDetails> creationEventDetails, std::unique_ptr<protocol::Network::RefreshEventDetails> refreshEventDetails, std::unique_ptr<protocol::Network::TerminationEventDetails> terminationEventDetails, std::unique_ptr<protocol::Network::ChallengeEventDetails> challengeEventDetails)
{
    if (!frontend_channel_)
        return;
    crdtp::ObjectSerializer serializer;
    serializer.AddField(crdtp::MakeSpan("eventId"), eventId);
    serializer.AddField(crdtp::MakeSpan("site"), site);
    serializer.AddField(crdtp::MakeSpan("succeeded"), succeeded);
    serializer.AddField(crdtp::MakeSpan("sessionId"), sessionId);
    serializer.AddField(crdtp::MakeSpan("creationEventDetails"), creationEventDetails);
    serializer.AddField(crdtp::MakeSpan("refreshEventDetails"), refreshEventDetails);
    serializer.AddField(crdtp::MakeSpan("terminationEventDetails"), terminationEventDetails);
    serializer.AddField(crdtp::MakeSpan("challengeEventDetails"), challengeEventDetails);
    frontend_channel_->SendProtocolNotification(crdtp::CreateNotification("Network.deviceBoundSessionEventOccurred", serializer.Finish()));
}

void Frontend::flush()
{
    frontend_channel_->FlushProtocolNotifications();
}

void Frontend::sendRawNotification(std::unique_ptr<Serializable> notification)
{
    frontend_channel_->SendProtocolNotification(std::move(notification));
}

// --------------------- Dispatcher.

class DomainDispatcherImpl : public protocol::DomainDispatcher {
public:
    DomainDispatcherImpl(FrontendChannel* frontendChannel, Backend* backend)
        : DomainDispatcher(frontendChannel)
        , m_backend(backend) {}
    ~DomainDispatcherImpl() override { }

    using CallHandler = void (DomainDispatcherImpl::*)(crdtp::Dispatchable& dispatchable);

    bool Dispatch(crdtp::span<uint8_t> command_name, crdtp::Dispatchable& dispatchable) override;

    void canEmulateNetworkConditions(crdtp::Dispatchable& dispatchable);
    void clearBrowserCache(crdtp::Dispatchable& dispatchable);
    void clearBrowserCookies(crdtp::Dispatchable& dispatchable);
    void deleteCookies(crdtp::Dispatchable& dispatchable);
    void disable(crdtp::Dispatchable& dispatchable);
    void emulateNetworkConditions(crdtp::Dispatchable& dispatchable);
    void emulateNetworkConditionsByRule(crdtp::Dispatchable& dispatchable);
    void enable(crdtp::Dispatchable& dispatchable);
    void configureDurableMessages(crdtp::Dispatchable& dispatchable);
    void getAllCookies(crdtp::Dispatchable& dispatchable);
    void getCookies(crdtp::Dispatchable& dispatchable);
    void getResponseBody(crdtp::Dispatchable& dispatchable);
    void setBypassServiceWorker(crdtp::Dispatchable& dispatchable);
    void setCacheDisabled(crdtp::Dispatchable& dispatchable);
    void setCookie(crdtp::Dispatchable& dispatchable);
    void setCookies(crdtp::Dispatchable& dispatchable);
    void setExtraHTTPHeaders(crdtp::Dispatchable& dispatchable);
    void getSecurityIsolationStatus(crdtp::Dispatchable& dispatchable);
    void enableReportingApi(crdtp::Dispatchable& dispatchable);
    void enableDeviceBoundSessions(crdtp::Dispatchable& dispatchable);
    void deleteDeviceBoundSession(crdtp::Dispatchable& dispatchable);
    void fetchSchemefulSite(crdtp::Dispatchable& dispatchable);
    void loadNetworkResource(crdtp::Dispatchable& dispatchable);
    void setCookieControls(crdtp::Dispatchable& dispatchable);
 protected:
    Backend* m_backend;
};

namespace {
// This helper method with a static map of command methods (instance methods
// of DomainDispatcherImpl declared just above) by their name is used immediately below,
// in the DomainDispatcherImpl::Dispatch method.
DomainDispatcherImpl::CallHandler CommandByName(crdtp::span<uint8_t> command_name) {
  static auto* commands = [](){
    auto* commands = new std::vector<std::pair<crdtp::span<uint8_t>,
                              DomainDispatcherImpl::CallHandler>>{
    {
          crdtp::SpanFrom("canEmulateNetworkConditions"),
          &DomainDispatcherImpl::canEmulateNetworkConditions
    },
    {
          crdtp::SpanFrom("clearBrowserCache"),
          &DomainDispatcherImpl::clearBrowserCache
    },
    {
          crdtp::SpanFrom("clearBrowserCookies"),
          &DomainDispatcherImpl::clearBrowserCookies
    },
    {
          crdtp::SpanFrom("configureDurableMessages"),
          &DomainDispatcherImpl::configureDurableMessages
    },
    {
          crdtp::SpanFrom("deleteCookies"),
          &DomainDispatcherImpl::deleteCookies
    },
    {
          crdtp::SpanFrom("deleteDeviceBoundSession"),
          &DomainDispatcherImpl::deleteDeviceBoundSession
    },
    {
          crdtp::SpanFrom("disable"),
          &DomainDispatcherImpl::disable
    },
    {
          crdtp::SpanFrom("emulateNetworkConditions"),
          &DomainDispatcherImpl::emulateNetworkConditions
    },
    {
          crdtp::SpanFrom("emulateNetworkConditionsByRule"),
          &DomainDispatcherImpl::emulateNetworkConditionsByRule
    },
    {
          crdtp::SpanFrom("enable"),
          &DomainDispatcherImpl::enable
    },
    {
          crdtp::SpanFrom("enableDeviceBoundSessions"),
          &DomainDispatcherImpl::enableDeviceBoundSessions
    },
    {
          crdtp::SpanFrom("enableReportingApi"),
          &DomainDispatcherImpl::enableReportingApi
    },
    {
          crdtp::SpanFrom("fetchSchemefulSite"),
          &DomainDispatcherImpl::fetchSchemefulSite
    },
    {
          crdtp::SpanFrom("getAllCookies"),
          &DomainDispatcherImpl::getAllCookies
    },
    {
          crdtp::SpanFrom("getCookies"),
          &DomainDispatcherImpl::getCookies
    },
    {
          crdtp::SpanFrom("getResponseBody"),
          &DomainDispatcherImpl::getResponseBody
    },
    {
          crdtp::SpanFrom("getSecurityIsolationStatus"),
          &DomainDispatcherImpl::getSecurityIsolationStatus
    },
    {
          crdtp::SpanFrom("loadNetworkResource"),
          &DomainDispatcherImpl::loadNetworkResource
    },
    {
          crdtp::SpanFrom("setBypassServiceWorker"),
          &DomainDispatcherImpl::setBypassServiceWorker
    },
    {
          crdtp::SpanFrom("setCacheDisabled"),
          &DomainDispatcherImpl::setCacheDisabled
    },
    {
          crdtp::SpanFrom("setCookie"),
          &DomainDispatcherImpl::setCookie
    },
    {
          crdtp::SpanFrom("setCookieControls"),
          &DomainDispatcherImpl::setCookieControls
    },
    {
          crdtp::SpanFrom("setCookies"),
          &DomainDispatcherImpl::setCookies
    },
    {
          crdtp::SpanFrom("setExtraHTTPHeaders"),
          &DomainDispatcherImpl::setExtraHTTPHeaders
    },
    };
    return commands;
  }();
  return crdtp::FindByFirst<DomainDispatcherImpl::CallHandler>(*commands, command_name, nullptr);
}
}  // namespace

bool DomainDispatcherImpl::Dispatch(crdtp::span<uint8_t> command_name, crdtp::Dispatchable& dispatchable) {
  CallHandler handler = CommandByName(command_name);
  if (!handler) return false;

  (this->*handler)(dispatchable);
  return true;
}


namespace {


}  // namespace

void DomainDispatcherImpl::canEmulateNetworkConditions(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    // Declare output parameters.
    bool out_result;

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->CanEmulateNetworkConditions(&out_result);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
      if (weak->get()) {
        std::unique_ptr<crdtp::Serializable> result;
        if (response.IsSuccess()) {
          crdtp::ObjectSerializer serializer;
          serializer.AddField(crdtp::MakeSpan("result"), out_result);
          result = serializer.Finish();
        } else {
          result = Serializable::From({});
        }
        weak->get()->sendResponse(dispatchable.CallId(), response, std::move(result));
      }
    return;
}

class ClearBrowserCacheCallbackImpl : public Backend::ClearBrowserCacheCallback, public DomainDispatcher::Callback {
public:
    ClearBrowserCacheCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.clearBrowserCache")) { }

    void sendSuccess() override
    {
        crdtp::ObjectSerializer serializer;
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {


}  // namespace

void DomainDispatcherImpl::clearBrowserCache(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.

    m_backend->ClearBrowserCache(std::make_unique<ClearBrowserCacheCallbackImpl>(weakPtr(), dispatchable));
}

class ClearBrowserCookiesCallbackImpl : public Backend::ClearBrowserCookiesCallback, public DomainDispatcher::Callback {
public:
    ClearBrowserCookiesCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.clearBrowserCookies")) { }

    void sendSuccess() override
    {
        crdtp::ObjectSerializer serializer;
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {


}  // namespace

void DomainDispatcherImpl::clearBrowserCookies(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.

    m_backend->ClearBrowserCookies(std::make_unique<ClearBrowserCookiesCallbackImpl>(weakPtr(), dispatchable));
}

class DeleteCookiesCallbackImpl : public Backend::DeleteCookiesCallback, public DomainDispatcher::Callback {
public:
    DeleteCookiesCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.deleteCookies")) { }

    void sendSuccess() override
    {
        crdtp::ObjectSerializer serializer;
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {

struct deleteCookiesParams : public crdtp::DeserializableProtocolObject<deleteCookiesParams> {
    String name;
    std::optional<String> url;
    std::optional<String> domain;
    std::optional<String> path;
    std::unique_ptr<protocol::Network::CookiePartitionKey> partitionKey;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(deleteCookiesParams)
    CRDTP_DESERIALIZE_FIELD_OPT("domain", domain),
    CRDTP_DESERIALIZE_FIELD("name", name),
    CRDTP_DESERIALIZE_FIELD_OPT("partitionKey", partitionKey),
    CRDTP_DESERIALIZE_FIELD_OPT("path", path),
    CRDTP_DESERIALIZE_FIELD_OPT("url", url),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::deleteCookies(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    deleteCookiesParams params;
    if (!deleteCookiesParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    m_backend->DeleteCookies(params.name, std::move(params.url), std::move(params.domain), std::move(params.path), std::move(params.partitionKey), std::make_unique<DeleteCookiesCallbackImpl>(weakPtr(), dispatchable));
}

namespace {


}  // namespace

void DomainDispatcherImpl::disable(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->Disable();
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

namespace {

struct emulateNetworkConditionsParams : public crdtp::DeserializableProtocolObject<emulateNetworkConditionsParams> {
    bool offline;
    double latency;
    double downloadThroughput;
    double uploadThroughput;
    std::optional<String> connectionType;
    std::optional<double> packetLoss;
    std::optional<int> packetQueueLength;
    std::optional<bool> packetReordering;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(emulateNetworkConditionsParams)
    CRDTP_DESERIALIZE_FIELD_OPT("connectionType", connectionType),
    CRDTP_DESERIALIZE_FIELD("downloadThroughput", downloadThroughput),
    CRDTP_DESERIALIZE_FIELD("latency", latency),
    CRDTP_DESERIALIZE_FIELD("offline", offline),
    CRDTP_DESERIALIZE_FIELD_OPT("packetLoss", packetLoss),
    CRDTP_DESERIALIZE_FIELD_OPT("packetQueueLength", packetQueueLength),
    CRDTP_DESERIALIZE_FIELD_OPT("packetReordering", packetReordering),
    CRDTP_DESERIALIZE_FIELD("uploadThroughput", uploadThroughput),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::emulateNetworkConditions(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    emulateNetworkConditionsParams params;
    if (!emulateNetworkConditionsParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->EmulateNetworkConditions(params.offline, params.latency, params.downloadThroughput, params.uploadThroughput, std::move(params.connectionType), std::move(params.packetLoss), std::move(params.packetQueueLength), std::move(params.packetReordering));
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

namespace {

struct emulateNetworkConditionsByRuleParams : public crdtp::DeserializableProtocolObject<emulateNetworkConditionsByRuleParams> {
    std::optional<bool> offline;
    std::optional<bool> emulateOfflineServiceWorker;
    std::unique_ptr<protocol::Array<protocol::Network::NetworkConditions>> matchedNetworkConditions;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(emulateNetworkConditionsByRuleParams)
    CRDTP_DESERIALIZE_FIELD_OPT("emulateOfflineServiceWorker", emulateOfflineServiceWorker),
    CRDTP_DESERIALIZE_FIELD("matchedNetworkConditions", matchedNetworkConditions),
    CRDTP_DESERIALIZE_FIELD_OPT("offline", offline),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::emulateNetworkConditionsByRule(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    emulateNetworkConditionsByRuleParams params;
    if (!emulateNetworkConditionsByRuleParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }
    // Declare output parameters.
    std::unique_ptr<protocol::Array<String>> out_ruleIds;

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->EmulateNetworkConditionsByRule(std::move(params.offline), std::move(params.emulateOfflineServiceWorker), std::move(params.matchedNetworkConditions), &out_ruleIds);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
      if (weak->get()) {
        std::unique_ptr<crdtp::Serializable> result;
        if (response.IsSuccess()) {
          crdtp::ObjectSerializer serializer;
          serializer.AddField(crdtp::MakeSpan("ruleIds"), out_ruleIds);
          result = serializer.Finish();
        } else {
          result = Serializable::From({});
        }
        weak->get()->sendResponse(dispatchable.CallId(), response, std::move(result));
      }
    return;
}

namespace {

struct enableParams : public crdtp::DeserializableProtocolObject<enableParams> {
    std::optional<int> maxTotalBufferSize;
    std::optional<int> maxResourceBufferSize;
    std::optional<int> maxPostDataSize;
    std::optional<bool> reportDirectSocketTraffic;
    std::optional<bool> enableDurableMessages;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(enableParams)
    CRDTP_DESERIALIZE_FIELD_OPT("enableDurableMessages", enableDurableMessages),
    CRDTP_DESERIALIZE_FIELD_OPT("maxPostDataSize", maxPostDataSize),
    CRDTP_DESERIALIZE_FIELD_OPT("maxResourceBufferSize", maxResourceBufferSize),
    CRDTP_DESERIALIZE_FIELD_OPT("maxTotalBufferSize", maxTotalBufferSize),
    CRDTP_DESERIALIZE_FIELD_OPT("reportDirectSocketTraffic", reportDirectSocketTraffic),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::enable(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    enableParams params;
    if (!enableParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->Enable(std::move(params.maxTotalBufferSize), std::move(params.maxResourceBufferSize), std::move(params.maxPostDataSize), std::move(params.reportDirectSocketTraffic), std::move(params.enableDurableMessages));
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

class ConfigureDurableMessagesCallbackImpl : public Backend::ConfigureDurableMessagesCallback, public DomainDispatcher::Callback {
public:
    ConfigureDurableMessagesCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.configureDurableMessages")) { }

    void sendSuccess() override
    {
        crdtp::ObjectSerializer serializer;
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {

struct configureDurableMessagesParams : public crdtp::DeserializableProtocolObject<configureDurableMessagesParams> {
    std::optional<int> maxTotalBufferSize;
    std::optional<int> maxResourceBufferSize;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(configureDurableMessagesParams)
    CRDTP_DESERIALIZE_FIELD_OPT("maxResourceBufferSize", maxResourceBufferSize),
    CRDTP_DESERIALIZE_FIELD_OPT("maxTotalBufferSize", maxTotalBufferSize),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::configureDurableMessages(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    configureDurableMessagesParams params;
    if (!configureDurableMessagesParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    m_backend->ConfigureDurableMessages(std::move(params.maxTotalBufferSize), std::move(params.maxResourceBufferSize), std::make_unique<ConfigureDurableMessagesCallbackImpl>(weakPtr(), dispatchable));
}

class GetAllCookiesCallbackImpl : public Backend::GetAllCookiesCallback, public DomainDispatcher::Callback {
public:
    GetAllCookiesCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.getAllCookies")) { }

    void sendSuccess(std::unique_ptr<protocol::Array<protocol::Network::Cookie>> cookies) override
    {
        crdtp::ObjectSerializer serializer;
        serializer.AddField(crdtp::MakeSpan("cookies"), cookies);
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {


}  // namespace

void DomainDispatcherImpl::getAllCookies(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.

    m_backend->GetAllCookies(std::make_unique<GetAllCookiesCallbackImpl>(weakPtr(), dispatchable));
}

class GetCookiesCallbackImpl : public Backend::GetCookiesCallback, public DomainDispatcher::Callback {
public:
    GetCookiesCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.getCookies")) { }

    void sendSuccess(std::unique_ptr<protocol::Array<protocol::Network::Cookie>> cookies) override
    {
        crdtp::ObjectSerializer serializer;
        serializer.AddField(crdtp::MakeSpan("cookies"), cookies);
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {

struct getCookiesParams : public crdtp::DeserializableProtocolObject<getCookiesParams> {
    std::unique_ptr<protocol::Array<String>> urls;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(getCookiesParams)
    CRDTP_DESERIALIZE_FIELD_OPT("urls", urls),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::getCookies(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    getCookiesParams params;
    if (!getCookiesParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    m_backend->GetCookies(std::move(params.urls), std::make_unique<GetCookiesCallbackImpl>(weakPtr(), dispatchable));
}

class GetResponseBodyCallbackImpl : public Backend::GetResponseBodyCallback, public DomainDispatcher::Callback {
public:
    GetResponseBodyCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.getResponseBody")) { }

    void sendSuccess(const String& body, bool base64Encoded) override
    {
        crdtp::ObjectSerializer serializer;
        serializer.AddField(crdtp::MakeSpan("body"), body);
        serializer.AddField(crdtp::MakeSpan("base64Encoded"), base64Encoded);
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {

struct getResponseBodyParams : public crdtp::DeserializableProtocolObject<getResponseBodyParams> {
    String requestId;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(getResponseBodyParams)
    CRDTP_DESERIALIZE_FIELD("requestId", requestId),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::getResponseBody(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    getResponseBodyParams params;
    if (!getResponseBodyParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    m_backend->GetResponseBody(params.requestId, std::make_unique<GetResponseBodyCallbackImpl>(weakPtr(), dispatchable));
}

namespace {

struct setBypassServiceWorkerParams : public crdtp::DeserializableProtocolObject<setBypassServiceWorkerParams> {
    bool bypass;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(setBypassServiceWorkerParams)
    CRDTP_DESERIALIZE_FIELD("bypass", bypass),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::setBypassServiceWorker(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    setBypassServiceWorkerParams params;
    if (!setBypassServiceWorkerParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->SetBypassServiceWorker(params.bypass);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

namespace {

struct setCacheDisabledParams : public crdtp::DeserializableProtocolObject<setCacheDisabledParams> {
    bool cacheDisabled;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(setCacheDisabledParams)
    CRDTP_DESERIALIZE_FIELD("cacheDisabled", cacheDisabled),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::setCacheDisabled(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    setCacheDisabledParams params;
    if (!setCacheDisabledParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->SetCacheDisabled(params.cacheDisabled);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

class SetCookieCallbackImpl : public Backend::SetCookieCallback, public DomainDispatcher::Callback {
public:
    SetCookieCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.setCookie")) { }

    void sendSuccess(bool success) override
    {
        crdtp::ObjectSerializer serializer;
        serializer.AddField(crdtp::MakeSpan("success"), success);
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {

struct setCookieParams : public crdtp::DeserializableProtocolObject<setCookieParams> {
    String name;
    String value;
    std::optional<String> url;
    std::optional<String> domain;
    std::optional<String> path;
    std::optional<bool> secure;
    std::optional<bool> httpOnly;
    std::optional<String> sameSite;
    std::optional<double> expires;
    std::optional<String> priority;
    std::optional<String> sourceScheme;
    std::optional<int> sourcePort;
    std::unique_ptr<protocol::Network::CookiePartitionKey> partitionKey;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(setCookieParams)
    CRDTP_DESERIALIZE_FIELD_OPT("domain", domain),
    CRDTP_DESERIALIZE_FIELD_OPT("expires", expires),
    CRDTP_DESERIALIZE_FIELD_OPT("httpOnly", httpOnly),
    CRDTP_DESERIALIZE_FIELD("name", name),
    CRDTP_DESERIALIZE_FIELD_OPT("partitionKey", partitionKey),
    CRDTP_DESERIALIZE_FIELD_OPT("path", path),
    CRDTP_DESERIALIZE_FIELD_OPT("priority", priority),
    CRDTP_DESERIALIZE_FIELD_OPT("sameSite", sameSite),
    CRDTP_DESERIALIZE_FIELD_OPT("secure", secure),
    CRDTP_DESERIALIZE_FIELD_OPT("sourcePort", sourcePort),
    CRDTP_DESERIALIZE_FIELD_OPT("sourceScheme", sourceScheme),
    CRDTP_DESERIALIZE_FIELD_OPT("url", url),
    CRDTP_DESERIALIZE_FIELD("value", value),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::setCookie(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    setCookieParams params;
    if (!setCookieParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    m_backend->SetCookie(params.name, params.value, std::move(params.url), std::move(params.domain), std::move(params.path), std::move(params.secure), std::move(params.httpOnly), std::move(params.sameSite), std::move(params.expires), std::move(params.priority), std::move(params.sourceScheme), std::move(params.sourcePort), std::move(params.partitionKey), std::make_unique<SetCookieCallbackImpl>(weakPtr(), dispatchable));
}

class SetCookiesCallbackImpl : public Backend::SetCookiesCallback, public DomainDispatcher::Callback {
public:
    SetCookiesCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.setCookies")) { }

    void sendSuccess() override
    {
        crdtp::ObjectSerializer serializer;
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {

struct setCookiesParams : public crdtp::DeserializableProtocolObject<setCookiesParams> {
    std::unique_ptr<protocol::Array<protocol::Network::CookieParam>> cookies;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(setCookiesParams)
    CRDTP_DESERIALIZE_FIELD("cookies", cookies),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::setCookies(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    setCookiesParams params;
    if (!setCookiesParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    m_backend->SetCookies(std::move(params.cookies), std::make_unique<SetCookiesCallbackImpl>(weakPtr(), dispatchable));
}

namespace {

struct setExtraHTTPHeadersParams : public crdtp::DeserializableProtocolObject<setExtraHTTPHeadersParams> {
    std::unique_ptr<protocol::Network::Headers> headers;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(setExtraHTTPHeadersParams)
    CRDTP_DESERIALIZE_FIELD("headers", headers),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::setExtraHTTPHeaders(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    setExtraHTTPHeadersParams params;
    if (!setExtraHTTPHeadersParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->SetExtraHTTPHeaders(std::move(params.headers));
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

namespace {

struct getSecurityIsolationStatusParams : public crdtp::DeserializableProtocolObject<getSecurityIsolationStatusParams> {
    std::optional<String> frameId;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(getSecurityIsolationStatusParams)
    CRDTP_DESERIALIZE_FIELD_OPT("frameId", frameId),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::getSecurityIsolationStatus(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    getSecurityIsolationStatusParams params;
    if (!getSecurityIsolationStatusParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }
    // Declare output parameters.
    std::unique_ptr<protocol::Network::SecurityIsolationStatus> out_status;

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->GetSecurityIsolationStatus(std::move(params.frameId), &out_status);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
      if (weak->get()) {
        std::unique_ptr<crdtp::Serializable> result;
        if (response.IsSuccess()) {
          crdtp::ObjectSerializer serializer;
          serializer.AddField(crdtp::MakeSpan("status"), out_status);
          result = serializer.Finish();
        } else {
          result = Serializable::From({});
        }
        weak->get()->sendResponse(dispatchable.CallId(), response, std::move(result));
      }
    return;
}

namespace {

struct enableReportingApiParams : public crdtp::DeserializableProtocolObject<enableReportingApiParams> {
    bool enable;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(enableReportingApiParams)
    CRDTP_DESERIALIZE_FIELD("enable", enable),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::enableReportingApi(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    enableReportingApiParams params;
    if (!enableReportingApiParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->EnableReportingApi(params.enable);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

namespace {

struct enableDeviceBoundSessionsParams : public crdtp::DeserializableProtocolObject<enableDeviceBoundSessionsParams> {
    bool enable;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(enableDeviceBoundSessionsParams)
    CRDTP_DESERIALIZE_FIELD("enable", enable),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::enableDeviceBoundSessions(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    enableDeviceBoundSessionsParams params;
    if (!enableDeviceBoundSessionsParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->EnableDeviceBoundSessions(params.enable);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

namespace {

struct deleteDeviceBoundSessionParams : public crdtp::DeserializableProtocolObject<deleteDeviceBoundSessionParams> {
    std::unique_ptr<protocol::Network::DeviceBoundSessionKey> key;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(deleteDeviceBoundSessionParams)
    CRDTP_DESERIALIZE_FIELD("key", key),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::deleteDeviceBoundSession(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    deleteDeviceBoundSessionParams params;
    if (!deleteDeviceBoundSessionParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->DeleteDeviceBoundSession(std::move(params.key));
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

namespace {

struct fetchSchemefulSiteParams : public crdtp::DeserializableProtocolObject<fetchSchemefulSiteParams> {
    String origin;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(fetchSchemefulSiteParams)
    CRDTP_DESERIALIZE_FIELD("origin", origin),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::fetchSchemefulSite(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    fetchSchemefulSiteParams params;
    if (!fetchSchemefulSiteParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }
    // Declare output parameters.
    String out_schemefulSite;

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->FetchSchemefulSite(params.origin, &out_schemefulSite);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
      if (weak->get()) {
        std::unique_ptr<crdtp::Serializable> result;
        if (response.IsSuccess()) {
          crdtp::ObjectSerializer serializer;
          serializer.AddField(crdtp::MakeSpan("schemefulSite"), out_schemefulSite);
          result = serializer.Finish();
        } else {
          result = Serializable::From({});
        }
        weak->get()->sendResponse(dispatchable.CallId(), response, std::move(result));
      }
    return;
}

class LoadNetworkResourceCallbackImpl : public Backend::LoadNetworkResourceCallback, public DomainDispatcher::Callback {
public:
    LoadNetworkResourceCallbackImpl(std::unique_ptr<DomainDispatcher::WeakPtr> backendImpl, crdtp::Dispatchable& dispatchable)
        : DomainDispatcher::Callback(std::move(backendImpl), dispatchable, crdtp::SpanFrom("Network.loadNetworkResource")) { }

    void sendSuccess(std::unique_ptr<protocol::Network::LoadNetworkResourcePageResult> resource) override
    {
        crdtp::ObjectSerializer serializer;
        serializer.AddField(crdtp::MakeSpan("resource"), resource);
        sendIfActive(serializer.Finish(), DispatchResponse::Success());
    }

    void fallThrough() override
    {
        fallThroughIfActive();
    }

    void sendFailure(const DispatchResponse& response) override
    {
        DCHECK(response.IsError());
        sendIfActive(nullptr, response);
    }
};

namespace {

struct loadNetworkResourceParams : public crdtp::DeserializableProtocolObject<loadNetworkResourceParams> {
    std::optional<String> frameId;
    String url;
    std::unique_ptr<protocol::Network::LoadNetworkResourceOptions> options;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(loadNetworkResourceParams)
    CRDTP_DESERIALIZE_FIELD_OPT("frameId", frameId),
    CRDTP_DESERIALIZE_FIELD("options", options),
    CRDTP_DESERIALIZE_FIELD("url", url),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::loadNetworkResource(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    loadNetworkResourceParams params;
    if (!loadNetworkResourceParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    m_backend->LoadNetworkResource(std::move(params.frameId), params.url, std::move(params.options), std::make_unique<LoadNetworkResourceCallbackImpl>(weakPtr(), dispatchable));
}

namespace {

struct setCookieControlsParams : public crdtp::DeserializableProtocolObject<setCookieControlsParams> {
    bool enableThirdPartyCookieRestriction;
    DECLARE_DESERIALIZATION_SUPPORT();
};

CRDTP_BEGIN_DESERIALIZER(setCookieControlsParams)
    CRDTP_DESERIALIZE_FIELD("enableThirdPartyCookieRestriction", enableThirdPartyCookieRestriction),
CRDTP_END_DESERIALIZER()

}  // namespace

void DomainDispatcherImpl::setCookieControls(crdtp::Dispatchable& dispatchable)
{
    // Prepare input parameters.
    auto deserializer = crdtp::DeferredMessage::FromSpan(dispatchable.Params())->MakeDeserializer();
    setCookieControlsParams params;
    if (!setCookieControlsParams::Deserialize(&deserializer, &params)) {
      ReportInvalidParams(dispatchable, deserializer);
      return;
    }

    std::unique_ptr<DomainDispatcher::WeakPtr> weak = weakPtr();
    DispatchResponse response = m_backend->SetCookieControls(params.enableThirdPartyCookieRestriction);
    if (response.IsFallThrough()) {
        dispatchable.DispatchFallThrough(response.Message());
        return;
    }
    if (weak->get())
        weak->get()->sendResponse(dispatchable.CallId(), response);
    return;
}

namespace {
// This helper method (with a static map of redirects) is used from Dispatcher::wire
// immediately below.
const std::vector<std::pair<crdtp::span<uint8_t>, crdtp::span<uint8_t>>>& SortedRedirects() {
  static auto* redirects = [](){
    auto* redirects = new std::vector<std::pair<crdtp::span<uint8_t>, crdtp::span<uint8_t>>>{
          { crdtp::SpanFrom("Network.setUserAgentOverride"), crdtp::SpanFrom("Emulation.setUserAgentOverride") },
    };
    return redirects;
  }();
  return *redirects;
}
}  // namespace

// static
void Dispatcher::wire(UberDispatcher* uber, Backend* backend)
{
    auto dispatcher = std::make_unique<DomainDispatcherImpl>(uber->channel(), backend);
    uber->WireBackend(crdtp::SpanFrom("Network"), SortedRedirects(), std::move(dispatcher));
}

} // Network
} // namespace content
} // namespace protocol
