#ifndef NET_REPORTING_REPORTING_HEADER_PARSER_H_
#define NET_REPORTING_REPORTING_HEADER_PARSER_H_
#include <memory>
#include <optional>
#include "base/containers/flat_map.h"
#include "base/values.h"
#include "net/base/net_export.h"
#include "net/http/structured_headers.h"
#include "url/origin.h"
namespace net {
class IsolationInfo;
class NetworkAnonymizationKey;
class ReportingContext;
NET_EXPORT
std::optional<base::flat_map<std::string, std::string>> ParseReportingEndpoints(
const std::string& header);
class NET_EXPORT ReportingHeaderParser {
public:
enum class ReportingHeaderType {
kReportTo = 0,
kReportToInvalid = 1,
kReportingEndpoints = 2,
kReportingEndpointsInvalid = 3,
kMaxValue = kReportingEndpointsInvalid,
};
ReportingHeaderParser() = delete;
ReportingHeaderParser(const ReportingHeaderParser&) = delete;
ReportingHeaderParser& operator=(const ReportingHeaderParser&) = delete;
static void ParseReportToHeader(
ReportingContext* context,
const NetworkAnonymizationKey& network_anonymization_key,
const url::Origin& origin,
const base::Value::List& list);
static void ProcessParsedReportingEndpointsHeader(
ReportingContext* context,
const base::UnguessableToken& reporting_source,
const IsolationInfo& isolation_info,
const NetworkAnonymizationKey& network_anonymization_key,
const url::Origin& origin,
base::flat_map<std::string, std::string> parsed_header);
static void RecordReportingHeaderType(ReportingHeaderType header_type);
};
}
#endif