#include "components/browsing_topics/util.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "crypto/hmac.h"
#include "crypto/sha2.h"
#include "third_party/blink/public/common/features.h"
namespace browsing_topics {
namespace {
const char kRandomOrTopTopicDecisionPrefix[] = …;
const char kRandomTopicIndexDecisionPrefix[] = …;
const char kTopTopicIndexDecisionPrefix[] = …;
const char kEpochSwitchTimeDecisionPrefix[] = …;
const char kContextDomainStoragePrefix[] = …;
const char kMainFrameHostStoragePrefix[] = …;
uint64_t HmacHash(ReadOnlyHmacKey hmac_key,
const std::string& use_case_prefix,
const std::string& data) { … }
bool g_hmac_key_overridden = …;
browsing_topics::HmacKey& GetHmacKeyOverrideForTesting() { … }
}
bool DoesCalculationFailDueToHanging(CalculatorResultStatus status) { … }
HmacKey GenerateRandomHmacKey() { … }
uint64_t HashTopDomainForRandomOrTopTopicDecision(
ReadOnlyHmacKey hmac_key,
base::Time epoch_calculation_time,
const std::string& top_domain) { … }
uint64_t HashTopDomainForRandomTopicIndexDecision(
ReadOnlyHmacKey hmac_key,
base::Time epoch_calculation_time,
const std::string& top_domain) { … }
uint64_t HashTopDomainForTopTopicIndexDecision(
ReadOnlyHmacKey hmac_key,
base::Time epoch_calculation_time,
const std::string& top_domain) { … }
uint64_t HashTopDomainForEpochSwitchTimeDecision(
ReadOnlyHmacKey hmac_key,
const std::string& top_domain) { … }
HashedDomain HashContextDomainForStorage(ReadOnlyHmacKey hmac_key,
const std::string& context_domain) { … }
HashedHost HashMainFrameHostForStorage(const std::string& main_frame_host) { … }
void OverrideHmacKeyForTesting(ReadOnlyHmacKey hmac_key) { … }
}