#include "components/optimization_guide/core/hint_cache.h"
#include <algorithm>
#include "base/functional/bind.h"
#include "base/time/default_clock.h"
#include "components/optimization_guide/core/hints_processing_util.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/store_update_data.h"
#include "url/gurl.h"
namespace optimization_guide {
HintCache::HintCache(
base::WeakPtr<OptimizationGuideStore> optimization_guide_store,
int max_memory_cache_host_keyed_hints)
: … { … }
HintCache::~HintCache() = default;
void HintCache::Initialize(bool purge_existing_data,
base::OnceClosure callback) { … }
std::unique_ptr<StoreUpdateData>
HintCache::MaybeCreateUpdateDataForComponentHints(
const base::Version& version) const { … }
std::unique_ptr<StoreUpdateData> HintCache::CreateUpdateDataForFetchedHints(
base::Time update_time) const { … }
void HintCache::UpdateComponentHints(
std::unique_ptr<StoreUpdateData> component_data,
base::OnceClosure callback) { … }
void HintCache::UpdateFetchedHints(
std::unique_ptr<proto::GetHintsResponse> get_hints_response,
base::Time update_time,
const base::flat_set<std::string>& hosts_fetched,
const base::flat_set<GURL>& urls_fetched,
base::OnceClosure callback) { … }
void HintCache::RemoveHintsForURLs(const base::flat_set<GURL>& urls) { … }
void HintCache::RemoveHintsForHosts(base::OnceClosure on_success,
const base::flat_set<std::string>& hosts) { … }
void HintCache::PurgeExpiredFetchedHints() { … }
void HintCache::ClearFetchedHints() { … }
void HintCache::ClearHostKeyedHints() { … }
bool HintCache::HasHint(const std::string& host) { … }
void HintCache::LoadHint(const std::string& host, HintLoadedCallback callback) { … }
const proto::Hint* HintCache::GetHostKeyedHintIfLoaded(
const std::string& host) { … }
proto::Hint* HintCache::GetURLKeyedHint(const GURL& url) { … }
bool HintCache::HasURLKeyedEntryForURL(const GURL& url) { … }
base::Time HintCache::GetFetchedHintsUpdateTime() const { … }
std::string HintCache::GetURLKeyedHintCacheKey(const GURL& url) const { … }
void HintCache::OnStoreInitialized(base::OnceClosure callback) { … }
void HintCache::OnLoadStoreHint(
const std::string& host,
HintLoadedCallback callback,
const OptimizationGuideStore::EntryKey& hint_entry_key,
std::unique_ptr<MemoryHint> hint) { … }
bool HintCache::ProcessAndCacheHints(
google::protobuf::RepeatedPtrField<proto::Hint>* hints,
optimization_guide::StoreUpdateData* update_data) { … }
void HintCache::SetClockForTesting(const base::Clock* clock) { … }
void HintCache::AddHintForTesting(const GURL& url,
std::unique_ptr<proto::Hint> hint) { … }
bool HintCache::IsHintStoreAvailable() const { … }
}