#include "components/history_clusters/core/context_clusterer_history_service_observer.h"
#include "base/metrics/histogram_functions.h"
#include "base/time/default_clock.h"
#include "base/timer/elapsed_timer.h"
#include "base/trace_event/trace_event.h"
#include "components/history/core/browser/history_service.h"
#include "components/history_clusters/core/config.h"
#include "components/history_clusters/core/history_clusters_util.h"
#include "components/optimization_guide/core/optimization_guide_decider.h"
#include "components/search_engines/template_url_service.h"
#include "components/site_engagement/core/site_engagement_score_provider.h"
namespace history_clusters {
namespace {
bool ShouldAddVisitToCluster(const history::VisitRow& new_visit,
const std::u16string& search_terms,
const InProgressCluster& in_progress_cluster) { … }
enum class ContextClustererDbLatencyType { … };
std::string DbLatencyHistogramSuffix(
ContextClustererDbLatencyType db_latency_type) { … }
void LogDbLatencyHistogram(ContextClustererDbLatencyType db_latency_type,
base::TimeTicks start_time) { … }
enum class VisitProcessingStage { … };
std::string VisitProcessingStageHistogramSuffix(
VisitProcessingStage visit_processing_stage) { … }
class ScopedVisitProcessingTimer { … };
}
InProgressCluster::InProgressCluster() = default;
InProgressCluster::~InProgressCluster() = default;
InProgressCluster::InProgressCluster(const InProgressCluster&) = default;
CachedEngagementScore::CachedEngagementScore(float score,
base::Time expiry_time)
: … { … }
CachedEngagementScore::~CachedEngagementScore() = default;
CachedEngagementScore::CachedEngagementScore(const CachedEngagementScore&) =
default;
ContextClustererHistoryServiceObserver::ContextClustererHistoryServiceObserver(
history::HistoryService* history_service,
TemplateURLService* template_url_service,
optimization_guide::OptimizationGuideDecider* optimization_guide_decider,
site_engagement::SiteEngagementScoreProvider* engagement_score_provider)
: … { … }
ContextClustererHistoryServiceObserver::
~ContextClustererHistoryServiceObserver() = default;
void ContextClustererHistoryServiceObserver::OnURLVisited(
history::HistoryService* history_service,
const history::URLRow& url_row,
const history::VisitRow& new_visit) { … }
void ContextClustererHistoryServiceObserver::OnHistoryDeletions(
history::HistoryService* history_service,
const history::DeletionInfo& deletion_info) { … }
void ContextClustererHistoryServiceObserver::CleanUpClusters() { … }
void ContextClustererHistoryServiceObserver::FinalizeCluster(
int64_t cluster_id) { … }
void ContextClustererHistoryServiceObserver::OnPersistedClusterIdReceived(
base::TimeTicks start_time,
int64_t cluster_id,
int64_t persisted_cluster_id) { … }
history::ClusterVisit
ContextClustererHistoryServiceObserver::CreateClusterVisit(
const std::string& normalized_url,
bool is_search_normalized_url,
const history::VisitRow& visit_row) { … }
float ContextClustererHistoryServiceObserver::GetEngagementScore(
const GURL& normalized_url) { … }
void ContextClustererHistoryServiceObserver::OverrideClockForTesting(
const base::Clock* clock) { … }
}