Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
Mikel Astiz | 91c345c | 2023-05-16 14:18:56 | [diff] [blame] | 5 | #ifndef COMPONENTS_SYNC_SERVICE_SYNC_API_COMPONENT_FACTORY_H_ |
6 | #define COMPONENTS_SYNC_SERVICE_SYNC_API_COMPONENT_FACTORY_H_ | ||||
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 7 | |
dcheng | b21a1b1 | 2016-04-21 19:23:13 | [diff] [blame] | 8 | #include <memory> |
skym | 9dbfbcf | 2015-10-09 18:44:33 | [diff] [blame] | 9 | #include <string> |
10 | |||||
Max Bogue | fef332d | 2016-07-28 22:09:09 | [diff] [blame] | 11 | #include "components/sync/base/model_type.h" |
Mikel Astiz | 91c345c | 2023-05-16 14:18:56 | [diff] [blame] | 12 | #include "components/sync/service/data_type_controller.h" |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 13 | |
zea | 5758a24 | 2015-08-18 05:06:20 | [diff] [blame] | 14 | namespace syncer { |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 15 | |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 16 | class DataTypeEncryptionHandler; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 17 | class DataTypeManager; |
18 | class DataTypeManagerObserver; | ||||
Mikel Astiz | acaea41d | 2021-08-05 09:48:22 | [diff] [blame] | 19 | class ModelTypeConfigurer; |
maxbogue | 6dcda76 | 2016-12-05 20:45:56 | [diff] [blame] | 20 | class SyncEngine; |
Rushan Suleymanov | d5c5ef5 | 2020-07-30 13:07:24 | [diff] [blame] | 21 | class SyncInvalidationsService; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 22 | |
Mikel Astiz | 91c345c | 2023-05-16 14:18:56 | [diff] [blame] | 23 | // This factory provides sync service code with the model type specific sync/api |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 24 | // service (like SyncableService) implementations. |
25 | class SyncApiComponentFactory { | ||||
26 | public: | ||||
Marc Treib | 8c8f4b3 | 2021-05-27 17:53:47 | [diff] [blame] | 27 | virtual ~SyncApiComponentFactory() = default; |
[email protected] | 0ae5be3 | 2014-05-20 06:14:54 | [diff] [blame] | 28 | |
Marc Treib | f699c4d | 2018-05-11 11:42:05 | [diff] [blame] | 29 | virtual std::unique_ptr<DataTypeManager> CreateDataTypeManager( |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 30 | const DataTypeController::TypeMap* controllers, |
31 | const DataTypeEncryptionHandler* encryption_handler, | ||||
maxbogue | 27ff5590 | 2016-12-08 01:38:14 | [diff] [blame] | 32 | ModelTypeConfigurer* configurer, |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 33 | DataTypeManagerObserver* observer) = 0; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 34 | |
Rushan Suleymanov | 1b4c9d0 | 2023-07-26 07:21:33 | [diff] [blame] | 35 | // Creating this in the factory helps us mock it out in testing. |
Mikel Astiz | 527d0a1e | 2023-09-22 12:05:35 | [diff] [blame^] | 36 | // `sync_invalidation_service` must not be null. |
Marc Treib | f699c4d | 2018-05-11 11:42:05 | [diff] [blame] | 37 | virtual std::unique_ptr<SyncEngine> CreateSyncEngine( |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 38 | const std::string& name, |
Rushan Suleymanov | 137294e | 2023-01-05 11:29:01 | [diff] [blame] | 39 | SyncInvalidationsService* sync_invalidation_service) = 0; |
Victor Hugo Vianna Silva | 29c3019 | 2020-10-15 18:54:04 | [diff] [blame] | 40 | |
Mikel Astiz | 527d0a1e | 2023-09-22 12:05:35 | [diff] [blame^] | 41 | // Returns whether the local transport data indicates that a sync engine |
42 | // previously initialized successfully and hence populated at least some | ||||
43 | // transport data (e.g. birthday). It also implies that the client | ||||
44 | // successfully communicated to the server at least once. | ||||
45 | virtual bool HasTransportDataIncludingFirstSync() = 0; | ||||
46 | |||||
Mikel Astiz | c959c65d | 2021-05-03 18:49:15 | [diff] [blame] | 47 | // Clears all local transport data. Upon calling this, the deletion is |
Mikel Astiz | 527d0a1e | 2023-09-22 12:05:35 | [diff] [blame^] | 48 | // guaranteed to finish before a new engine returned by `CreateSyncEngine()` |
Mikel Astiz | c959c65d | 2021-05-03 18:49:15 | [diff] [blame] | 49 | // can do any proper work. |
50 | virtual void ClearAllTransportData() = 0; | ||||
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 51 | }; |
52 | |||||
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 53 | } // namespace syncer |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 54 | |
Mikel Astiz | 91c345c | 2023-05-16 14:18:56 | [diff] [blame] | 55 | #endif // COMPONENTS_SYNC_SERVICE_SYNC_API_COMPONENT_FACTORY_H_ |