device_info_sync_service_impl.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2019 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_DEVICE_INFO_DEVICE_INFO_SYNC_SERVICE_IMPL_H_
  5. #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_SERVICE_IMPL_H_
  6. #include <memory>
  7. #include "base/memory/raw_ptr.h"
  8. #include "components/sync/invalidations/fcm_registration_token_observer.h"
  9. #include "components/sync/invalidations/interested_data_types_handler.h"
  10. #include "components/sync/model/model_type_store.h"
  11. #include "components/sync_device_info/device_info_sync_service.h"
  12. namespace syncer {
  13. class DeviceInfoPrefs;
  14. class DeviceInfoSyncClient;
  15. class DeviceInfoSyncBridge;
  16. class MutableLocalDeviceInfoProvider;
  17. class SyncInvalidationsService;
  18. class DeviceInfoSyncServiceImpl : public DeviceInfoSyncService,
  19. public FCMRegistrationTokenObserver,
  20. public InterestedDataTypesHandler {
  21. public:
  22. // |local_device_info_provider| must not be null.
  23. // |device_info_prefs| must not be null.
  24. // |device_info_sync_client| must not be null and must outlive this object.
  25. // |sync_invalidations_service| can be null if sync invalidations are
  26. // disabled.
  27. DeviceInfoSyncServiceImpl(
  28. OnceModelTypeStoreFactory model_type_store_factory,
  29. std::unique_ptr<MutableLocalDeviceInfoProvider>
  30. local_device_info_provider,
  31. std::unique_ptr<DeviceInfoPrefs> device_info_prefs,
  32. std::unique_ptr<DeviceInfoSyncClient> device_info_sync_client,
  33. SyncInvalidationsService* sync_invalidations_service);
  34. DeviceInfoSyncServiceImpl(const DeviceInfoSyncServiceImpl&) = delete;
  35. DeviceInfoSyncServiceImpl& operator=(const DeviceInfoSyncServiceImpl&) =
  36. delete;
  37. ~DeviceInfoSyncServiceImpl() override;
  38. // DeviceInfoSyncService implementation.
  39. LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() override;
  40. DeviceInfoTracker* GetDeviceInfoTracker() override;
  41. base::WeakPtr<ModelTypeControllerDelegate> GetControllerDelegate() override;
  42. void RefreshLocalDeviceInfo() override;
  43. // FCMRegistrationTokenObserver implementation.
  44. void OnFCMRegistrationTokenChanged() override;
  45. // InterestedDataTypesHandler implementation.
  46. void OnInterestedDataTypesChanged() override;
  47. void SetCommittedAdditionalInterestedDataTypesCallback(
  48. base::RepeatingCallback<void(const ModelTypeSet&)> callback) override;
  49. // KeyedService overrides.
  50. void Shutdown() override;
  51. private:
  52. std::unique_ptr<DeviceInfoSyncClient> device_info_sync_client_;
  53. std::unique_ptr<DeviceInfoSyncBridge> bridge_;
  54. const raw_ptr<SyncInvalidationsService> sync_invalidations_service_;
  55. };
  56. } // namespace syncer
  57. #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_INFO_SYNC_SERVICE_IMPL_H_