NetworkSessionCreationParameters.h [plain text]
#pragma once
#include "ArgumentCoders.h"
#include <pal/SessionID.h>
#include <wtf/EnumTraits.h>
#include <wtf/text/WTFString.h>
namespace WebKit {
class LegacyCustomProtocolManager;
enum class AllowsCellularAccess { No, Yes };
struct NetworkSessionCreationParameters {
void encode(IPC::Encoder&) const;
static std::optional<NetworkSessionCreationParameters> decode(IPC::Decoder&);
PAL::SessionID sessionID { PAL::SessionID::defaultSessionID() };
LegacyCustomProtocolManager* legacyCustomProtocolManager { nullptr };
String boundInterfaceIdentifier;
AllowsCellularAccess allowsCellularAccess { AllowsCellularAccess::Yes };
};
inline void NetworkSessionCreationParameters::encode(IPC::Encoder& encoder) const
{
encoder << sessionID;
encoder << boundInterfaceIdentifier;
encoder << allowsCellularAccess;
}
inline std::optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::decode(IPC::Decoder& decoder)
{
PAL::SessionID sessionID;
if (!decoder.decode(sessionID))
return std::nullopt;
std::optional<String> boundInterfaceIdentifier;
decoder >> boundInterfaceIdentifier;
if (!boundInterfaceIdentifier)
return std::nullopt;
std::optional<AllowsCellularAccess> allowsCellularAccess;
decoder >> allowsCellularAccess;
if (!allowsCellularAccess)
return std::nullopt;
return {{ sessionID, nullptr, WTFMove(*boundInterfaceIdentifier), WTFMove(*allowsCellularAccess) }};
}
}
namespace WTF {
template<> struct EnumTraits<WebKit::AllowsCellularAccess> {
using values = EnumValues<
WebKit::AllowsCellularAccess,
WebKit::AllowsCellularAccess::No,
WebKit::AllowsCellularAccess::Yes
>;
};
}