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" |
Marc Treib | a2fa834d | 2024-03-27 09:17:51 | [diff] [blame] | 12 | #include "components/sync/service/model_type_controller.h" |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 13 | |
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame^] | 14 | namespace signin { |
15 | class GaiaIdHash; | ||||
16 | } | ||||
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; | ||||
maxbogue | 6dcda76 | 2016-12-05 20:45:56 | [diff] [blame] | 23 | class SyncEngine; |
Rushan Suleymanov | d5c5ef5 | 2020-07-30 13:07:24 | [diff] [blame] | 24 | class SyncInvalidationsService; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 25 | |
Mikel Astiz | 91c345c | 2023-05-16 14:18:56 | [diff] [blame] | 26 | // This factory provides sync service code with the model type specific sync/api |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 27 | // service (like SyncableService) implementations. |
28 | class SyncApiComponentFactory { | ||||
29 | public: | ||||
Marc Treib | 8c8f4b3 | 2021-05-27 17:53:47 | [diff] [blame] | 30 | virtual ~SyncApiComponentFactory() = default; |
[email protected] | 0ae5be3 | 2014-05-20 06:14:54 | [diff] [blame] | 31 | |
Marc Treib | f699c4d | 2018-05-11 11:42:05 | [diff] [blame] | 32 | virtual std::unique_ptr<DataTypeManager> CreateDataTypeManager( |
Marc Treib | 2182c9e | 2024-03-25 16:58:23 | [diff] [blame] | 33 | const ModelTypeController::TypeMap* controllers, |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 34 | const DataTypeEncryptionHandler* encryption_handler, |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 35 | DataTypeManagerObserver* observer) = 0; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 36 | |
Rushan Suleymanov | 1b4c9d0 | 2023-07-26 07:21:33 | [diff] [blame] | 37 | // Creating this in the factory helps us mock it out in testing. |
Mikel Astiz | 527d0a1e | 2023-09-22 12:05:35 | [diff] [blame] | 38 | // `sync_invalidation_service` must not be null. |
Marc Treib | f699c4d | 2018-05-11 11:42:05 | [diff] [blame] | 39 | virtual std::unique_ptr<SyncEngine> CreateSyncEngine( |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 40 | const std::string& name, |
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame^] | 41 | const signin::GaiaIdHash& gaia_id_hash, |
Rushan Suleymanov | 137294e | 2023-01-05 11:29:01 | [diff] [blame] | 42 | SyncInvalidationsService* sync_invalidation_service) = 0; |
Victor Hugo Vianna Silva | 29c3019 | 2020-10-15 18:54:04 | [diff] [blame] | 43 | |
Mikel Astiz | 527d0a1e | 2023-09-22 12:05:35 | [diff] [blame] | 44 | // Returns whether the local transport data indicates that a sync engine |
45 | // previously initialized successfully and hence populated at least some | ||||
46 | // transport data (e.g. birthday). It also implies that the client | ||||
47 | // successfully communicated to the server at least once. | ||||
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame^] | 48 | virtual bool HasTransportDataIncludingFirstSync( |
49 | const signin::GaiaIdHash& gaia_id_hash) = 0; | ||||
Mikel Astiz | 527d0a1e | 2023-09-22 12:05:35 | [diff] [blame] | 50 | |
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame^] | 51 | // Cleans up potentially-leftover sync data. Usually the SyncEngine is |
52 | // responsible for that; this is meant to be called if sync gets disabled | ||||
53 | // while the engine doesn't exist. | ||||
54 | virtual void CleanupOnDisableSync() = 0; | ||||
55 | |||||
56 | // Clears local transport data (cache GUID etc) for the given account. | ||||
57 | virtual void ClearTransportDataForAccount( | ||||
58 | const signin::GaiaIdHash& gaia_id_hash) = 0; | ||||
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 59 | }; |
60 | |||||
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 61 | } // namespace syncer |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 62 | |
Mikel Astiz | 91c345c | 2023-05-16 14:18:56 | [diff] [blame] | 63 | #endif // COMPONENTS_SYNC_SERVICE_SYNC_API_COMPONENT_FACTORY_H_ |