#include "components/history/core/browser/browsing_history_service.h"
#include <stddef.h>
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "base/types/optional_ref.h"
#include "base/values.h"
#include "components/history/core/browser/browsing_history_driver.h"
#include "components/history/core/browser/history_types.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/sync/protocol/history_delete_directive_specifics.pb.h"
namespace history {
namespace {
constexpr int kWebHistoryTimeoutSeconds = …;
enum WebHistoryQueryBuckets { … };
QueryOptions OptionsWithEndTime(QueryOptions original_options,
base::Time end_time) { … }
enum QuerySourceStatus { … };
bool CanRetry(QuerySourceStatus status) { … }
base::Time OldestTime(
const std::vector<BrowsingHistoryService::HistoryEntry>& entries) { … }
}
struct BrowsingHistoryService::QueryHistoryState
: public base::RefCounted<BrowsingHistoryService::QueryHistoryState> { … };
BrowsingHistoryService::HistoryEntry::HistoryEntry(
BrowsingHistoryService::HistoryEntry::EntryType entry_type,
const GURL& url,
const std::u16string& title,
base::Time time,
const std::string& client_id,
bool is_search_result,
const std::u16string& snippet,
bool blocked_visit,
const GURL& remote_icon_url_for_uma,
int visit_count,
int typed_count,
std::optional<std::string> app_id)
: … { … }
BrowsingHistoryService::HistoryEntry::HistoryEntry()
: … { … }
BrowsingHistoryService::HistoryEntry::HistoryEntry(const HistoryEntry& other) =
default;
BrowsingHistoryService::HistoryEntry::~HistoryEntry() { … }
bool BrowsingHistoryService::HistoryEntry::SortByTimeDescending(
const BrowsingHistoryService::HistoryEntry& entry1,
const BrowsingHistoryService::HistoryEntry& entry2) { … }
BrowsingHistoryService::QueryResultsInfo::~QueryResultsInfo() = default;
BrowsingHistoryService::BrowsingHistoryService(
BrowsingHistoryDriver* driver,
HistoryService* local_history,
syncer::SyncService* sync_service)
: … { … }
BrowsingHistoryService::BrowsingHistoryService(
BrowsingHistoryDriver* driver,
HistoryService* local_history,
syncer::SyncService* sync_service,
std::unique_ptr<base::OneShotTimer> web_history_timer)
: … { … }
BrowsingHistoryService::BrowsingHistoryService() = default;
BrowsingHistoryService::~BrowsingHistoryService() { … }
void BrowsingHistoryService::OnStateChanged(syncer::SyncService* sync) { … }
void BrowsingHistoryService::OnSyncShutdown(syncer::SyncService* sync) { … }
void BrowsingHistoryService::WebHistoryTimeout(
scoped_refptr<QueryHistoryState> state) { … }
void BrowsingHistoryService::QueryHistory(const std::u16string& search_text,
const QueryOptions& options) { … }
void BrowsingHistoryService::QueryHistoryInternal(
scoped_refptr<QueryHistoryState> state) { … }
void BrowsingHistoryService::GetAllAppIds() { … }
void BrowsingHistoryService::GetLastVisitToHostBeforeRecentNavigations(
const std::string& host_name,
base::OnceCallback<void(base::Time)> callback) { … }
void BrowsingHistoryService::OnLastVisitBeforeRecentNavigationsComplete(
const std::string& host_name,
base::Time query_start_time,
base::OnceCallback<void(base::Time)> callback,
HistoryLastVisitResult result) { … }
void BrowsingHistoryService::OnLastVisitBeforeRecentNavigationsComplete2(
base::OnceCallback<void(base::Time)> callback,
HistoryLastVisitResult result) { … }
void BrowsingHistoryService::RemoveVisits(
const std::vector<BrowsingHistoryService::HistoryEntry>& items) { … }
void BrowsingHistoryService::MergeDuplicateResults(
QueryHistoryState* state,
std::vector<HistoryEntry>* results) { … }
void BrowsingHistoryService::QueryComplete(
scoped_refptr<QueryHistoryState> state,
QueryResults results) { … }
void BrowsingHistoryService::OnGetAllAppIds(GetAllAppIdsResult result) { … }
void BrowsingHistoryService::ReturnResultsToDriver(
scoped_refptr<QueryHistoryState> state) { … }
void BrowsingHistoryService::WebHistoryQueryComplete(
scoped_refptr<QueryHistoryState> state,
base::Time start_time,
WebHistoryService::Request* request,
base::optional_ref<const base::Value::Dict> results_dict) { … }
void BrowsingHistoryService::OtherFormsOfBrowsingHistoryQueryComplete(
bool found_other_forms_of_browsing_history) { … }
void BrowsingHistoryService::RemoveComplete() { … }
void BrowsingHistoryService::RemoveWebHistoryComplete(bool success) { … }
static bool DeletionsDiffer(const URLRows& deleted_rows,
const std::set<GURL>& urls_to_be_deleted) { … }
void BrowsingHistoryService::OnHistoryDeletions(
HistoryService* history_service,
const DeletionInfo& deletion_info) { … }
void BrowsingHistoryService::OnWebHistoryDeleted() { … }
}