#include "chrome/browser/sync/test/integration/history_helper.h"
#include <memory>
#include <ostream>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/time/time.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "components/history/core/browser/history_backend.h"
#include "components/history/core/browser/history_backend_observer.h"
#include "components/history/core/browser/history_database.h"
#include "components/history/core/browser/history_db_task.h"
#include "components/history/core/browser/history_service.h"
#include "components/sync/protocol/history_specifics.pb.h"
#include "components/sync/protocol/proto_value_conversions.h"
namespace sync_pb {
void PrintTo(const HistorySpecifics& history, std::ostream* os) { … }
}
namespace history {
void PrintTo(const VisitRow& row, std::ostream* os) { … }
}
namespace history_helper {
namespace {
class FlushHistoryDBQueueTask : public history::HistoryDBTask { … };
class GetUrlTask : public history::HistoryDBTask { … };
class GetUrlByIdTask : public history::HistoryDBTask { … };
class GetVisitsTask : public history::HistoryDBTask { … };
class GetAnnotatedVisitsTask : public history::HistoryDBTask { … };
class GetRedirectChainTask : public history::HistoryDBTask { … };
void WaitForHistoryDBThread(int index) { … }
void AddToHistory(history::HistoryService* service,
const GURL& url,
ui::PageTransition transition,
history::VisitSource source,
const base::Time& timestamp) { … }
bool GetUrlFromHistoryService(history::HistoryService* service,
const GURL& url,
history::URLRow* row) { … }
bool GetUrlFromHistoryService(history::HistoryService* service,
history::URLID url_id,
history::URLRow* row) { … }
history::VisitVector GetVisitsFromHistoryService(
history::HistoryService* service,
history::URLID id) { … }
std::vector<history::AnnotatedVisit> GetAnnotatedVisitsFromHistoryService(
history::HistoryService* service,
history::URLID id) { … }
history::VisitVector GetRedirectChainFromHistoryService(
history::HistoryService* service,
history::VisitRow final_visit) { … }
history::HistoryService* GetHistoryServiceFromClient(int index) { … }
static base::Time* g_timestamp = …;
base::Time GetUniqueTimestamp() { … }
std::vector<sync_pb::HistorySpecifics> SyncEntitiesToHistorySpecifics(
std::vector<sync_pb::SyncEntity> entities) { … }
}
bool GetUrlFromClient(int index, const GURL& url, history::URLRow* row) { … }
bool GetUrlFromClient(int index, history::URLID url_id, history::URLRow* row) { … }
history::VisitVector GetVisitsFromClient(int index, history::URLID id) { … }
history::VisitVector GetVisitsForURLFromClient(int index, const GURL& url) { … }
std::vector<history::AnnotatedVisit> GetAnnotatedVisitsFromClient(
int index,
history::URLID id) { … }
std::vector<history::AnnotatedVisit> GetAnnotatedVisitsForURLFromClient(
int index,
const GURL& url) { … }
history::VisitVector GetRedirectChainFromClient(int index,
history::VisitRow final_visit) { … }
void AddUrlToHistory(int index, const GURL& url) { … }
void AddUrlToHistoryWithTransition(int index,
const GURL& url,
ui::PageTransition transition,
history::VisitSource source) { … }
void AddUrlToHistoryWithTimestamp(int index,
const GURL& url,
ui::PageTransition transition,
history::VisitSource source,
const base::Time& timestamp) { … }
LocalHistoryMatchChecker::LocalHistoryMatchChecker(
int profile_index,
syncer::SyncServiceImpl* service,
const std::map<GURL, Matcher>& matchers)
: … { … }
LocalHistoryMatchChecker::~LocalHistoryMatchChecker() = default;
bool LocalHistoryMatchChecker::IsExitConditionSatisfied(std::ostream* os) { … }
void LocalHistoryMatchChecker::OnSyncCycleCompleted(syncer::SyncService* sync) { … }
ServerHistoryMatchChecker::ServerHistoryMatchChecker(const Matcher& matcher)
: … { … }
ServerHistoryMatchChecker::~ServerHistoryMatchChecker() = default;
void ServerHistoryMatchChecker::OnCommit(
syncer::DataTypeSet committed_data_types) { … }
bool ServerHistoryMatchChecker::IsExitConditionSatisfied(std::ostream* os) { … }
}