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 16 matching lines...) Expand all Loading... |
27 // Interface implemented by model types to receive updates from sync via a | 27 // Interface implemented by model types to receive updates from sync via a |
28 // ModelTypeChangeProcessor. Provides a way for sync to update the data and | 28 // ModelTypeChangeProcessor. Provides a way for sync to update the data and |
29 // metadata for entities, as well as the model type state. Sync bridge | 29 // metadata for entities, as well as the model type state. Sync bridge |
30 // implementations must provide their change_processor() with metadata through | 30 // implementations must provide their change_processor() with metadata through |
31 // ModelReadyToSync() as soon as possible. Once this is called, sync will | 31 // ModelReadyToSync() as soon as possible. Once this is called, sync will |
32 // immediately begin locally tracking changes and can start syncing with the | 32 // immediately begin locally tracking changes and can start syncing with the |
33 // server soon afterward. If an error occurs during startup, the processor's | 33 // server soon afterward. If an error occurs during startup, the processor's |
34 // ReportError() method should be called instead of ModelReadyToSync(). | 34 // ReportError() method should be called instead of ModelReadyToSync(). |
35 class ModelTypeSyncBridge : public base::SupportsWeakPtr<ModelTypeSyncBridge> { | 35 class ModelTypeSyncBridge : public base::SupportsWeakPtr<ModelTypeSyncBridge> { |
36 public: | 36 public: |
37 typedef base::Callback<void(std::unique_ptr<DataBatch>)> DataCallback; | 37 using DataCallback = base::Callback<void(std::unique_ptr<DataBatch>)>; |
38 typedef std::vector<std::string> StorageKeyList; | 38 using StorageKeyList = std::vector<std::string>; |
39 typedef base::RepeatingCallback<std::unique_ptr<ModelTypeChangeProcessor>( | 39 using ChangeProcessorFactory = base::RepeatingCallback<std::unique_ptr< |
40 ModelType type, | 40 ModelTypeChangeProcessor>(ModelType type, ModelTypeSyncBridge* bridge)>; |
41 ModelTypeSyncBridge* bridge)> | |
42 ChangeProcessorFactory; | |
43 | 41 |
44 ModelTypeSyncBridge(const ChangeProcessorFactory& change_processor_factory, | 42 ModelTypeSyncBridge(const ChangeProcessorFactory& change_processor_factory, |
45 ModelType type); | 43 ModelType type); |
46 | 44 |
47 virtual ~ModelTypeSyncBridge(); | 45 virtual ~ModelTypeSyncBridge(); |
48 | 46 |
49 // Creates an object used to communicate changes in the sync metadata to the | 47 // Creates an object used to communicate changes in the sync metadata to the |
50 // model type store. | 48 // model type store. |
51 virtual std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; | 49 virtual std::unique_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; |
52 | 50 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 const ModelType type_; | 128 const ModelType type_; |
131 | 129 |
132 const ChangeProcessorFactory change_processor_factory_; | 130 const ChangeProcessorFactory change_processor_factory_; |
133 | 131 |
134 std::unique_ptr<ModelTypeChangeProcessor> change_processor_; | 132 std::unique_ptr<ModelTypeChangeProcessor> change_processor_; |
135 }; | 133 }; |
136 | 134 |
137 } // namespace syncer | 135 } // namespace syncer |
138 | 136 |
139 #endif // COMPONENTS_SYNC_MODEL_MODEL_TYPE_SYNC_BRIDGE_H_ | 137 #endif // COMPONENTS_SYNC_MODEL_MODEL_TYPE_SYNC_BRIDGE_H_ |
OLD | NEW |