blob: a14d50d27a70cf0589d1515983d38fd7312b5677 [file] [log] [blame]
Avi Drissman8ba1bad2022-09-13 19:22:361// Copyright 2014 The Chromium Authors
[email protected]553ee5ae2014-04-22 00:19:192// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Mikel Astiz055d1fc2024-07-30 10:43:595#ifndef COMPONENTS_SYNC_SERVICE_SYNC_ENGINE_FACTORY_H_
6#define COMPONENTS_SYNC_SERVICE_SYNC_ENGINE_FACTORY_H_
[email protected]553ee5ae2014-04-22 00:19:197
dchengb21a1b12016-04-21 19:23:138#include <memory>
skym9dbfbcf2015-10-09 18:44:339#include <string>
10
Marc Treibd2917512024-05-16 11:24:5811namespace signin {
12class GaiaIdHash;
Mikel Astiz055d1fc2024-07-30 10:43:5913} // namespace signin
Marc Treibd2917512024-05-16 11:24:5814
zea5758a242015-08-18 05:06:2015namespace syncer {
[email protected]553ee5ae2014-04-22 00:19:1916
maxbogue6dcda762016-12-05 20:45:5617class SyncEngine;
Rushan Suleymanovd5c5ef52020-07-30 13:07:2418class SyncInvalidationsService;
zea9276f212015-08-29 01:35:0319
Mikel Astiz055d1fc2024-07-30 10:43:5920// 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.
25class SyncEngineFactory {
[email protected]553ee5ae2014-04-22 00:19:1926 public:
Mikel Astiz055d1fc2024-07-30 10:43:5927 virtual ~SyncEngineFactory() = default;
[email protected]0ae5be32014-05-20 06:14:5428
Victor Hugo Vianna Silvacb403cff2024-09-12 08:06:3429 // 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 Treibf699c4d2018-05-11 11:42:0533 virtual std::unique_ptr<SyncEngine> CreateSyncEngine(
zea9276f212015-08-29 01:35:0334 const std::string& name,
Marc Treibd2917512024-05-16 11:24:5835 const signin::GaiaIdHash& gaia_id_hash,
Rushan Suleymanov137294e2023-01-05 11:29:0136 SyncInvalidationsService* sync_invalidation_service) = 0;
Victor Hugo Vianna Silva29c30192020-10-15 18:54:0437
Mikel Astiz527d0a1e2023-09-22 12:05:3538 // 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 Treibd2917512024-05-16 11:24:5842 virtual bool HasTransportDataIncludingFirstSync(
43 const signin::GaiaIdHash& gaia_id_hash) = 0;
Mikel Astiz527d0a1e2023-09-22 12:05:3544
Marc Treibd2917512024-05-16 11:24:5845 // 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]553ee5ae2014-04-22 00:19:1953};
54
maxbogue7e006db2016-10-03 19:48:2855} // namespace syncer
[email protected]553ee5ae2014-04-22 00:19:1956
Mikel Astiz055d1fc2024-07-30 10:43:5957#endif // COMPONENTS_SYNC_SERVICE_SYNC_ENGINE_FACTORY_H_