#include "components/send_tab_to_self/send_tab_to_self_bridge.h"
#include <algorithm>
#include <optional>
#include <vector>
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/observer_list.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "base/uuid.h"
#include "components/history/core/browser/history_service.h"
#include "components/send_tab_to_self/features.h"
#include "components/send_tab_to_self/metrics_util.h"
#include "components/send_tab_to_self/proto/send_tab_to_self.pb.h"
#include "components/send_tab_to_self/target_device_info.h"
#include "components/sync/base/deletion_origin.h"
#include "components/sync/model/data_type_local_change_processor.h"
#include "components/sync/model/entity_change.h"
#include "components/sync/model/metadata_batch.h"
#include "components/sync/model/metadata_change_list.h"
#include "components/sync/model/mutable_data_batch.h"
#include "components/sync_device_info/local_device_info_util.h"
namespace send_tab_to_self {
namespace {
DataTypeStore;
const base::TimeDelta kDedupeTime = …;
const base::TimeDelta kDeviceExpiration = …;
base::Time ProtoTimeToTime(int64_t proto_t) { … }
std::unique_ptr<syncer::EntityData> CopyToEntityData(
const sync_pb::SendTabToSelfSpecifics& specifics) { … }
std::optional<syncer::ModelError> ParseLocalEntriesOnBackendSequence(
base::Time now,
std::map<std::string, std::unique_ptr<SendTabToSelfEntry>>* entries,
std::string* local_personalizable_device_name,
std::unique_ptr<DataTypeStore::RecordList> record_list) { … }
}
SendTabToSelfBridge::SendTabToSelfBridge(
std::unique_ptr<syncer::DataTypeLocalChangeProcessor> change_processor,
base::Clock* clock,
syncer::OnceDataTypeStoreFactory create_store_callback,
history::HistoryService* history_service,
syncer::DeviceInfoTracker* device_info_tracker)
: … { … }
SendTabToSelfBridge::~SendTabToSelfBridge() { … }
std::unique_ptr<syncer::MetadataChangeList>
SendTabToSelfBridge::CreateMetadataChangeList() { … }
std::optional<syncer::ModelError> SendTabToSelfBridge::MergeFullSyncData(
std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
syncer::EntityChangeList entity_data) { … }
std::optional<syncer::ModelError>
SendTabToSelfBridge::ApplyIncrementalSyncChanges(
std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
syncer::EntityChangeList entity_changes) { … }
std::unique_ptr<syncer::DataBatch> SendTabToSelfBridge::GetDataForCommit(
StorageKeyList storage_keys) { … }
std::unique_ptr<syncer::DataBatch>
SendTabToSelfBridge::GetAllDataForDebugging() { … }
std::string SendTabToSelfBridge::GetClientTag(
const syncer::EntityData& entity_data) { … }
std::string SendTabToSelfBridge::GetStorageKey(
const syncer::EntityData& entity_data) { … }
void SendTabToSelfBridge::ApplyDisableSyncChanges(
std::unique_ptr<syncer::MetadataChangeList> delete_metadata_change_list) { … }
std::vector<std::string> SendTabToSelfBridge::GetAllGuids() const { … }
const SendTabToSelfEntry* SendTabToSelfBridge::GetEntryByGUID(
const std::string& guid) const { … }
const SendTabToSelfEntry* SendTabToSelfBridge::AddEntry(
const GURL& url,
const std::string& title,
const std::string& target_device_cache_guid) { … }
void SendTabToSelfBridge::DeleteEntry(const std::string& guid) { … }
void SendTabToSelfBridge::DismissEntry(const std::string& guid) { … }
void SendTabToSelfBridge::MarkEntryOpened(const std::string& guid) { … }
void SendTabToSelfBridge::OnHistoryDeletions(
history::HistoryService* history_service,
const history::DeletionInfo& deletion_info) { … }
void SendTabToSelfBridge::OnDeviceInfoChange() { … }
bool SendTabToSelfBridge::IsReady() { … }
bool SendTabToSelfBridge::HasValidTargetDevice() { … }
std::vector<TargetDeviceInfo>
SendTabToSelfBridge::GetTargetDeviceInfoSortedList() { … }
std::unique_ptr<syncer::DataTypeStore>
SendTabToSelfBridge::DestroyAndStealStoreForTest(
std::unique_ptr<SendTabToSelfBridge> bridge) { … }
void SendTabToSelfBridge::SetLocalDeviceNameForTest(
const std::string& local_device_name) { … }
void SendTabToSelfBridge::NotifyRemoteSendTabToSelfEntryAdded(
const std::vector<const SendTabToSelfEntry*>& new_entries) { … }
void SendTabToSelfBridge::NotifyRemoteSendTabToSelfEntryDeleted(
const std::vector<std::string>& guids) { … }
void SendTabToSelfBridge::NotifyRemoteSendTabToSelfEntryOpened(
const std::vector<const SendTabToSelfEntry*>& opened_entries) { … }
void SendTabToSelfBridge::NotifySendTabToSelfModelLoaded() { … }
void SendTabToSelfBridge::OnStoreCreated(
const std::optional<syncer::ModelError>& error,
std::unique_ptr<syncer::DataTypeStore> store) { … }
void SendTabToSelfBridge::OnReadAllData(
std::unique_ptr<SendTabToSelfEntries> initial_entries,
std::unique_ptr<std::string> local_device_name,
const std::optional<syncer::ModelError>& error) { … }
void SendTabToSelfBridge::OnReadAllMetadata(
const std::optional<syncer::ModelError>& error,
std::unique_ptr<syncer::MetadataBatch> metadata_batch) { … }
void SendTabToSelfBridge::OnCommit(
const std::optional<syncer::ModelError>& error) { … }
void SendTabToSelfBridge::Commit(
std::unique_ptr<DataTypeStore::WriteBatch> batch) { … }
SendTabToSelfEntry* SendTabToSelfBridge::GetMutableEntryByGUID(
const std::string& guid) const { … }
void SendTabToSelfBridge::DoGarbageCollection() { … }
void SendTabToSelfBridge::ComputeTargetDeviceInfoSortedList() { … }
void SendTabToSelfBridge::DeleteEntryWithBatch(
const std::string& guid,
DataTypeStore::WriteBatch* batch) { … }
void SendTabToSelfBridge::DeleteEntries(const std::vector<GURL>& urls) { … }
void SendTabToSelfBridge::DeleteAllEntries() { … }
}