sync_metadata_store.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2017 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_MODEL_SYNC_METADATA_STORE_H_
  5. #define COMPONENTS_SYNC_MODEL_SYNC_METADATA_STORE_H_
  6. #include <string>
  7. #include "components/sync/base/model_type.h"
  8. namespace sync_pb {
  9. class EntityMetadata;
  10. class ModelTypeState;
  11. } // namespace sync_pb
  12. namespace syncer {
  13. // SyncMetadataStore defines interface implemented by model types for persisting
  14. // sync metadata and datatype state. It allows model type to use common
  15. // implementation of MetadataChangeList (SyncMetadataStoreChangeList) instead of
  16. // implementing their own.
  17. // Model type in implementation of ModelTypeSyncBridge::CreateMetadataChangeList
  18. // should create instance of SyncMetadataStoreChangeList passing pointer to
  19. // SyncMetadataStore to its constructor.
  20. // Implementations of SyncMetadataStore methods should support add/update/delete
  21. // metadata in model type specific sync metadata storage.
  22. class SyncMetadataStore {
  23. public:
  24. SyncMetadataStore() {}
  25. virtual ~SyncMetadataStore() {}
  26. // Update the metadata row for |model_type|, keyed by |storage_key|, to
  27. // contain the contents of |metadata|.
  28. // Return true on success.
  29. virtual bool UpdateSyncMetadata(syncer::ModelType model_type,
  30. const std::string& storage_key,
  31. const sync_pb::EntityMetadata& metadata) = 0;
  32. // Remove the metadata row of type |model_type| keyed by |storage_key|.
  33. // Return true on success.
  34. virtual bool ClearSyncMetadata(syncer::ModelType model_type,
  35. const std::string& storage_key) = 0;
  36. // Update the stored sync state for the |model_type|.
  37. // Return true on success.
  38. virtual bool UpdateModelTypeState(
  39. syncer::ModelType model_type,
  40. const sync_pb::ModelTypeState& model_type_state) = 0;
  41. // Clear the stored sync state for |model_type|.
  42. // Return true on success.
  43. virtual bool ClearModelTypeState(syncer::ModelType model_type) = 0;
  44. };
  45. } // namespace syncer
  46. #endif // COMPONENTS_SYNC_MODEL_SYNC_METADATA_STORE_H_