#include "components/history/core/browser/sync/delete_directive_handler.h"
#include <stddef.h>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/history/core/browser/history_backend.h"
#include "components/history/core/browser/history_db_task.h"
#include "components/sync/model/sync_change.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/history_delete_directive_specifics.pb.h"
#include "components/sync/protocol/proto_value_conversions.h"
namespace {
std::string RandASCIIString(size_t length) { … }
std::string DeleteDirectiveToString(
const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) { … }
bool TimeRangeLessThan(const syncer::SyncData& data1,
const syncer::SyncData& data2) { … }
base::Time UnixUsecToTime(int64_t usec) { … }
int64_t TimeToUnixUsec(base::Time time) { … }
void GetTimesFromGlobalIds(
const sync_pb::GlobalIdDirective& global_id_directive,
std::set<base::Time>* times) { … }
#if !defined(NDEBUG)
void CheckDeleteDirectiveValid(
const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) { … }
#endif
}
namespace history {
class DeleteDirectiveHandler::DeleteDirectiveTask : public HistoryDBTask { … };
bool DeleteDirectiveHandler::DeleteDirectiveTask::RunOnDBThread(
HistoryBackend* backend,
HistoryDatabase* db) { … }
void DeleteDirectiveHandler::DeleteDirectiveTask::DoneRunOnMainThread() { … }
void DeleteDirectiveHandler::DeleteDirectiveTask::
ProcessGlobalIdDeleteDirectives(
HistoryBackend* history_backend,
const syncer::SyncDataList& global_id_directives) { … }
void DeleteDirectiveHandler::DeleteDirectiveTask::
ProcessTimeRangeDeleteDirectives(
HistoryBackend* history_backend,
const syncer::SyncDataList& time_range_directives) { … }
void DeleteDirectiveHandler::DeleteDirectiveTask::
ProcessTimeRangeDeleteDirectivesByApp(
HistoryBackend* history_backend,
std::optional<std::string> restrict_app_id,
const syncer::SyncDataList& time_range_directives) { … }
void DeleteDirectiveHandler::DeleteDirectiveTask::ProcessUrlDeleteDirectives(
HistoryBackend* history_backend,
const syncer::SyncDataList& url_directives) { … }
DeleteDirectiveHandler::DeleteDirectiveHandler(
BackendTaskScheduler backend_task_scheduler)
: … { … }
DeleteDirectiveHandler::~DeleteDirectiveHandler() = default;
void DeleteDirectiveHandler::OnBackendLoaded() { … }
bool DeleteDirectiveHandler::CreateTimeRangeDeleteDirective(
base::Time begin_time,
base::Time end_time) { … }
bool DeleteDirectiveHandler::CreateUrlDeleteDirective(const GURL& url) { … }
std::optional<syncer::ModelError>
DeleteDirectiveHandler::ProcessLocalDeleteDirective(
const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) { … }
void DeleteDirectiveHandler::WaitUntilReadyToSync(base::OnceClosure done) { … }
std::optional<syncer::ModelError>
DeleteDirectiveHandler::MergeDataAndStartSyncing(
syncer::DataType type,
const syncer::SyncDataList& initial_sync_data,
std::unique_ptr<syncer::SyncChangeProcessor> sync_processor) { … }
void DeleteDirectiveHandler::StopSyncing(syncer::DataType type) { … }
std::optional<syncer::ModelError> DeleteDirectiveHandler::ProcessSyncChanges(
const base::Location& from_here,
const syncer::SyncChangeList& change_list) { … }
base::WeakPtr<syncer::SyncableService> DeleteDirectiveHandler::AsWeakPtr() { … }
void DeleteDirectiveHandler::FinishProcessing(
PostProcessingAction post_processing_action,
const syncer::SyncDataList& delete_directives) { … }
}