#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/metrics/persistent_system_profile.h"
#include <set>
#include <string_view>
#include <vector>
#include "base/atomicops.h"
#include "base/bits.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/debug/crash_logging.h"
#include "base/memory/singleton.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/notreached.h"
#include "base/pickle.h"
#include "components/variations/active_field_trials.h"
namespace metrics {
namespace {
RecordHeader;
constexpr uint32_t kTypeIdSystemProfile = …;
constexpr size_t kSystemProfileAllocSize = …;
constexpr size_t kMaxRecordSize = …;
constexpr char kFieldTrialDeletionSentinel[] = …;
static_assert …;
size_t CalculateRecordSize(size_t data_amount) { … }
}
PersistentSystemProfile::RecordAllocator::RecordAllocator(
base::PersistentMemoryAllocator* memory_allocator,
size_t min_size)
: … { … }
PersistentSystemProfile::RecordAllocator::RecordAllocator(
const base::PersistentMemoryAllocator* memory_allocator)
: … { … }
void PersistentSystemProfile::RecordAllocator::Reset() { … }
bool PersistentSystemProfile::RecordAllocator::Write(RecordType type,
std::string_view record) { … }
bool PersistentSystemProfile::RecordAllocator::HasMoreData() const { … }
bool PersistentSystemProfile::RecordAllocator::Read(RecordType* type,
std::string* record) const { … }
bool PersistentSystemProfile::RecordAllocator::NextSegment() const { … }
bool PersistentSystemProfile::RecordAllocator::AddSegment(size_t min_size) { … }
bool PersistentSystemProfile::RecordAllocator::WriteData(RecordType type,
const char** data,
size_t* data_size) { … }
bool PersistentSystemProfile::RecordAllocator::ReadData(
RecordType* type,
std::string* record) const { … }
PersistentSystemProfile::PersistentSystemProfile() { … }
PersistentSystemProfile::~PersistentSystemProfile() { … }
void PersistentSystemProfile::RegisterPersistentAllocator(
base::PersistentMemoryAllocator* memory_allocator) { … }
void PersistentSystemProfile::DeregisterPersistentAllocator(
base::PersistentMemoryAllocator* memory_allocator) { … }
void PersistentSystemProfile::SetSystemProfile(
const std::string& serialized_profile,
bool complete) { … }
void PersistentSystemProfile::SetSystemProfile(
const SystemProfileProto& profile,
bool complete) { … }
void PersistentSystemProfile::AddFieldTrial(std::string_view trial,
std::string_view group) { … }
void PersistentSystemProfile::RemoveFieldTrial(std::string_view trial) { … }
bool PersistentSystemProfile::HasSystemProfile(
const base::PersistentMemoryAllocator& memory_allocator) { … }
bool PersistentSystemProfile::GetSystemProfile(
const base::PersistentMemoryAllocator& memory_allocator,
SystemProfileProto* system_profile) { … }
void PersistentSystemProfile::MergeUpdateRecords(
const base::PersistentMemoryAllocator& memory_allocator,
SystemProfileProto* system_profile) { … }
void PersistentSystemProfile::WriteToAll(RecordType type,
std::string_view record) { … }
GlobalPersistentSystemProfile* GlobalPersistentSystemProfile::GetInstance() { … }
}