#include "chrome/browser/web_applications/isolated_web_apps/cleanup_orphaned_isolated_web_apps_command.h"
#include <iterator>
#include <optional>
#include <set>
#include <variant>
#include "base/check_deref.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/callback_helpers.h"
#include "base/ranges/algorithm.h"
#include "base/task/thread_pool.h"
#include "base/types/expected.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/web_applications/commands/command_result.h"
#include "chrome/browser/web_applications/isolated_web_apps/error/uma_logging.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_storage_location.h"
#include "chrome/browser/web_applications/locks/all_apps_lock.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
namespace web_app {
namespace {
std::set<base::FilePath> RetrieveAllInstalledIsolatedWebAppsPaths(
AllAppsLock& lock,
const Profile& profile) { … }
std::set<base::FilePath> RetrieveAllIsolatedWebAppsDirectories(
const base::FilePath& profile_dir) { … }
bool DeleteOrphanedIsolatedWebApps(std::vector<base::FilePath> paths) { … }
base::expected<CleanupOrphanedIsolatedWebAppsCommandSuccess,
CleanupOrphanedIsolatedWebAppsCommandError>
GetResult(int number_of_deleted_directories, bool success) { … }
void RecordOutcomeMetric(
base::expected<CleanupOrphanedIsolatedWebAppsCommandSuccess,
CleanupOrphanedIsolatedWebAppsCommandError> result) { … }
}
CleanupOrphanedIsolatedWebAppsCommandSuccess::
CleanupOrphanedIsolatedWebAppsCommandSuccess(
int number_of_cleaned_up_directories)
: … { … }
CleanupOrphanedIsolatedWebAppsCommandSuccess::
~CleanupOrphanedIsolatedWebAppsCommandSuccess() = default;
CleanupOrphanedIsolatedWebAppsCommandSuccess::
CleanupOrphanedIsolatedWebAppsCommandSuccess(
const CleanupOrphanedIsolatedWebAppsCommandSuccess& other) = default;
std::ostream& operator<<(
std::ostream& os,
const CleanupOrphanedIsolatedWebAppsCommandSuccess& success) { … }
std::ostream& operator<<(
std::ostream& os,
const CleanupOrphanedIsolatedWebAppsCommandError& error) { … }
CleanupOrphanedIsolatedWebAppsCommand::CleanupOrphanedIsolatedWebAppsCommand(
Profile& profile,
Callback callback)
: … { … }
CleanupOrphanedIsolatedWebAppsCommand::
~CleanupOrphanedIsolatedWebAppsCommand() = default;
void CleanupOrphanedIsolatedWebAppsCommand::StartWithLock(
std::unique_ptr<AllAppsLock> lock) { … }
void CleanupOrphanedIsolatedWebAppsCommand::
OnIsolatedWebAppsDirectoriesRetrieved(
std::set<base::FilePath> isolated_web_apps_directories) { … }
void CleanupOrphanedIsolatedWebAppsCommand::CommandComplete(bool success) { … }
}