nigori_sync_bridge.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SYNC_NIGORI_NIGORI_SYNC_BRIDGE_H_
  5. #define COMPONENTS_SYNC_NIGORI_NIGORI_SYNC_BRIDGE_H_
  6. #include <memory>
  7. #include "components/sync/model/conflict_resolution.h"
  8. #include "components/sync/model/model_error.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. namespace syncer {
  11. struct EntityData;
  12. // Interface implemented by Nigori model to receive Nigori updates from sync via
  13. // a ModelTypeChangeProcessor. Provides a way for sync to update the data and
  14. // metadata for Nigori entities, as well as the model type state.
  15. class NigoriSyncBridge {
  16. public:
  17. NigoriSyncBridge() = default;
  18. NigoriSyncBridge(const NigoriSyncBridge&) = delete;
  19. NigoriSyncBridge& operator=(const NigoriSyncBridge&) = delete;
  20. virtual ~NigoriSyncBridge() = default;
  21. // Perform the initial merge between local and sync data.
  22. virtual absl::optional<ModelError> MergeSyncData(
  23. absl::optional<EntityData> data) = 0;
  24. // Apply changes from the sync server locally.
  25. virtual absl::optional<ModelError> ApplySyncChanges(
  26. absl::optional<EntityData> data) = 0;
  27. // Retrieve Nigori sync data.
  28. virtual std::unique_ptr<EntityData> GetData() = 0;
  29. // Informs the bridge that sync has been disabed. The bridge is responsible
  30. // for deleting all data and metadata upon disabling sync.
  31. virtual void ApplyDisableSyncChanges() = 0;
  32. };
  33. } // namespace syncer
  34. #endif // COMPONENTS_SYNC_NIGORI_NIGORI_SYNC_BRIDGE_H_