#include "components/metrics/structured/lib/key_data.h"
#include <memory>
#include <utility>
#include "base/check.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/rand_util.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "components/metrics/structured/lib/histogram_util.h"
#include "components/metrics/structured/lib/key_util.h"
#include "crypto/hmac.h"
#include "crypto/sha2.h"
namespace metrics::structured {
namespace {
std::string HashToHex(const uint64_t hash) { … }
int NowInDays() { … }
}
KeyData::KeyData(std::unique_ptr<StorageDelegate> storage_delegate)
: … { … }
KeyData::~KeyData() = default;
uint64_t KeyData::Id(const uint64_t project_name_hash,
base::TimeDelta key_rotation_period) { … }
uint64_t KeyData::HmacMetric(const uint64_t project_name_hash,
const uint64_t metric_name_hash,
const std::string& value,
base::TimeDelta key_rotation_period) { … }
std::optional<base::TimeDelta> KeyData::LastKeyRotation(
const uint64_t project_name_hash) const { … }
std::optional<int> KeyData::GetKeyAgeInWeeks(uint64_t project_name_hash) const { … }
void KeyData::Purge() { … }
void KeyData::EnsureKeyUpdated(const uint64_t project_name_hash,
base::TimeDelta key_rotation_period) { … }
const std::optional<std::string_view> KeyData::GetKeyBytes(
const uint64_t project_name_hash) const { … }
}