sync_client.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2015 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. #ifndef COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_
  5. #define COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_
  6. #include "base/files/file_path.h"
  7. #include "base/memory/ref_counted.h"
  8. #include "components/sync/base/extensions_activity.h"
  9. #include "components/sync/base/model_type.h"
  10. #include "components/sync/driver/data_type_controller.h"
  11. class PrefService;
  12. namespace invalidation {
  13. class InvalidationService;
  14. } // namespace invalidation
  15. namespace signin {
  16. class IdentityManager;
  17. }
  18. namespace syncer {
  19. class SyncApiComponentFactory;
  20. class SyncInvalidationsService;
  21. class SyncService;
  22. class SyncTypePreferenceProvider;
  23. class TrustedVaultClient;
  24. // Interface for clients of the Sync API to plumb through necessary dependent
  25. // components. This interface is purely for abstracting dependencies, and
  26. // should not contain any non-trivial functional logic.
  27. //
  28. // Note: on some platforms, getters might return nullptr. Callers are expected
  29. // to handle these scenarios gracefully.
  30. class SyncClient {
  31. public:
  32. SyncClient() = default;
  33. SyncClient(const SyncClient&) = delete;
  34. SyncClient& operator=(const SyncClient&) = delete;
  35. virtual ~SyncClient() = default;
  36. // Returns the current profile's preference service.
  37. virtual PrefService* GetPrefService() = 0;
  38. virtual signin::IdentityManager* GetIdentityManager() = 0;
  39. // Returns the path to the folder used for storing the local sync database.
  40. // It is only used when sync is running against a local backend.
  41. virtual base::FilePath GetLocalSyncBackendFolder() = 0;
  42. // Returns a vector with all supported datatypes and their controllers.
  43. virtual DataTypeController::TypeVector CreateDataTypeControllers(
  44. SyncService* sync_service) = 0;
  45. virtual invalidation::InvalidationService* GetInvalidationService() = 0;
  46. virtual syncer::SyncInvalidationsService* GetSyncInvalidationsService() = 0;
  47. virtual TrustedVaultClient* GetTrustedVaultClient() = 0;
  48. virtual scoped_refptr<ExtensionsActivity> GetExtensionsActivity() = 0;
  49. // Returns the current SyncApiComponentFactory instance.
  50. virtual SyncApiComponentFactory* GetSyncApiComponentFactory() = 0;
  51. // Returns the preference provider, or null if none exists.
  52. virtual SyncTypePreferenceProvider* GetPreferenceProvider() = 0;
  53. // Notifies the client that local sync metadata in preferences has been
  54. // cleared.
  55. // TODO(crbug.com/1137346): Replace this mechanism with a more universal one,
  56. // e.g. using SyncServiceObserver.
  57. virtual void OnLocalSyncTransportDataCleared() = 0;
  58. };
  59. } // namespace syncer
  60. #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_