#include "components/offline_pages/core/model/clear_storage_task.h"
#include <algorithm>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ref.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "components/offline_pages/core/model/delete_page_task.h"
#include "components/offline_pages/core/model/get_pages_task.h"
#include "components/offline_pages/core/offline_page_client_policy.h"
#include "components/offline_pages/core/offline_page_metadata_store.h"
#include "components/offline_pages/core/offline_store_utils.h"
#include "components/offline_pages/core/page_criteria.h"
#include "sql/database.h"
#include "sql/statement.h"
#include "sql/transaction.h"
namespace offline_pages {
ClearStorageResult;
namespace {
const double kOfflinePageStorageLimit = …;
const double kOfflinePageStorageClearThreshold = …;
class PageClearCriteria { … };
std::vector<OfflinePageItem> GetPagesToClear(
const base::Time& start_time,
const ArchiveManager::StorageStats& stats,
sql::Database* db) { … }
std::pair<size_t, DeletePageResult> ClearPagesSync(
const base::Time& start_time,
const ArchiveManager::StorageStats& stats,
sql::Database* db) { … }
}
ClearStorageTask::ClearStorageTask(OfflinePageMetadataStore* store,
ArchiveManager* archive_manager,
const base::Time& clearup_time,
ClearStorageCallback callback)
: … { … }
ClearStorageTask::~ClearStorageTask() { … }
void ClearStorageTask::Run() { … }
void ClearStorageTask::OnGetStorageStatsDone(
const ArchiveManager::StorageStats& stats) { … }
void ClearStorageTask::OnClearPagesDone(
std::pair<size_t, DeletePageResult> result) { … }
void ClearStorageTask::InformClearStorageDone(size_t pages_cleared,
ClearStorageResult result) { … }
}