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