chromium/components/prefs/json_pref_store.cc

// Copyright 2012 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/prefs/json_pref_store.h"

#include <stddef.h>

#include <algorithm>
#include <string>
#include <string_view>
#include <utility>

#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/hash/hash.h"
#include "base/json/json_file_value_serializer.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/default_clock.h"
#include "base/values.h"
#include "components/prefs/pref_filter.h"

// Result returned from internal read tasks.
struct JsonPrefStore::ReadResult {};

JsonPrefStore::ReadResult::ReadResult() = default;
JsonPrefStore::ReadResult::~ReadResult() = default;

namespace {

// Some extensions we'll tack on to copies of the Preferences files.
const base::FilePath::CharType kBadExtension[] =);

// Report a key that triggers a write into the Preferences files.
void ReportKeyChangedToUMA(std::string_view key) {}

bool BackupPrefsFile(const base::FilePath& path) {}

PersistentPrefStore::PrefReadError HandleReadErrors(
    const base::Value* value,
    const base::FilePath& path,
    int error_code,
    const std::string& error_msg) {}

std::unique_ptr<JsonPrefStore::ReadResult> ReadPrefsFromDisk(
    const base::FilePath& path) {}

// Returns the a histogram suffix for a few allowlisted JsonPref files.
const char* GetHistogramSuffix(const base::FilePath& path) {}

std::optional<std::string> DoSerialize(base::ValueView value,
                                       const base::FilePath& path) {}

}  // namespace

JsonPrefStore::JsonPrefStore(
    const base::FilePath& pref_filename,
    std::unique_ptr<PrefFilter> pref_filter,
    scoped_refptr<base::SequencedTaskRunner> file_task_runner,
    bool read_only)
    :{}

bool JsonPrefStore::GetValue(std::string_view key,
                             const base::Value** result) const {}

base::Value::Dict JsonPrefStore::GetValues() const {}

void JsonPrefStore::AddObserver(PrefStore::Observer* observer) {}

void JsonPrefStore::RemoveObserver(PrefStore::Observer* observer) {}

bool JsonPrefStore::HasObservers() const {}

bool JsonPrefStore::IsInitializationComplete() const {}

bool JsonPrefStore::GetMutableValue(std::string_view key,
                                    base::Value** result) {}

void JsonPrefStore::SetValue(std::string_view key,
                             base::Value value,
                             uint32_t flags) {}

void JsonPrefStore::SetValueSilently(std::string_view key,
                                     base::Value value,
                                     uint32_t flags) {}

void JsonPrefStore::RemoveValue(std::string_view key, uint32_t flags) {}

void JsonPrefStore::RemoveValueSilently(std::string_view key, uint32_t flags) {}

void JsonPrefStore::RemoveValuesByPrefixSilently(std::string_view prefix) {}

bool JsonPrefStore::ReadOnly() const {}

PersistentPrefStore::PrefReadError JsonPrefStore::GetReadError() const {}

PersistentPrefStore::PrefReadError JsonPrefStore::ReadPrefs() {}

void JsonPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate) {}

void JsonPrefStore::CommitPendingWrite(
    base::OnceClosure reply_callback,
    base::OnceClosure synchronous_done_callback) {}

void JsonPrefStore::SchedulePendingLossyWrites() {}

void JsonPrefStore::ReportValueChanged(std::string_view key, uint32_t flags) {}

void JsonPrefStore::PerformPreserializationTasks() {}

void JsonPrefStore::RunOrScheduleNextSuccessfulWriteCallback(
    bool write_success) {}

// static
void JsonPrefStore::PostWriteCallback(
    base::OnceCallback<void(bool success)> on_next_write_callback,
    base::OnceCallback<void(bool success)> on_next_write_reply,
    scoped_refptr<base::SequencedTaskRunner> reply_task_runner,
    bool write_success) {}

void JsonPrefStore::RegisterOnNextSuccessfulWriteReply(
    base::OnceClosure on_next_successful_write_reply) {}

void JsonPrefStore::RegisterOnNextWriteSynchronousCallbacks(
    OnWriteCallbackPair callbacks) {}

void JsonPrefStore::OnStoreDeletionFromDisk() {}

void JsonPrefStore::OnFileRead(std::unique_ptr<ReadResult> read_result) {}

JsonPrefStore::~JsonPrefStore() {}

std::optional<std::string> JsonPrefStore::SerializeData() {}

base::ImportantFileWriter::BackgroundDataProducerCallback
JsonPrefStore::GetSerializedDataProducerForBackgroundSequence() {}

void JsonPrefStore::FinalizeFileRead(bool initialization_successful,
                                     base::Value::Dict prefs,
                                     bool schedule_write) {}

void JsonPrefStore::ScheduleWrite(uint32_t flags) {}

bool JsonPrefStore::HasReadErrorDelegate() const {}