#include "components/download/database/download_db_impl.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/task/thread_pool.h"
#include "components/download/database/download_db_conversions.h"
#include "components/download/database/download_db_entry.h"
#include "components/download/database/proto/download_entry.pb.h"
#include "components/leveldb_proto/public/proto_database_provider.h"
namespace download {
namespace {
const int kMaxNumInitializeAttempts = …;
ProtoKeyVector;
ProtoEntryVector;
ProtoKeyEntryVector;
std::string GetDatabaseKeyPrefix(DownloadNamespace download_namespace) { … }
bool IsUnderNameSpace(DownloadNamespace download_namespace,
const std::string& key) { … }
void OnUpdateDone(bool success) { … }
}
DownloadDBImpl::DownloadDBImpl(
DownloadNamespace download_namespace,
const base::FilePath& database_dir,
leveldb_proto::ProtoDatabaseProvider* db_provider)
: … { … }
DownloadDBImpl::DownloadDBImpl(
DownloadNamespace download_namespace,
std::unique_ptr<leveldb_proto::ProtoDatabase<download_pb::DownloadDBEntry>>
db)
: … { … }
DownloadDBImpl::~DownloadDBImpl() = default;
bool DownloadDBImpl::IsInitialized() { … }
void DownloadDBImpl::Initialize(DownloadDBCallback callback) { … }
void DownloadDBImpl::DestroyAndReinitialize(DownloadDBCallback callback) { … }
void DownloadDBImpl::AddOrReplace(const DownloadDBEntry& entry) { … }
void DownloadDBImpl::AddOrReplaceEntries(
const std::vector<DownloadDBEntry>& entries,
DownloadDBCallback callback) { … }
void DownloadDBImpl::LoadEntries(LoadEntriesCallback callback) { … }
void DownloadDBImpl::Remove(const std::string& guid) { … }
std::string DownloadDBImpl::GetEntryKey(const std::string& guid) const { … }
void DownloadDBImpl::OnAllEntriesLoaded(
LoadEntriesCallback callback,
bool success,
std::unique_ptr<ProtoEntryVector> entries) { … }
void DownloadDBImpl::OnDatabaseInitialized(
DownloadDBCallback callback,
leveldb_proto::Enums::InitStatus status) { … }
void DownloadDBImpl::OnDatabaseDestroyed(DownloadDBCallback callback,
bool success) { … }
void DownloadDBImpl::OnRemoveDone(bool success) { … }
}