interested_data_types_manager.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2020 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_INVALIDATIONS_INTERESTED_DATA_TYPES_MANAGER_H_
  5. #define COMPONENTS_SYNC_INVALIDATIONS_INTERESTED_DATA_TYPES_MANAGER_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. #include "base/sequence_checker.h"
  9. #include "components/sync/base/model_type.h"
  10. #include "components/sync/invalidations/sync_invalidations_service.h"
  11. namespace syncer {
  12. class InterestedDataTypesHandler;
  13. // Manages for which data types are invalidations sent to this device.
  14. class InterestedDataTypesManager {
  15. public:
  16. InterestedDataTypesManager();
  17. ~InterestedDataTypesManager();
  18. InterestedDataTypesManager(const InterestedDataTypesManager&) = delete;
  19. InterestedDataTypesManager& operator=(const InterestedDataTypesManager&) =
  20. delete;
  21. // Set the interested data types change handler. |handler| can be nullptr to
  22. // unregister any existing handler. There can be at most one handler.
  23. void SetInterestedDataTypesHandler(InterestedDataTypesHandler* handler);
  24. // Get the interested data types. Returns nullopt if SetInterestedDataTypes()
  25. // has never been called.
  26. absl::optional<ModelTypeSet> GetInterestedDataTypes() const;
  27. // Set interested data types. The first call of the method initializes this
  28. // object.
  29. void SetInterestedDataTypes(const ModelTypeSet& data_types);
  30. void SetCommittedAdditionalInterestedDataTypesCallback(
  31. SyncInvalidationsService::InterestedDataTypesAppliedCallback callback);
  32. private:
  33. SEQUENCE_CHECKER(sequence_checker_);
  34. raw_ptr<InterestedDataTypesHandler> interested_data_types_handler_ = nullptr;
  35. absl::optional<ModelTypeSet> data_types_;
  36. };
  37. } // namespace syncer
  38. #endif // COMPONENTS_SYNC_INVALIDATIONS_INTERESTED_DATA_TYPES_MANAGER_H_