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 COMPONENTS_SYNC_MODEL_MODEL_TYPE_SYNC_BRIDGE_H_ | 5 #ifndef COMPONENTS_SYNC_MODEL_MODEL_TYPE_SYNC_BRIDGE_H_ |
6 #define COMPONENTS_SYNC_MODEL_MODEL_TYPE_SYNC_BRIDGE_H_ | 6 #define COMPONENTS_SYNC_MODEL_MODEL_TYPE_SYNC_BRIDGE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // delete one of the records (preferably local). Any local pieces of data that | 59 // delete one of the records (preferably local). Any local pieces of data that |
60 // are not present in sync should immediately be Put(...) to the processor | 60 // are not present in sync should immediately be Put(...) to the processor |
61 // before returning. The same MetadataChangeList that was passed into this | 61 // before returning. The same MetadataChangeList that was passed into this |
62 // function can be passed to Put(...) calls. Delete(...) can also be called | 62 // function can be passed to Put(...) calls. Delete(...) can also be called |
63 // but should not be needed for most model types. Durable storage writes, if | 63 // but should not be needed for most model types. Durable storage writes, if |
64 // not able to combine all change atomically, should save the metadata after | 64 // not able to combine all change atomically, should save the metadata after |
65 // the data changes, so that this merge will be re-driven by sync if is not | 65 // the data changes, so that this merge will be re-driven by sync if is not |
66 // completely saved during the current run. | 66 // completely saved during the current run. |
67 virtual base::Optional<ModelError> MergeSyncData( | 67 virtual base::Optional<ModelError> MergeSyncData( |
68 std::unique_ptr<MetadataChangeList> metadata_change_list, | 68 std::unique_ptr<MetadataChangeList> metadata_change_list, |
69 EntityChangeList entity_data); | 69 EntityChangeList entity_data) = 0; |
70 | |
71 // Perform the initial merge between local and sync data. This should only be | |
72 // called when a data type is first enabled to start syncing, and there is no | |
73 // sync metadata. Best effort should be made to match local and sync data. The | |
74 // keys in the |entity_data_map| will have been created via | |
75 // GetStorageKey(...), and if a local and sync data should match/merge but | |
76 // disagree on storage key, the bridge should delete one of the records | |
77 // (preferably local). Any local pieces of data that are not present in sync | |
78 // should immediately be Put(...) to the processor before returning. The same | |
79 // MetadataChangeList that was passed into this function can be passed to | |
80 // Put(...) calls. Delete(...) can also be called but should not be needed for | |
81 // most model types. Durable storage writes, if not able to combine all change | |
82 // atomically, should save the metadata after the data changes, so that this | |
83 // merge will be re-driven by sync if is not completely saved during the | |
84 // current run. | |
85 // TODO(pavely): This function should be removed as part of crbug.com/719570 | |
86 // once all bridge implementations are switched to the other MergeSyncData | |
87 // signature. | |
88 virtual base::Optional<ModelError> MergeSyncData( | |
89 std::unique_ptr<MetadataChangeList> metadata_change_list, | |
90 EntityDataMap entity_data_map) = 0; | |
91 | 70 |
92 // Apply changes from the sync server locally. | 71 // Apply changes from the sync server locally. |
93 // Please note that |entity_changes| might have fewer entries than | 72 // Please note that |entity_changes| might have fewer entries than |
94 // |metadata_change_list| in case when some of the data changes are filtered | 73 // |metadata_change_list| in case when some of the data changes are filtered |
95 // out, or even be empty in case when a commit confirmation is processed and | 74 // out, or even be empty in case when a commit confirmation is processed and |
96 // only the metadata needs to persisted. | 75 // only the metadata needs to persisted. |
97 virtual base::Optional<ModelError> ApplySyncChanges( | 76 virtual base::Optional<ModelError> ApplySyncChanges( |
98 std::unique_ptr<MetadataChangeList> metadata_change_list, | 77 std::unique_ptr<MetadataChangeList> metadata_change_list, |
99 EntityChangeList entity_changes) = 0; | 78 EntityChangeList entity_changes) = 0; |
100 | 79 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 const ModelType type_; | 146 const ModelType type_; |
168 | 147 |
169 const ChangeProcessorFactory change_processor_factory_; | 148 const ChangeProcessorFactory change_processor_factory_; |
170 | 149 |
171 std::unique_ptr<ModelTypeChangeProcessor> change_processor_; | 150 std::unique_ptr<ModelTypeChangeProcessor> change_processor_; |
172 }; | 151 }; |
173 | 152 |
174 } // namespace syncer | 153 } // namespace syncer |
175 | 154 |
176 #endif // COMPONENTS_SYNC_MODEL_MODEL_TYPE_SYNC_BRIDGE_H_ | 155 #endif // COMPONENTS_SYNC_MODEL_MODEL_TYPE_SYNC_BRIDGE_H_ |
OLD | NEW |