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 | |||||
5 | #ifndef COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ | ||||
6 | #define COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ | ||||
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" |
maxbogue | 455a57e3 | 2016-08-14 00:08:32 | [diff] [blame] | 12 | #include "components/sync/driver/data_type_controller.h" |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 13 | |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 14 | namespace invalidation { |
15 | class InvalidationService; | ||||
16 | } // namespace invalidation | ||||
17 | |||||
zea | 5758a24 | 2015-08-18 05:06:20 | [diff] [blame] | 18 | namespace syncer { |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 19 | |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 20 | class DataTypeEncryptionHandler; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 21 | class DataTypeManager; |
22 | class DataTypeManagerObserver; | ||||
Mikel Astiz | acaea41d | 2021-08-05 09:48:22 | [diff] [blame] | 23 | class ModelTypeConfigurer; |
maxbogue | 6dcda76 | 2016-12-05 20:45:56 | [diff] [blame] | 24 | class SyncEngine; |
Rushan Suleymanov | d5c5ef5 | 2020-07-30 13:07:24 | [diff] [blame] | 25 | class SyncInvalidationsService; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 26 | |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 27 | // This factory provides sync driver code with the model type specific sync/api |
28 | // service (like SyncableService) implementations. | ||||
29 | class SyncApiComponentFactory { | ||||
30 | public: | ||||
Marc Treib | 8c8f4b3 | 2021-05-27 17:53:47 | [diff] [blame] | 31 | virtual ~SyncApiComponentFactory() = default; |
[email protected] | 0ae5be3 | 2014-05-20 06:14:54 | [diff] [blame] | 32 | |
Marc Treib | f699c4d | 2018-05-11 11:42:05 | [diff] [blame] | 33 | virtual std::unique_ptr<DataTypeManager> CreateDataTypeManager( |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 34 | const DataTypeController::TypeMap* controllers, |
35 | const DataTypeEncryptionHandler* encryption_handler, | ||||
maxbogue | 27ff5590 | 2016-12-08 01:38:14 | [diff] [blame] | 36 | ModelTypeConfigurer* configurer, |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 37 | DataTypeManagerObserver* observer) = 0; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 38 | |
Rushan Suleymanov | d5c5ef5 | 2020-07-30 13:07:24 | [diff] [blame] | 39 | // Creating this in the factory helps us mock it out in testing. |invalidator| |
40 | // and |sync_invalidation_service| are different invalidations. SyncEngine | ||||
41 | // handles incoming invalidations from both of them (if provided). | ||||
42 | // |sync_invalidation_service| is a new sync-specific invalidations service | ||||
Rushan Suleymanov | 137294e | 2023-01-05 11:29:01 | [diff] [blame^] | 43 | // and must not be null. In future, there will be only one invalidation |
44 | // service. | ||||
Marc Treib | f699c4d | 2018-05-11 11:42:05 | [diff] [blame] | 45 | virtual std::unique_ptr<SyncEngine> CreateSyncEngine( |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 46 | const std::string& name, |
47 | invalidation::InvalidationService* invalidator, | ||||
Rushan Suleymanov | 137294e | 2023-01-05 11:29:01 | [diff] [blame^] | 48 | SyncInvalidationsService* sync_invalidation_service) = 0; |
Victor Hugo Vianna Silva | 29c3019 | 2020-10-15 18:54:04 | [diff] [blame] | 49 | |
Mikel Astiz | c959c65d | 2021-05-03 18:49:15 | [diff] [blame] | 50 | // Clears all local transport data. Upon calling this, the deletion is |
51 | // guaranteed to finish before a new engine returned by |CreateSyncEngine()| | ||||
52 | // can do any proper work. | ||||
53 | virtual void ClearAllTransportData() = 0; | ||||
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 54 | }; |
55 | |||||
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 56 | } // namespace syncer |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 57 | |
58 | #endif // COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ |