#include "components/history/core/browser/expire_history_backend.h"
#include <stddef.h>
#include <functional>
#include <limits>
#include <memory>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/containers/flat_set.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "components/favicon/core/favicon_database.h"
#include "components/history/core/browser/features.h"
#include "components/history/core/browser/history_backend_client.h"
#include "components/history/core/browser/history_backend_notifier.h"
#include "components/history/core/browser/history_database.h"
namespace history {
namespace {
const int kEarlyExpirationAdvanceDays = …;
class AllVisitsReader : public ExpiringVisitsReader { … };
class AutoSubframeVisitsReader : public ExpiringVisitsReader { … };
const int kNumExpirePerIteration = …;
const int kExpirationDelaySec = …;
const int kExpirationEmptyDelayMin = …;
constexpr base::TimeDelta kExpirationSleepWakeupThreshold = …;
const int kClearOnDemandFaviconsIntervalHours = …;
bool IsAnyURLPinned(HistoryBackendClient* backend_client,
const std::vector<GURL>& urls) { … }
}
namespace internal {
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
constexpr bool kClearOldOnDemandFaviconsEnabled = true;
#else
constexpr bool kClearOldOnDemandFaviconsEnabled = …;
#endif
const int kOnDemandFaviconIsOldAfterDays = …;
}
ExpireHistoryBackend::DeleteEffects::DeleteEffects() = default;
ExpireHistoryBackend::DeleteEffects::~DeleteEffects() = default;
ExpireHistoryBackend::ExpireHistoryBackend(
HistoryBackendNotifier* notifier,
HistoryBackendClient* backend_client,
scoped_refptr<base::SequencedTaskRunner> task_runner)
: … { … }
ExpireHistoryBackend::~ExpireHistoryBackend() = default;
void ExpireHistoryBackend::SetDatabases(HistoryDatabase* main_db,
favicon::FaviconDatabase* favicon_db) { … }
void ExpireHistoryBackend::DeleteURL(const GURL& url, base::Time end_time) { … }
void ExpireHistoryBackend::DeleteURLs(const std::vector<GURL>& urls,
base::Time end_time) { … }
void ExpireHistoryBackend::ExpireHistoryBetween(
const std::set<GURL>& restrict_urls,
std::optional<std::string> restrict_app_id,
base::Time begin_time,
base::Time end_time,
bool user_initiated) { … }
void ExpireHistoryBackend::ExpireHistoryForTimes(
const std::vector<base::Time>& times) { … }
void ExpireHistoryBackend::ExpireVisits(const VisitVector& visits,
DeletionInfo::Reason deletion_reason) { … }
void ExpireHistoryBackend::ExpireVisitsInternal(
const VisitVector& visits,
const DeletionTimeRange& time_range,
const std::set<GURL>& restrict_urls,
DeletionType type,
DeletionInfo::Reason deletion_reason) { … }
void ExpireHistoryBackend::ExpireHistoryBeforeForTesting(base::Time end_time) { … }
void ExpireHistoryBackend::ClearOldOnDemandFaviconsIfPossible(
base::Time expiration_threshold) { … }
void ExpireHistoryBackend::InitWorkQueue() { … }
const ExpiringVisitsReader* ExpireHistoryBackend::GetAllVisitsReader() { … }
const ExpiringVisitsReader*
ExpireHistoryBackend::GetAutoSubframeVisitsReader() { … }
void ExpireHistoryBackend::StartExpiringOldStuff(
base::TimeDelta expiration_threshold) { … }
void ExpireHistoryBackend::DeleteFaviconsIfPossible(DeleteEffects* effects) { … }
void ExpireHistoryBackend::BroadcastNotifications(
DeleteEffects* effects,
DeletionType type,
const DeletionTimeRange& time_range,
std::optional<std::set<GURL>> restrict_urls,
DeletionInfo::Reason deletion_reason) { … }
VisitVector ExpireHistoryBackend::GetVisitsAndRedirectParents(
const VisitVector& visits) { … }
void ExpireHistoryBackend::DeleteVisitRelatedInfo(const VisitVector& visits,
DeleteEffects* effects) { … }
void ExpireHistoryBackend::DeleteOneURL(const URLRow& url_row,
bool is_pinned,
DeleteEffects* effects) { … }
void ExpireHistoryBackend::DeleteIcons(const GURL& gurl,
DeleteEffects* effects) { … }
namespace {
struct ChangedURL { … };
}
void ExpireHistoryBackend::ExpireURLsForVisits(const VisitVector& visits,
DeleteEffects* effects) { … }
void ExpireHistoryBackend::ScheduleExpire() { … }
void ExpireHistoryBackend::DoExpireIteration() { … }
bool ExpireHistoryBackend::ExpireSomeOldHistory(
base::Time end_time,
const ExpiringVisitsReader* reader,
int max_visits) { … }
void ExpireHistoryBackend::ExpireOldSegmentData(base::Time end_time) { … }
void ExpireHistoryBackend::ParanoidExpireHistory() { … }
}