#include "components/sync/engine/data_type_worker.h"
#include <stdint.h>
#include <map>
#include <set>
#include <utility>
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/thread_restrictions.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "base/uuid.h"
#include "components/sync/base/client_tag_hash.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/data_type_histogram.h"
#include "components/sync/base/features.h"
#include "components/sync/base/hash_util.h"
#include "components/sync/base/sync_invalidation_adapter.h"
#include "components/sync/base/time.h"
#include "components/sync/engine/bookmark_update_preprocessing.h"
#include "components/sync/engine/cancelation_signal.h"
#include "components/sync/engine/commit_contribution.h"
#include "components/sync/engine/commit_contribution_impl.h"
#include "components/sync/engine/cycle/entity_change_metric_recording.h"
#include "components/sync/engine/data_type_processor.h"
#include "components/sync/protocol/data_type_progress_marker.pb.h"
#include "components/sync/protocol/data_type_state_helper.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/password_specifics.pb.h"
#include "components/sync/protocol/proto_memory_estimations.h"
#include "components/sync/protocol/sync_entity.pb.h"
namespace syncer {
namespace {
const char kUndecryptablePendingUpdatesDroppedHistogramName[] = …;
const char kBlockedByUndecryptableUpdateHistogramName[] = …;
const char kPasswordNotesStateHistogramName[] = …;
constexpr char kEntityEncryptionResultHistogramName[] = …;
constexpr int kMinGuResponsesToIgnoreKey = …;
enum class CrossUserSharingDecryptionResult { … };
void LogPasswordNotesState(PasswordNotesStateForUMA state) { … }
void LogEncryptionResult(DataType type, bool success) { … }
void LogCrossUserSharingDecryptionResult(
CrossUserSharingDecryptionResult result) { … }
class CommitQueueProxy : public CommitQueue { … };
void AdaptClientTagForFullUpdateData(DataType data_type,
syncer::EntityData* data) { … }
void AdaptWebAuthnClientTagHash(syncer::EntityData* data) { … }
std::string GetEncryptionKeyName(const sync_pb::SyncEntity& entity) { … }
bool DecryptSpecifics(const Cryptographer& cryptographer,
const sync_pb::EntitySpecifics& in,
sync_pb::EntitySpecifics* out) { … }
bool DecryptPasswordSpecifics(const Cryptographer& cryptographer,
const sync_pb::PasswordSpecifics& in,
sync_pb::PasswordSpecificsData* out) { … }
bool DecryptIncomingPasswordSharingInvitationSpecifics(
const Cryptographer& cryptographer,
const sync_pb::IncomingPasswordSharingInvitationSpecifics& invitation,
sync_pb::PasswordSharingInvitationData* unencrypted_invitation_data) { … }
}
DataTypeWorker::DataTypeWorker(DataType type,
const sync_pb::DataTypeState& initial_state,
Cryptographer* cryptographer,
bool encryption_enabled,
PassphraseType passphrase_type,
NudgeHandler* nudge_handler,
CancelationSignal* cancelation_signal)
: … { … }
DataTypeWorker::PendingInvalidation::PendingInvalidation() = default;
DataTypeWorker::PendingInvalidation::PendingInvalidation(
PendingInvalidation&&) = default;
DataTypeWorker::PendingInvalidation&
DataTypeWorker::PendingInvalidation::operator=(PendingInvalidation&&) =
default;
DataTypeWorker::PendingInvalidation::PendingInvalidation(
std::unique_ptr<SyncInvalidation> invalidation,
bool is_processed)
: … { … }
DataTypeWorker::PendingInvalidation::~PendingInvalidation() = default;
DataTypeWorker::~DataTypeWorker() { … }
void DataTypeWorker::LogPendingInvalidationStatus(
PendingInvalidationStatus status) { … }
void DataTypeWorker::ConnectSync(
std::unique_ptr<DataTypeProcessor> data_type_processor) { … }
DataType DataTypeWorker::GetDataType() const { … }
void DataTypeWorker::EnableEncryption() { … }
void DataTypeWorker::OnCryptographerChange() { … }
void DataTypeWorker::UpdatePassphraseType(PassphraseType type) { … }
bool DataTypeWorker::IsInitialSyncEnded() const { … }
const sync_pb::DataTypeProgressMarker& DataTypeWorker::GetDownloadProgress()
const { … }
const sync_pb::DataTypeContext& DataTypeWorker::GetDataTypeContext() const { … }
void DataTypeWorker::ProcessGetUpdatesResponse(
const sync_pb::DataTypeProgressMarker& progress_marker,
const sync_pb::DataTypeContext& mutated_context,
const SyncEntityList& applicable_updates,
StatusController* status) { … }
DataTypeWorker::DecryptionStatus DataTypeWorker::PopulateUpdateResponseData(
const Cryptographer& cryptographer,
DataType data_type,
const sync_pb::SyncEntity& update_entity,
UpdateResponseData* response_data) { … }
void DataTypeWorker::ApplyUpdates(StatusController* status, bool cycle_done) { … }
void DataTypeWorker::SendPendingUpdatesToProcessorIfReady() { … }
void DataTypeWorker::NudgeForCommit() { … }
void DataTypeWorker::NudgeIfReadyToCommit() { … }
std::unique_ptr<CommitContribution> DataTypeWorker::GetContribution(
size_t max_entries) { … }
bool DataTypeWorker::HasLocalChanges() const { … }
void DataTypeWorker::OnCommitResponse(
const CommitResponseDataList& committed_response_list,
const FailedCommitResponseDataList& error_response_list) { … }
void DataTypeWorker::OnFullCommitFailure(SyncCommitError commit_error) { … }
size_t DataTypeWorker::EstimateMemoryUsage() const { … }
bool DataTypeWorker::CanCommitItems() const { … }
bool DataTypeWorker::BlockForEncryption() const { … }
bool DataTypeWorker::UpdateTypeEncryptionKeyName() { … }
void DataTypeWorker::DecryptStoredEntities() { … }
void DataTypeWorker::DeduplicatePendingUpdatesBasedOnServerId() { … }
void DataTypeWorker::DeduplicatePendingUpdatesBasedOnClientTagHash() { … }
void DataTypeWorker::DeduplicatePendingUpdatesBasedOnOriginatorClientItemId() { … }
bool DataTypeWorker::ShouldIgnoreUpdatesEncryptedWith(
const std::string& key_name) { … }
void DataTypeWorker::MaybeDropPendingUpdatesEncryptedWith(
const std::string& key_name) { … }
void DataTypeWorker::RemoveKeysNoLongerUnknown() { … }
bool DataTypeWorker::HasNonDeletionUpdates() const { … }
void DataTypeWorker::ExtractGcDirective() { … }
void DataTypeWorker::RecordRemoteInvalidation(
std::unique_ptr<SyncInvalidation> incoming) { … }
void DataTypeWorker::CollectPendingInvalidations(
sync_pb::GetUpdateTriggers* msg) { … }
bool DataTypeWorker::HasPendingInvalidations() const { … }
void DataTypeWorker::SendPendingInvalidationsToProcessor() { … }
void DataTypeWorker::UpdateDataTypeStateInvalidations() { … }
void DataTypeWorker::EncryptPasswordSpecificsData(
CommitRequestDataList* request_data_list) { … }
void DataTypeWorker::EncryptOutgoingPasswordSharingInvitations(
CommitRequestDataList* request_data_list) { … }
void DataTypeWorker::EncryptSpecifics(
CommitRequestDataList* request_data_list) { … }
GetLocalChangesRequest::GetLocalChangesRequest()
: … { … }
GetLocalChangesRequest::~GetLocalChangesRequest() = default;
void GetLocalChangesRequest::OnCancelationSignalReceived() { … }
void GetLocalChangesRequest::WaitForResponseOrCancelation(
CancelationSignal* cancelation_signal) { … }
void GetLocalChangesRequest::SetResponse(
CommitRequestDataList&& local_changes) { … }
CommitRequestDataList&& GetLocalChangesRequest::ExtractResponse() { … }
}