1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SECURITY_EVENTS_SECURITY_EVENT_SYNC_BRIDGE_IMPL_H_
#define CHROME_BROWSER_SECURITY_EVENTS_SECURITY_EVENT_SYNC_BRIDGE_IMPL_H_
#include <memory>
#include <optional>
#include <string>
#include "base/memory/weak_ptr.h"
#include "chrome/browser/security_events/security_event_sync_bridge.h"
#include "components/sync/model/data_type_local_change_processor.h"
#include "components/sync/model/data_type_store_with_in_memory_cache.h"
#include "components/sync/model/data_type_sync_bridge.h"
class SecurityEventSyncBridgeImpl : public SecurityEventSyncBridge,
public syncer::DataTypeSyncBridge {
public:
SecurityEventSyncBridgeImpl(
syncer::OnceDataTypeStoreFactory store_factory,
std::unique_ptr<syncer::DataTypeLocalChangeProcessor> change_processor);
SecurityEventSyncBridgeImpl(const SecurityEventSyncBridgeImpl&) = delete;
SecurityEventSyncBridgeImpl& operator=(const SecurityEventSyncBridgeImpl&) =
delete;
~SecurityEventSyncBridgeImpl() override;
void RecordSecurityEvent(sync_pb::SecurityEventSpecifics specifics) override;
base::WeakPtr<syncer::DataTypeControllerDelegate> GetControllerDelegate()
override;
// DataTypeSyncBridge implementation.
std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList()
override;
std::optional<syncer::ModelError> MergeFullSyncData(
std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
syncer::EntityChangeList entity_data) override;
std::optional<syncer::ModelError> ApplyIncrementalSyncChanges(
std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
syncer::EntityChangeList entity_changes) override;
std::unique_ptr<syncer::DataBatch> GetDataForCommit(
StorageKeyList storage_keys) override;
std::unique_ptr<syncer::DataBatch> GetAllDataForDebugging() override;
std::string GetClientTag(
const syncer::EntityData& entity_data) const override;
std::string GetStorageKey(
const syncer::EntityData& entity_data) const override;
void ApplyDisableSyncChanges(std::unique_ptr<syncer::MetadataChangeList>
delete_metadata_change_list) override;
private:
using StoreWithCache =
syncer::DataTypeStoreWithInMemoryCache<sync_pb::SecurityEventSpecifics>;
void OnStoreLoaded(const std::optional<syncer::ModelError>& error,
std::unique_ptr<StoreWithCache> store,
std::unique_ptr<syncer::MetadataBatch> metadata_batch);
void OnStoreCommit(const std::optional<syncer::ModelError>& error);
std::unique_ptr<StoreWithCache> store_;
base::WeakPtrFactory<SecurityEventSyncBridgeImpl> weak_ptr_factory_{this};
};
#endif // CHROME_BROWSER_SECURITY_EVENTS_SECURITY_EVENT_SYNC_BRIDGE_IMPL_H_
|