chromium/components/metrics/persistent_system_profile.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#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 {

// To provide atomic addition of records so that there is no confusion between
// writers and readers, all of the metadata about a record is contained in a
// structure that can be stored as a single atomic 32-bit word.
RecordHeader;

constexpr uint32_t kTypeIdSystemProfile =;  // SHA1(SystemProfile)
constexpr size_t kSystemProfileAllocSize =;    // 4 KiB
constexpr size_t kMaxRecordSize =;
constexpr char kFieldTrialDeletionSentinel[] =;

static_assert;

// Calculate the size of a record based on the amount of data. This adds room
// for the record header and rounds up to the next multiple of the record-header
// size.
size_t CalculateRecordSize(size_t data_amount) {}

}  // namespace

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) {}
// static
bool PersistentSystemProfile::HasSystemProfile(
    const base::PersistentMemoryAllocator& memory_allocator) {}

// static
bool PersistentSystemProfile::GetSystemProfile(
    const base::PersistentMemoryAllocator& memory_allocator,
    SystemProfileProto* system_profile) {}

// static
void PersistentSystemProfile::MergeUpdateRecords(
    const base::PersistentMemoryAllocator& memory_allocator,
    SystemProfileProto* system_profile) {}

void PersistentSystemProfile::WriteToAll(RecordType type,
                                         std::string_view record) {}

GlobalPersistentSystemProfile* GlobalPersistentSystemProfile::GetInstance() {}

}  // namespace metrics