chromium/components/browsing_topics/util.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// Note that updating the use case prefixes below will change the pre-existing
// per-user stickiness. Some of the derived data may already have been persisted
// elsewhere. Be sure you are aware of the implications before updating those
// strings. Note also that the version here is just about the hash method, and
// is distinctive from the broader configuration version of the Topics API.
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() {}

}  // namespace

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) {}

}  // namespace browsing_topics