chromium/components/sync_device_info/device_info_sync_bridge.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/sync_device_info/device_info_sync_bridge.h"

#include <stdint.h>

#include <algorithm>
#include <cstdio>
#include <map>
#include <optional>
#include <unordered_set>
#include <utility>

#include "base/containers/span.h"
#include "base/containers/to_vector.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/observer_list.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/time.h"
#include "components/sync/engine/commit_and_get_updates_types.h"
#include "components/sync/model/data_type_activation_request.h"
#include "components/sync/model/entity_change.h"
#include "components/sync/model/metadata_batch.h"
#include "components/sync/model/mutable_data_batch.h"
#include "components/sync/protocol/data_type_state.pb.h"
#include "components/sync/protocol/data_type_state_helper.h"
#include "components/sync/protocol/device_info_specifics.pb.h"
#include "components/sync/protocol/sync_enums.pb.h"
#include "components/sync_device_info/device_info_prefs.h"
#include "components/sync_device_info/device_info_proto_enum_util.h"
#include "components/sync_device_info/device_info_util.h"
#include "components/sync_device_info/local_device_info_util.h"

namespace syncer {

Time;
DeviceInfoSpecifics;
FeatureSpecificFields;
SharingSpecificFields;

Record;
RecordList;
WriteBatch;

namespace {

constexpr base::TimeDelta kExpirationThreshold =;

// Find the timestamp for the last time this |device_info| was edited.
Time GetLastUpdateTime(const DeviceInfoSpecifics& specifics) {}

base::TimeDelta GetPulseIntervalFromSpecifics(
    const DeviceInfoSpecifics& specifics) {}

std::optional<DeviceInfo::SharingInfo> SpecificsToSharingInfo(
    const DeviceInfoSpecifics& specifics) {}

std::optional<DeviceInfo::PhoneAsASecurityKeyInfo>
SpecificsToPhoneAsASecurityKeyInfo(const DeviceInfoSpecifics& specifics) {}

std::optional<base::Time> SpecificsToFloatingWorkspaceLastSigninTime(
    const DeviceInfoSpecifics& specifics) {}

std::string GetVersionNumberFromSpecifics(
    const DeviceInfoSpecifics& specifics) {}

// Returns true if |speifics| represents a client that is
// chromium-based and hence exposed in DeviceInfoTracker.
bool IsChromeClient(const DeviceInfoSpecifics& specifics) {}

// Converts DeviceInfoSpecifics into DeviceInfo.
DeviceInfo SpecificsToModel(const DeviceInfoSpecifics& specifics) {}

// Allocate a EntityData and copies |specifics| into it.
std::unique_ptr<EntityData> CopyToEntityData(
    const DeviceInfoSpecifics& specifics) {}

sync_pb::PhoneAsASecurityKeySpecificFields PhoneAsASecurityKeyInfoToProto(
    const DeviceInfo::PhoneAsASecurityKeyInfo& paask_info) {}

// Converts a local DeviceInfo into a freshly allocated DeviceInfoSpecifics.
std::unique_ptr<DeviceInfoSpecifics> MakeLocalDeviceSpecifics(
    const DeviceInfo& info) {}

// Returns true if |stored| is similar enough to |current| that |current|
// needn't be uploaded.
bool StoredDeviceInfoStillAccurate(const DeviceInfo* stored,
                                   const DeviceInfo* current) {}

// Record a histogram of the age of the PaaSK fields, in days. To confirm that
// crbug.com/1465558 is fixed.
// TODO(crbug.com/40276038): remove this function before Oct 2023.
void RecordPhoneAsASecurityKeyFieldsAge(const DeviceInfoSpecifics& specifics) {}

}  // namespace

DeviceInfoSyncBridge::ImmutableDeviceInfoAndSpecifics::
    ImmutableDeviceInfoAndSpecifics(sync_pb::DeviceInfoSpecifics specifics)
    :{}

DeviceInfoSyncBridge::DeviceInfoSyncBridge(
    std::unique_ptr<MutableLocalDeviceInfoProvider> local_device_info_provider,
    OnceDataTypeStoreFactory store_factory,
    std::unique_ptr<DataTypeLocalChangeProcessor> change_processor,
    std::unique_ptr<DeviceInfoPrefs> device_info_prefs)
    :{}

DeviceInfoSyncBridge::~DeviceInfoSyncBridge() {}

LocalDeviceInfoProvider* DeviceInfoSyncBridge::GetLocalDeviceInfoProvider() {}

void DeviceInfoSyncBridge::RefreshLocalDeviceInfoIfNeeded() {}

void DeviceInfoSyncBridge::SetCommittedAdditionalInterestedDataTypesCallback(
    base::RepeatingCallback<void(const DataTypeSet&)> callback) {}

void DeviceInfoSyncBridge::OnSyncStarting(
    const DataTypeActivationRequest& request) {}

std::unique_ptr<MetadataChangeList>
DeviceInfoSyncBridge::CreateMetadataChangeList() {}

std::optional<ModelError> DeviceInfoSyncBridge::MergeFullSyncData(
    std::unique_ptr<MetadataChangeList> metadata_change_list,
    EntityChangeList entity_data) {}

std::optional<ModelError> DeviceInfoSyncBridge::ApplyIncrementalSyncChanges(
    std::unique_ptr<MetadataChangeList> metadata_change_list,
    EntityChangeList entity_changes) {}

std::unique_ptr<DataBatch> DeviceInfoSyncBridge::GetDataForCommit(
    StorageKeyList storage_keys) {}

std::unique_ptr<DataBatch> DeviceInfoSyncBridge::GetAllDataForDebugging() {}

std::string DeviceInfoSyncBridge::GetClientTag(const EntityData& entity_data) {}

std::string DeviceInfoSyncBridge::GetStorageKey(const EntityData& entity_data) {}

void DeviceInfoSyncBridge::ApplyDisableSyncChanges(
    std::unique_ptr<MetadataChangeList> delete_metadata_change_list) {}

DataTypeSyncBridge::CommitAttemptFailedBehavior
DeviceInfoSyncBridge::OnCommitAttemptFailed(
    syncer::SyncCommitError commit_error) {}

bool DeviceInfoSyncBridge::IsSyncing() const {}

const DeviceInfo* DeviceInfoSyncBridge::GetDeviceInfo(
    const std::string& client_id) const {}

std::vector<const DeviceInfo*> DeviceInfoSyncBridge::GetAllDeviceInfo() const {}

std::vector<const DeviceInfo*> DeviceInfoSyncBridge::GetAllChromeDeviceInfo()
    const {}

void DeviceInfoSyncBridge::AddObserver(Observer* observer) {}

void DeviceInfoSyncBridge::RemoveObserver(Observer* observer) {}

bool DeviceInfoSyncBridge::IsRecentLocalCacheGuid(
    const std::string& cache_guid) const {}

bool DeviceInfoSyncBridge::IsPulseTimerRunningForTest() const {}

void DeviceInfoSyncBridge::ForcePulseForTest() {}

void DeviceInfoSyncBridge::NotifyObservers() {}

// static
std::optional<ModelError> DeviceInfoSyncBridge::ParseSpecificsOnBackendSequence(
    ClientIdToDeviceInfo* all_data,
    std::unique_ptr<DataTypeStore::RecordList> record_list) {}

void DeviceInfoSyncBridge::StoreSpecifics(DeviceInfoSpecifics specifics,
                                          WriteBatch* batch) {}

bool DeviceInfoSyncBridge::DeleteSpecifics(const std::string& guid,
                                           WriteBatch* batch) {}

std::string DeviceInfoSyncBridge::GetLocalClientName() const {}

void DeviceInfoSyncBridge::OnStoreCreated(
    const std::optional<syncer::ModelError>& error,
    std::unique_ptr<DataTypeStore> store) {}

void DeviceInfoSyncBridge::OnLocalDeviceNameInfoRetrieved(
    LocalDeviceNameInfo local_device_name_info) {}

void DeviceInfoSyncBridge::OnReadAllData(
    std::unique_ptr<ClientIdToDeviceInfo> all_data,
    const std::optional<syncer::ModelError>& error) {}

void DeviceInfoSyncBridge::OnReadAllMetadata(
    const std::optional<ModelError>& error,
    std::unique_ptr<MetadataBatch> metadata_batch) {}

void DeviceInfoSyncBridge::OnCommit(
    const std::optional<syncer::ModelError>& error) {}

bool DeviceInfoSyncBridge::ReconcileLocalAndStored() {}

void DeviceInfoSyncBridge::SendLocalData() {}

void DeviceInfoSyncBridge::SendLocalDataWithBatch(
    std::unique_ptr<DataTypeStore::WriteBatch> batch) {}

void DeviceInfoSyncBridge::CommitAndNotify(std::unique_ptr<WriteBatch> batch,
                                           bool should_notify) {}

std::map<DeviceInfo::FormFactor, int>
DeviceInfoSyncBridge::CountActiveDevicesByType() const {}

void DeviceInfoSyncBridge::ExpireOldEntries() {}

}  // namespace syncer