#include "content/browser/media/cdm_storage_database.h"
#include <algorithm>
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/json/values_util.h"
#include "base/metrics/histogram_functions.h"
#include "sql/statement.h"
namespace content {
namespace {
static const int kVersionNumber = …;
const char kUmaPrefix[] = …;
const char kDeleteForTimeFrameError[] = …;
const char kDeleteForStorageKeyError[] = …;
const char kDeleteForFilterError[] = …;
const char kDeleteFileError[] = …;
static bool DatabaseIsEmpty(sql::Database* db) { … }
}
CdmStorageDatabase::CdmStorageDatabase(const base::FilePath& path)
: … { … }
CdmStorageDatabase::~CdmStorageDatabase() = default;
CdmStorageOpenError CdmStorageDatabase::EnsureOpen() { … }
std::optional<std::vector<uint8_t>> CdmStorageDatabase::ReadFile(
const blink::StorageKey& storage_key,
const media::CdmType& cdm_type,
const std::string& file_name) { … }
bool CdmStorageDatabase::WriteFile(const blink::StorageKey& storage_key,
const media::CdmType& cdm_type,
const std::string& file_name,
const std::vector<uint8_t>& data) { … }
std::optional<uint64_t> CdmStorageDatabase::GetSizeForFile(
const blink::StorageKey& storage_key,
const media::CdmType& cdm_type,
const std::string& file_name) { … }
std::optional<uint64_t> CdmStorageDatabase::GetSizeForStorageKey(
const blink::StorageKey& storage_key,
const base::Time begin,
const base::Time end) { … }
std::optional<uint64_t> CdmStorageDatabase::GetSizeForTimeFrame(
const base::Time begin,
const base::Time end) { … }
CdmStorageKeyUsageSize CdmStorageDatabase::GetUsagePerAllStorageKeys(
const base::Time begin,
const base::Time end) { … }
bool CdmStorageDatabase::DeleteFile(const blink::StorageKey& storage_key,
const media::CdmType& cdm_type,
const std::string& file_name) { … }
bool CdmStorageDatabase::DeleteData(
const StoragePartition::StorageKeyMatcherFunction& storage_key_matcher,
const blink::StorageKey& storage_key,
const base::Time begin,
const base::Time end) { … }
bool CdmStorageDatabase::DeleteDataForFilter(
StoragePartition::StorageKeyMatcherFunction storage_key_matcher,
const base::Time begin,
const base::Time end) { … }
bool CdmStorageDatabase::DeleteDataForStorageKey(
const blink::StorageKey& storage_key,
const base::Time begin,
const base::Time end) { … }
bool CdmStorageDatabase::DeleteDataForTimeFrame(const base::Time begin,
const base::Time end) { … }
bool CdmStorageDatabase::ClearDatabase() { … }
void CdmStorageDatabase::CloseDatabaseForTesting() { … }
bool CdmStorageDatabase::DeleteIfEmptyDatabase(bool last_operation_success) { … }
CdmStorageOpenError CdmStorageDatabase::OpenDatabase(bool is_retry) { … }
bool CdmStorageDatabase::UpgradeDatabaseSchema(sql::MetaTable* meta_table) { … }
void CdmStorageDatabase::OnDatabaseError(int error, sql::Statement* stmt) { … }
}