OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_USER_EVENTS_USER_EVENT_SYNC_BRIDGE_H_ | 5 #ifndef COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SYNC_BRIDGE_H_ |
6 #define COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SYNC_BRIDGE_H_ | 6 #define COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SYNC_BRIDGE_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <map> |
8 #include <memory> | 11 #include <memory> |
9 #include <string> | 12 #include <string> |
10 | 13 |
11 #include "base/macros.h" | 14 #include "base/macros.h" |
12 #include "components/sync/model/model_type_store.h" | 15 #include "components/sync/model/model_type_store.h" |
13 #include "components/sync/model/model_type_sync_bridge.h" | 16 #include "components/sync/model/model_type_sync_bridge.h" |
| 17 #include "components/sync/user_events/global_id_mapper.h" |
14 | 18 |
15 namespace syncer { | 19 namespace syncer { |
16 | 20 |
17 class UserEventSyncBridge : public ModelTypeSyncBridge { | 21 class UserEventSyncBridge : public ModelTypeSyncBridge { |
18 public: | 22 public: |
19 UserEventSyncBridge(const ModelTypeStoreFactory& store_factory, | 23 UserEventSyncBridge(const ModelTypeStoreFactory& store_factory, |
20 const ChangeProcessorFactory& change_processor_factory); | 24 const ChangeProcessorFactory& change_processor_factory, |
| 25 GlobalIdMapper* global_id_mapper); |
21 ~UserEventSyncBridge() override; | 26 ~UserEventSyncBridge() override; |
22 | 27 |
23 // ModelTypeSyncBridge implementation. | 28 // ModelTypeSyncBridge implementation. |
24 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override; | 29 std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() override; |
25 base::Optional<ModelError> MergeSyncData( | 30 base::Optional<ModelError> MergeSyncData( |
26 std::unique_ptr<MetadataChangeList> metadata_change_list, | 31 std::unique_ptr<MetadataChangeList> metadata_change_list, |
27 EntityChangeList entity_data) override; | 32 EntityChangeList entity_data) override; |
28 base::Optional<ModelError> ApplySyncChanges( | 33 base::Optional<ModelError> ApplySyncChanges( |
29 std::unique_ptr<MetadataChangeList> metadata_change_list, | 34 std::unique_ptr<MetadataChangeList> metadata_change_list, |
30 EntityChangeList entity_changes) override; | 35 EntityChangeList entity_changes) override; |
(...skipping 15 matching lines...) Expand all Loading... |
46 ModelTypeStore::Result result, | 51 ModelTypeStore::Result result, |
47 std::unique_ptr<ModelTypeStore::RecordList> data_records, | 52 std::unique_ptr<ModelTypeStore::RecordList> data_records, |
48 std::unique_ptr<ModelTypeStore::IdList> missing_id_list); | 53 std::unique_ptr<ModelTypeStore::IdList> missing_id_list); |
49 void OnReadAllData(DataCallback callback, | 54 void OnReadAllData(DataCallback callback, |
50 ModelTypeStore::Result result, | 55 ModelTypeStore::Result result, |
51 std::unique_ptr<ModelTypeStore::RecordList> data_records); | 56 std::unique_ptr<ModelTypeStore::RecordList> data_records); |
52 void OnReadAllDataToDelete( | 57 void OnReadAllDataToDelete( |
53 ModelTypeStore::Result result, | 58 ModelTypeStore::Result result, |
54 std::unique_ptr<ModelTypeStore::RecordList> data_records); | 59 std::unique_ptr<ModelTypeStore::RecordList> data_records); |
55 | 60 |
| 61 void HandleGlobalIdChange(int64_t old_global_id, int64_t new_global_id); |
| 62 |
56 // Persistent storage for in flight events. Should remain quite small, as we | 63 // Persistent storage for in flight events. Should remain quite small, as we |
57 // delete upon commit confirmation. | 64 // delete upon commit confirmation. |
58 std::unique_ptr<ModelTypeStore> store_; | 65 std::unique_ptr<ModelTypeStore> store_; |
59 | 66 |
| 67 // The key is the global_id of the navigation the event is linked to. |
| 68 std::multimap<int64_t, sync_pb::UserEventSpecifics> |
| 69 in_flight_nav_linked_events_; |
| 70 |
| 71 GlobalIdMapper* global_id_mapper_; |
| 72 |
60 DISALLOW_COPY_AND_ASSIGN(UserEventSyncBridge); | 73 DISALLOW_COPY_AND_ASSIGN(UserEventSyncBridge); |
61 }; | 74 }; |
62 | 75 |
63 } // namespace syncer | 76 } // namespace syncer |
64 | 77 |
65 #endif // COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SYNC_BRIDGE_H_ | 78 #endif // COMPONENTS_SYNC_USER_EVENTS_USER_EVENT_SYNC_BRIDGE_H_ |
OLD | NEW |