| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SYNC_API_MODEL_TYPE_SERVICE_H_ | 5 #ifndef SYNC_API_MODEL_TYPE_SERVICE_H_ |
| 6 #define SYNC_API_MODEL_TYPE_SERVICE_H_ | 6 #define SYNC_API_MODEL_TYPE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // Interface implemented by model types to receive updates from sync via the | 25 // Interface implemented by model types to receive updates from sync via the |
| 26 // SharedModelTypeProcessor. Provides a way for sync to update the data and | 26 // SharedModelTypeProcessor. Provides a way for sync to update the data and |
| 27 // metadata for entities, as well as the model type state. | 27 // metadata for entities, as well as the model type state. |
| 28 class SYNC_EXPORT ModelTypeService { | 28 class SYNC_EXPORT ModelTypeService { |
| 29 public: | 29 public: |
| 30 typedef base::Callback<void(syncer::SyncError, scoped_ptr<DataBatch>)> | 30 typedef base::Callback<void(syncer::SyncError, scoped_ptr<DataBatch>)> |
| 31 DataCallback; | 31 DataCallback; |
| 32 typedef base::Callback<void(syncer::SyncError, scoped_ptr<MetadataBatch>)> | 32 typedef base::Callback<void(syncer::SyncError, scoped_ptr<MetadataBatch>)> |
| 33 MetadataCallback; | 33 MetadataCallback; |
| 34 typedef std::vector<std::string> ClientKeyList; | 34 typedef std::vector<std::string> ClientTagList; |
| 35 | 35 |
| 36 ModelTypeService(); | 36 ModelTypeService(); |
| 37 | 37 |
| 38 virtual ~ModelTypeService(); | 38 virtual ~ModelTypeService(); |
| 39 | 39 |
| 40 // Creates an object used to communicate changes in the sync metadata to the | 40 // Creates an object used to communicate changes in the sync metadata to the |
| 41 // model type store. | 41 // model type store. |
| 42 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; | 42 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; |
| 43 | 43 |
| 44 // Perform the initial merge of data from the sync server. Should only need | 44 // Perform the initial merge of data from the sync server. Should only need |
| 45 // to be called when sync is first turned on, not on every restart. | 45 // to be called when sync is first turned on, not on every restart. |
| 46 virtual syncer::SyncError MergeSyncData( | 46 virtual syncer::SyncError MergeSyncData( |
| 47 scoped_ptr<MetadataChangeList> metadata_change_list, | 47 scoped_ptr<MetadataChangeList> metadata_change_list, |
| 48 EntityDataList entity_data_list) = 0; | 48 EntityDataList entity_data_list) = 0; |
| 49 | 49 |
| 50 // Apply changes from the sync server locally. | 50 // Apply changes from the sync server locally. |
| 51 // Please note that |entity_changes| might have fewer entries than | 51 // Please note that |entity_changes| might have fewer entries than |
| 52 // |metadata_change_list| in case when some of the data changes are filtered | 52 // |metadata_change_list| in case when some of the data changes are filtered |
| 53 // out, or even be empty in case when a commit confirmation is processed and | 53 // out, or even be empty in case when a commit confirmation is processed and |
| 54 // only the metadata needs to persisted. | 54 // only the metadata needs to persisted. |
| 55 virtual syncer::SyncError ApplySyncChanges( | 55 virtual syncer::SyncError ApplySyncChanges( |
| 56 scoped_ptr<MetadataChangeList> metadata_change_list, | 56 scoped_ptr<MetadataChangeList> metadata_change_list, |
| 57 EntityChangeList entity_changes) = 0; | 57 EntityChangeList entity_changes) = 0; |
| 58 | 58 |
| 59 // Asynchronously retrieve the sync metadata. | 59 // Asynchronously retrieve the sync metadata. |
| 60 virtual void LoadMetadata(MetadataCallback callback) = 0; | 60 virtual void LoadMetadata(MetadataCallback callback) = 0; |
| 61 | 61 |
| 62 // Asynchronously retrieve the corresponding sync data for |client_keys|. | 62 // Asynchronously retrieve the corresponding sync data for |client_tags|. |
| 63 virtual void GetData(ClientKeyList client_keys, DataCallback callback) = 0; | 63 virtual void GetData(ClientTagList client_tags, DataCallback callback) = 0; |
| 64 | 64 |
| 65 // Asynchronously retrieve all of the local sync data. | 65 // Asynchronously retrieve all of the local sync data. |
| 66 virtual void GetAllData(DataCallback callback) = 0; | 66 virtual void GetAllData(DataCallback callback) = 0; |
| 67 | 67 |
| 68 // Get or generate a client tag for |entity_data|. | 68 // Get or generate a client tag for |entity_data|. |
| 69 virtual std::string GetClientTag(const EntityData& entity_data) = 0; | 69 virtual std::string GetClientTag(const EntityData& entity_data) = 0; |
| 70 | 70 |
| 71 // TODO(skym): See crbug/547087, do we need all these accessors? | 71 // TODO(skym): See crbug/547087, do we need all these accessors? |
| 72 syncer_v2::ModelTypeChangeProcessor* change_processor(); | 72 syncer_v2::ModelTypeChangeProcessor* change_processor(); |
| 73 | 73 |
| 74 void set_change_processor( | 74 void set_change_processor( |
| 75 scoped_ptr<syncer_v2::ModelTypeChangeProcessor> change_processor); | 75 scoped_ptr<syncer_v2::ModelTypeChangeProcessor> change_processor); |
| 76 | 76 |
| 77 void clear_change_processor(); | 77 void clear_change_processor(); |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 // Recieves ownership in set_change_processor(...). | 80 // Recieves ownership in set_change_processor(...). |
| 81 scoped_ptr<syncer_v2::ModelTypeChangeProcessor> change_processor_; | 81 scoped_ptr<syncer_v2::ModelTypeChangeProcessor> change_processor_; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace syncer_v2 | 84 } // namespace syncer_v2 |
| 85 | 85 |
| 86 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_ | 86 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_ |
| OLD | NEW |