#ifndef COMPONENTS_SESSION_PROTO_DB_SESSION_PROTO_DB_H_
#define COMPONENTS_SESSION_PROTO_DB_SESSION_PROTO_DB_H_
#include <memory>
#include <optional>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "components/commerce/core/proto/persisted_state_db_content.pb.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/leveldb_proto/public/proto_database.h"
#include "components/leveldb_proto/public/proto_database_provider.h"
#include "components/session_proto_db/session_proto_storage.h"
#include "third_party/leveldatabase/src/include/leveldb/options.h"
namespace {
const char kOrphanedDataCountHistogramName[] = …;
}
class SessionProtoDBTest;
template <typename T>
class SessionProtoDBFactory;
template <typename T>
class SessionProtoDB : public KeyedService, public SessionProtoStorage<T> { … };
template <typename T>
SessionProtoDB<T>::SessionProtoDB(
leveldb_proto::ProtoDatabaseProvider* proto_database_provider,
const base::FilePath& database_dir,
leveldb_proto::ProtoDbType proto_db_type,
scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner)
: … { … }
template <typename T>
SessionProtoDB<T>::~SessionProtoDB() = default;
template <typename T>
void SessionProtoDB<T>::LoadOneEntry(const std::string& key,
LoadCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::LoadAllEntries(LoadCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::LoadContentWithPrefix(const std::string& key_prefix,
LoadCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::PerformMaintenance(
const std::vector<std::string>& keys_to_keep,
const std::string& key_substring_to_match,
OperationCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::InsertContent(const std::string& key,
const T& value,
OperationCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::DeleteOneEntry(const std::string& key,
OperationCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::UpdateEntries(
std::unique_ptr<ContentEntry> entries_to_update,
std::unique_ptr<std::vector<std::string>> keys_to_remove,
OperationCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::DeleteContentWithPrefix(const std::string& key_prefix,
OperationCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::DeleteAllContent(OperationCallback callback) { … }
template <typename T>
void SessionProtoDB<T>::Destroy() const { … }
template <typename T>
SessionProtoDB<T>::SessionProtoDB(
std::unique_ptr<leveldb_proto::ProtoDatabase<T>> storage_database,
scoped_refptr<base::SequencedTaskRunner> task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner)
: … { … }
template <typename T>
void SessionProtoDB<T>::OnDatabaseInitialized(
leveldb_proto::Enums::InitStatus status) { … }
template <typename T>
void SessionProtoDB<T>::OnLoadOneEntry(LoadCallback callback,
bool success,
std::unique_ptr<T> entry) { … }
template <typename T>
void SessionProtoDB<T>::OnLoadContent(LoadCallback callback,
bool success,
std::unique_ptr<std::vector<T>> content) { … }
template <typename T>
void SessionProtoDB<T>::OnPerformMaintenance(
OperationCallback callback,
bool success,
std::unique_ptr<std::vector<T>> entries_to_delete) { … }
template <typename T>
void SessionProtoDB<T>::OnOperationCommitted(OperationCallback callback,
bool success) { … }
template <typename T>
bool SessionProtoDB<T>::InitStatusUnknown() const { … }
template <typename T>
bool SessionProtoDB<T>::FailedToInit() const { … }
#endif