NetworkLoadInformation.h [plain text]
#pragma once
#include "NetworkLoadMetrics.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include <wtf/Vector.h>
namespace WebCore {
struct NetworkTransactionInformation {
enum class Type { Redirection, Preflight };
Type type;
ResourceRequest request;
ResourceResponse response;
NetworkLoadMetrics metrics;
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static Optional<NetworkTransactionInformation> decode(Decoder&);
};
struct NetworkLoadInformation {
ResourceRequest request;
ResourceResponse response;
NetworkLoadMetrics metrics;
Vector<NetworkTransactionInformation> transactions;
};
}
namespace WTF {
template<> struct EnumTraits<WebCore::NetworkTransactionInformation::Type> {
using values = EnumValues<
WebCore::NetworkTransactionInformation::Type,
WebCore::NetworkTransactionInformation::Type::Redirection,
WebCore::NetworkTransactionInformation::Type::Preflight
>;
};
}
namespace WebCore {
template<class Encoder> inline void NetworkTransactionInformation::encode(Encoder& encoder) const
{
encoder << type;
encoder << request;
encoder << response;
encoder << metrics;
}
template<class Decoder> inline Optional<NetworkTransactionInformation> NetworkTransactionInformation::decode(Decoder& decoder)
{
NetworkTransactionInformation information;
if (!decoder.decode(information.type))
return WTF::nullopt;
if (!decoder.decode(information.request))
return WTF::nullopt;
if (!decoder.decode(information.response))
return WTF::nullopt;
if (!decoder.decode(information.metrics))
return WTF::nullopt;
return information;
}
}