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 20 matching lines...) Expand all Loading... |
31 typedef std::vector<std::string> ClientTagList; | 31 typedef std::vector<std::string> ClientTagList; |
32 | 32 |
33 ModelTypeService(); | 33 ModelTypeService(); |
34 | 34 |
35 virtual ~ModelTypeService(); | 35 virtual ~ModelTypeService(); |
36 | 36 |
37 // Creates an object used to communicate changes in the sync metadata to the | 37 // Creates an object used to communicate changes in the sync metadata to the |
38 // model type store. | 38 // model type store. |
39 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; | 39 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; |
40 | 40 |
41 // Perform the initial merge of data from the sync server. Should only need | 41 // Perform the initial merge between local and sync data. This should only be |
42 // to be called when sync is first turned on, not on every restart. | 42 // called when a data type is first enabled to start syncing, and there is no |
| 43 // sync metadata. Best effort should be made to match local and sync data. The |
| 44 // keys in the |entity_data_map| will have been created via GetClientTag(...), |
| 45 // and if a local and sync data should match/merge but disagree on tags, the |
| 46 // service should use the sync data's tag. Any local pieces of data that are |
| 47 // not present in sync should immediately be Put(...) to the processor before |
| 48 // returning. The same MetadataChangeList that was passed into this function |
| 49 // can be passed to Put(...) calls. Delete(...) can also be called but should |
| 50 // not be needed for most model types. Durable storage writes, if not able to |
| 51 // combine all change atomically, should save the metadata after the data |
| 52 // changes, so that this merge will be re-driven by sync if is not completely |
| 53 // saved during the current run. |
43 virtual syncer::SyncError MergeSyncData( | 54 virtual syncer::SyncError MergeSyncData( |
44 scoped_ptr<MetadataChangeList> metadata_change_list, | 55 scoped_ptr<MetadataChangeList> metadata_change_list, |
45 EntityDataMap entity_data_map) = 0; | 56 EntityDataMap entity_data_map) = 0; |
46 | 57 |
47 // Apply changes from the sync server locally. | 58 // Apply changes from the sync server locally. |
48 // Please note that |entity_changes| might have fewer entries than | 59 // Please note that |entity_changes| might have fewer entries than |
49 // |metadata_change_list| in case when some of the data changes are filtered | 60 // |metadata_change_list| in case when some of the data changes are filtered |
50 // out, or even be empty in case when a commit confirmation is processed and | 61 // out, or even be empty in case when a commit confirmation is processed and |
51 // only the metadata needs to persisted. | 62 // only the metadata needs to persisted. |
52 virtual syncer::SyncError ApplySyncChanges( | 63 virtual syncer::SyncError ApplySyncChanges( |
(...skipping 23 matching lines...) Expand all Loading... |
76 void clear_change_processor(); | 87 void clear_change_processor(); |
77 | 88 |
78 private: | 89 private: |
79 // Recieves ownership in set_change_processor(...). | 90 // Recieves ownership in set_change_processor(...). |
80 scoped_ptr<ModelTypeChangeProcessor> change_processor_; | 91 scoped_ptr<ModelTypeChangeProcessor> change_processor_; |
81 }; | 92 }; |
82 | 93 |
83 } // namespace syncer_v2 | 94 } // namespace syncer_v2 |
84 | 95 |
85 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_ | 96 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_ |
OLD | NEW |