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 | 055d1fc | 2024-07-30 10:43:59 | [diff] [blame] | 5 | #ifndef COMPONENTS_SYNC_SERVICE_SYNC_ENGINE_FACTORY_H_ |
| 6 | #define COMPONENTS_SYNC_SERVICE_SYNC_ENGINE_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 | |
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame] | 11 | namespace signin { |
| 12 | class GaiaIdHash; |
Mikel Astiz | 055d1fc | 2024-07-30 10:43:59 | [diff] [blame] | 13 | } // namespace signin |
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame] | 14 | |
zea | 5758a24 | 2015-08-18 05:06:20 | [diff] [blame] | 15 | namespace syncer { |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 16 | |
maxbogue | 6dcda76 | 2016-12-05 20:45:56 | [diff] [blame] | 17 | class SyncEngine; |
Rushan Suleymanov | d5c5ef5 | 2020-07-30 13:07:24 | [diff] [blame] | 18 | class SyncInvalidationsService; |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 19 | |
Mikel Astiz | 055d1fc | 2024-07-30 10:43:59 | [diff] [blame] | 20 | // Class responsible for instantiating SyncEngine and restoring its state |
| 21 | // (transport data including cache GUID, birthday, Nigori, etc.). In addition to |
| 22 | // acting as a factory, it fully abstrcts and encapsulates the storage of |
| 23 | // transport data and offers APIs to interact with this data even without having |
| 24 | // to instantiate SyncEngine. |
| 25 | class SyncEngineFactory { |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 26 | public: |
Mikel Astiz | 055d1fc | 2024-07-30 10:43:59 | [diff] [blame] | 27 | virtual ~SyncEngineFactory() = default; |
[email protected] | 0ae5be3 | 2014-05-20 06:14:54 | [diff] [blame] | 28 | |
Victor Hugo Vianna Silva | cb403cff | 2024-09-12 08:06:34 | [diff] [blame] | 29 | // Instantiates SyncEngine for a specific account determined by |
| 30 | // `gaia_id_hash`. `sync_invalidation_service` must not be null. `name` is for |
| 31 | // logging purposes only, useful in integration tests that involve multiple |
| 32 | // clients. |
Marc Treib | f699c4d | 2018-05-11 11:42:05 | [diff] [blame] | 33 | virtual std::unique_ptr<SyncEngine> CreateSyncEngine( |
zea | 9276f21 | 2015-08-29 01:35:03 | [diff] [blame] | 34 | const std::string& name, |
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame] | 35 | const signin::GaiaIdHash& gaia_id_hash, |
Rushan Suleymanov | 137294e | 2023-01-05 11:29:01 | [diff] [blame] | 36 | SyncInvalidationsService* sync_invalidation_service) = 0; |
Victor Hugo Vianna Silva | 29c3019 | 2020-10-15 18:54:04 | [diff] [blame] | 37 | |
Mikel Astiz | 527d0a1e | 2023-09-22 12:05:35 | [diff] [blame] | 38 | // Returns whether the local transport data indicates that a sync engine |
| 39 | // previously initialized successfully and hence populated at least some |
| 40 | // transport data (e.g. birthday). It also implies that the client |
| 41 | // successfully communicated to the server at least once. |
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame] | 42 | virtual bool HasTransportDataIncludingFirstSync( |
| 43 | const signin::GaiaIdHash& gaia_id_hash) = 0; |
Mikel Astiz | 527d0a1e | 2023-09-22 12:05:35 | [diff] [blame] | 44 | |
Marc Treib | d291751 | 2024-05-16 11:24:58 | [diff] [blame] | 45 | // Cleans up potentially-leftover sync data. Usually the SyncEngine is |
| 46 | // responsible for that; this is meant to be called if sync gets disabled |
| 47 | // while the engine doesn't exist. |
| 48 | virtual void CleanupOnDisableSync() = 0; |
| 49 | |
| 50 | // Clears local transport data (cache GUID etc) for the given account. |
| 51 | virtual void ClearTransportDataForAccount( |
| 52 | const signin::GaiaIdHash& gaia_id_hash) = 0; |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 53 | }; |
| 54 | |
maxbogue | 7e006db | 2016-10-03 19:48:28 | [diff] [blame] | 55 | } // namespace syncer |
[email protected] | 553ee5ae | 2014-04-22 00:19:19 | [diff] [blame] | 56 | |
Mikel Astiz | 055d1fc | 2024-07-30 10:43:59 | [diff] [blame] | 57 | #endif // COMPONENTS_SYNC_SERVICE_SYNC_ENGINE_FACTORY_H_ |