#include "components/history/core/browser/visit_database.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <utility>
#include "base/logging.h"
#include "base/not_fatal_until.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "components/google/core/common/google_util.h"
#include "components/history/core/browser/history_backend.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/browser/url_database.h"
#include "sql/statement.h"
#include "sql/transaction.h"
#include "ui/base/page_transition_types.h"
#include "url/url_constants.h"
namespace history {
namespace {
std::pair<std::string, std::string> GetOriginSearchBounds(const GURL& origin) { … }
std::pair<std::string, std::string>
GetSearchBoundsForAllOriginsWithNonDefaultPort(const GURL& origin) { … }
std::array<std::pair<std::string, std::string>, 4> GetHostSearchBounds(
const std::string& host_name) { … }
ui::PageTransition PageTransitionFromIntWithFallback(int32_t transition) { … }
bool TransitionIsVisible(int32_t transition) { … }
VisitSource VisitSourceFromInt(int value) { … }
}
VisitDatabase::VisitDatabase() = default;
VisitDatabase::~VisitDatabase() = default;
bool VisitDatabase::InitVisitTable() { … }
bool VisitDatabase::DropVisitTable() { … }
void VisitDatabase::FillVisitRow(sql::Statement& statement, VisitRow* visit) { … }
bool VisitDatabase::FillVisitVector(sql::Statement& statement,
VisitVector* visits) { … }
bool VisitDatabase::FillVisitVectorWithOptions(sql::Statement& statement,
const QueryOptions& options,
VisitVector* visits) { … }
VisitID VisitDatabase::AddVisit(VisitRow* visit, VisitSource source) { … }
void VisitDatabase::DeleteVisit(const VisitRow& visit) { … }
bool VisitDatabase::GetRowForVisit(VisitID visit_id, VisitRow* out_visit) { … }
bool VisitDatabase::GetLastRowForVisitByVisitTime(base::Time visit_time,
VisitRow* out_visit) { … }
bool VisitDatabase::GetRowForForeignVisit(
const std::string& originator_cache_guid,
VisitID originator_visit_id,
VisitRow* out_visit) { … }
bool VisitDatabase::UpdateVisitRow(const VisitRow& visit) { … }
bool VisitDatabase::SetAllVisitsAsNotKnownToSync() { … }
bool VisitDatabase::GetVisitsForURL(URLID url_id, VisitVector* visits) { … }
bool VisitDatabase::GetVisibleVisitsForURL(URLID url_id,
const QueryOptions& options,
VisitVector* visits) { … }
bool VisitDatabase::GetVisitsForTimes(const std::vector<base::Time>& times,
VisitVector* visits) { … }
bool VisitDatabase::GetAllVisitsInRange(base::Time begin_time,
base::Time end_time,
std::optional<std::string> app_id,
int max_results,
VisitVector* visits) { … }
bool VisitDatabase::GetVisitsInRangeForTransition(base::Time begin_time,
base::Time end_time,
int max_results,
ui::PageTransition transition,
VisitVector* visits) { … }
bool VisitDatabase::GetSomeForeignVisits(VisitID max_visit_id,
int max_results,
VisitVector* visits) { … }
bool VisitDatabase::GetAllURLIDsForTransition(ui::PageTransition transition,
std::vector<URLID>* urls) { … }
GetAllAppIdsResult VisitDatabase::GetAllAppIds() { … }
bool VisitDatabase::GetVisibleVisitsInRange(const QueryOptions& options,
VisitVector* visits) { … }
VisitID VisitDatabase::GetMostRecentVisitForURL(URLID url_id,
VisitRow* visit_row) { … }
bool VisitDatabase::GetMostRecentVisitsForURL(URLID url_id,
int max_results,
VisitVector* visits) { … }
bool VisitDatabase::GetRedirectFromVisit(VisitID from_visit,
VisitID* to_visit,
GURL* to_url) { … }
bool VisitDatabase::GetRedirectToVisit(VisitID to_visit,
VisitID* from_visit,
GURL* from_url) { … }
bool VisitDatabase::GetVisibleVisitCountToHost(const GURL& url,
int* count,
base::Time* first_visit) { … }
bool VisitDatabase::GetHistoryCount(const base::Time& begin_time,
const base::Time& end_time,
int* count) { … }
bool VisitDatabase::GetLastVisitToHost(const std::string& host,
base::Time begin_time,
base::Time end_time,
base::Time* last_visit) { … }
bool VisitDatabase::GetLastVisitToOrigin(const url::Origin& origin,
base::Time begin_time,
base::Time end_time,
base::Time* last_visit) { … }
bool VisitDatabase::GetLastVisitToURL(const GURL& url,
base::Time end_time,
base::Time* last_visit) { … }
DailyVisitsResult VisitDatabase::GetDailyVisitsToHost(const GURL& host,
base::Time begin_time,
base::Time end_time) { … }
bool VisitDatabase::GetStartDate(base::Time* first_visit) { … }
VisitID VisitDatabase::GetMaxVisitIDInUse() { … }
void VisitDatabase::GetVisitsSource(const VisitVector& visits,
VisitSourceMap* sources) { … }
VisitSource VisitDatabase::GetVisitSource(const VisitID visit_id) { … }
std::vector<DomainVisit>
VisitDatabase::GetGoogleDomainVisitsFromSearchesInRange(base::Time begin_time,
base::Time end_time) { … }
bool VisitDatabase::MigrateVisitsWithoutDuration() { … }
bool VisitDatabase::MigrateVisitsWithoutIncrementedOmniboxTypedScore() { … }
bool VisitDatabase::MigrateVisitsWithoutPubliclyRoutableColumn() { … }
bool VisitDatabase::CanMigrateFlocAllowed() { … }
bool VisitDatabase::
MigrateVisitsWithoutOpenerVisitColumnAndDropPubliclyRoutableColumn() { … }
bool VisitDatabase::MigrateVisitsAutoincrementIdAndAddOriginatorColumns() { … }
bool VisitDatabase::MigrateVisitsAddOriginatorFromVisitAndOpenerVisitColumns() { … }
bool VisitDatabase::VisitTableContainsAutoincrement() { … }
bool VisitDatabase::GetAllVisitedURLRowidsForMigrationToVersion40(
std::vector<URLID>* visited_url_rowids_sorted) { … }
bool VisitDatabase::MigrateVisitsAddIsKnownToSyncColumn() { … }
bool VisitDatabase::MigrateVisitsAddConsiderForNewTabPageMostVisitedColumn() { … }
bool VisitDatabase::MigrateVisitsAddExternalReferrerUrlColumn() { … }
bool VisitDatabase::MigrateVisitsAddVisitedLinkIdColumn() { … }
bool VisitDatabase::MigrateVisitsAddAppId() { … }
}