#include "components/sync/model/data_type_store_backend.h"
#include <memory>
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/task/sequenced_task_runner.h"
#include "components/sync/protocol/data_type_store_schema_descriptor.pb.h"
#include "third_party/leveldatabase/env_chromium.h"
#include "third_party/leveldatabase/leveldb_chrome.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h"
#include "third_party/leveldatabase/src/include/leveldb/iterator.h"
#include "third_party/leveldatabase/src/include/leveldb/options.h"
#include "third_party/leveldatabase/src/include/leveldb/slice.h"
#include "third_party/leveldatabase/src/include/leveldb/status.h"
#include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
DataTypeStoreSchemaDescriptor;
namespace syncer {
const int64_t kInvalidSchemaVersion = …;
const int64_t DataTypeStoreBackend::kLatestSchemaVersion = …;
const char DataTypeStoreBackend::kDBSchemaDescriptorRecordId[] = …;
namespace {
void LogDbStatusByCallingSiteIfNeeded(const std::string& calling_site,
leveldb::Status status) { … }
}
DataTypeStoreBackend::CustomOnTaskRunnerDeleter::CustomOnTaskRunnerDeleter(
scoped_refptr<base::SequencedTaskRunner> task_runner)
: … { … }
DataTypeStoreBackend::CustomOnTaskRunnerDeleter::CustomOnTaskRunnerDeleter(
CustomOnTaskRunnerDeleter&&) = default;
DataTypeStoreBackend::CustomOnTaskRunnerDeleter&
DataTypeStoreBackend::CustomOnTaskRunnerDeleter::operator=(
CustomOnTaskRunnerDeleter&&) = default;
DataTypeStoreBackend::CustomOnTaskRunnerDeleter::~CustomOnTaskRunnerDeleter() =
default;
scoped_refptr<DataTypeStoreBackend>
DataTypeStoreBackend::CreateInMemoryForTest() { … }
scoped_refptr<DataTypeStoreBackend>
DataTypeStoreBackend::CreateUninitialized() { … }
DataTypeStoreBackend::~DataTypeStoreBackend() = default;
std::optional<ModelError> DataTypeStoreBackend::Init(
const base::FilePath& path,
const std::vector<std::pair<std::string, std::string>>&
prefixes_to_update) { … }
bool DataTypeStoreBackend::IsInitialized() const { … }
DataTypeStoreBackend::DataTypeStoreBackend(std::unique_ptr<leveldb::Env> env)
: … { … }
leveldb::Status DataTypeStoreBackend::OpenDatabase(const std::string& path,
leveldb::Env* env) { … }
leveldb::Status DataTypeStoreBackend::DestroyDatabase(const std::string& path,
leveldb::Env* env) { … }
std::optional<ModelError> DataTypeStoreBackend::ReadRecordsWithPrefix(
const std::string& prefix,
const DataTypeStore::IdList& id_list,
DataTypeStore::RecordList* record_list,
DataTypeStore::IdList* missing_id_list) { … }
std::optional<ModelError> DataTypeStoreBackend::ReadAllRecordsWithPrefix(
const std::string& prefix,
DataTypeStore::RecordList* record_list) { … }
std::optional<ModelError> DataTypeStoreBackend::WriteModifications(
std::unique_ptr<leveldb::WriteBatch> write_batch) { … }
std::optional<ModelError> DataTypeStoreBackend::DeleteDataAndMetadataForPrefix(
const std::string& prefix) { … }
std::optional<ModelError> DataTypeStoreBackend::MigrateForTest(
int64_t current_version,
int64_t desired_version) { … }
int64_t DataTypeStoreBackend::GetStoreVersionForTest() { … }
int64_t DataTypeStoreBackend::GetStoreVersion() { … }
std::optional<ModelError> DataTypeStoreBackend::Migrate(
int64_t current_version,
int64_t desired_version) { … }
bool DataTypeStoreBackend::Migrate0To1() { … }
std::optional<ModelError> DataTypeStoreBackend::UpdateDataPrefix(
const std::string& old_prefix,
const std::string& new_prefix) { … }
}