#include "components/sessions/core/command_storage_manager.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/scoped_refptr.h"
#include "base/ranges/algorithm.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread.h"
#include "components/sessions/core/command_storage_backend.h"
#include "components/sessions/core/command_storage_manager_delegate.h"
#include "crypto/random.h"
namespace sessions {
namespace {
constexpr base::TimeDelta kSaveDelay = …;
void AdaptGetLastSessionCommands(
CommandStorageManager::GetCommandsCallback callback,
CommandStorageBackend::ReadCommandsResult result) { … }
}
CommandStorageManager::CommandStorageManager(
SessionType type,
const base::FilePath& path,
CommandStorageManagerDelegate* delegate,
bool enable_crypto,
const std::vector<uint8_t>& decryption_key,
scoped_refptr<base::SequencedTaskRunner> backend_task_runner)
: … { … }
CommandStorageManager::~CommandStorageManager() = default;
scoped_refptr<base::SequencedTaskRunner>
CommandStorageManager::CreateDefaultBackendTaskRunner() { … }
std::vector<uint8_t> CommandStorageManager::CreateCryptoKey() { … }
void CommandStorageManager::ScheduleCommand(
std::unique_ptr<SessionCommand> command) { … }
void CommandStorageManager::AppendRebuildCommand(
std::unique_ptr<SessionCommand> command) { … }
void CommandStorageManager::AppendRebuildCommands(
std::vector<std::unique_ptr<SessionCommand>> commands) { … }
void CommandStorageManager::EraseCommand(SessionCommand* old_command) { … }
void CommandStorageManager::SwapCommand(
SessionCommand* old_command,
std::unique_ptr<SessionCommand> new_command) { … }
void CommandStorageManager::ClearPendingCommands() { … }
void CommandStorageManager::StartSaveTimer() { … }
void CommandStorageManager::Save() { … }
bool CommandStorageManager::HasPendingSave() const { … }
void CommandStorageManager::MoveCurrentSessionToLastSession() { … }
void CommandStorageManager::DeleteLastSession() { … }
void CommandStorageManager::GetLastSessionCommands(
GetCommandsCallback callback) { … }
void CommandStorageManager::OnErrorWritingToFile() { … }
}