#include "services/network/cors/preflight_cache.h"
#include <iterator>
#include <string>
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_with_source.h"
#include "services/network/data_remover_util.h"
#include "services/network/public/mojom/clear_data_filter.mojom.h"
#include "url/gurl.h"
namespace network::cors {
namespace {
constexpr size_t kMaxCacheEntries = …;
constexpr size_t kMaxKeyLength = …;
constexpr size_t kPurgeUnit = …;
enum class CacheMetric { … };
base::Value::Dict NetLogCacheStatusParams(const CacheMetric metric) { … }
void RecordCacheMetricNetLog(CacheMetric metric,
const net::NetLogWithSource& net_log) { … }
}
PreflightCache::PreflightCache() = default;
PreflightCache::~PreflightCache() = default;
void PreflightCache::AppendEntry(
const url::Origin& origin,
const GURL& url,
const net::NetworkIsolationKey& network_isolation_key,
mojom::IPAddressSpace target_ip_address_space,
std::unique_ptr<PreflightResult> preflight_result) { … }
bool PreflightCache::CheckIfRequestCanSkipPreflight(
const url::Origin& origin,
const GURL& url,
const net::NetworkIsolationKey& network_isolation_key,
mojom::IPAddressSpace target_ip_address_space,
mojom::CredentialsMode credentials_mode,
const std::string& method,
const net::HttpRequestHeaders& request_headers,
bool is_revalidating,
const net::NetLogWithSource& net_log,
bool acam_preflight_spec_conformant) { … }
void PreflightCache::ClearCache(mojom::ClearDataFilterPtr url_filter) { … }
size_t PreflightCache::CountEntriesForTesting() const { … }
bool PreflightCache::DoesEntryExistForTesting(
const url::Origin& origin,
const std::string& url,
const net::NetworkIsolationKey& network_isolation_key,
mojom::IPAddressSpace target_ip_address_space) { … }
void PreflightCache::MayPurgeForTesting(size_t max_entries, size_t purge_unit) { … }
void PreflightCache::MayPurge(size_t max_entries, size_t purge_unit) { … }
}