#include "components/metrics/structured/lib/persistent_proto_internal.h"
#include <atomic>
#include <memory>
#include <string>
#include <utility>
#include "base/files/file_util.h"
#include "base/files/important_file_writer.h"
#include "base/functional/bind.h"
#include "base/rand_util.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
namespace metrics::structured::internal {
namespace {
base::expected<std::string, ReadStatus> Read(const base::FilePath& filepath) { … }
}
PersistentProtoInternal::PersistentProtoInternal(
const base::FilePath& path,
base::TimeDelta write_delay,
PersistentProtoInternal::ReadCallback on_read,
PersistentProtoInternal::WriteCallback on_write)
: … { … }
PersistentProtoInternal::~PersistentProtoInternal() = default;
void PersistentProtoInternal::OnReadComplete(
ReadCallback callback,
base::expected<std::string, ReadStatus> read_status) { … }
void PersistentProtoInternal::QueueWrite() { … }
void PersistentProtoInternal::OnWriteAttempt(bool write_successful) { … }
void PersistentProtoInternal::OnWriteComplete(const WriteStatus status) { … }
void PersistentProtoInternal::Purge() { … }
std::optional<std::string> PersistentProtoInternal::SerializeData() { … }
void PersistentProtoInternal::StartWriteForTesting() { … }
void PersistentProtoInternal::UpdatePath(const base::FilePath& path,
ReadCallback on_read,
bool remove_existing) { … }
void PersistentProtoInternal::DeallocProto() { … }
void PersistentProtoInternal::QueueFileDelete() { … }
void PersistentProtoInternal::FlushQueuedWrites() { … }
}