syncable_service_based_model_type_controller.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2018 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_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_
  5. #define COMPONENTS_SYNC_DRIVER_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_
  6. #include <memory>
  7. #include "base/memory/weak_ptr.h"
  8. #include "components/sync/base/model_type.h"
  9. #include "components/sync/driver/model_type_controller.h"
  10. #include "components/sync/model/model_type_store.h"
  11. namespace syncer {
  12. class SyncableService;
  13. // Controller responsible for integrating legacy data type implementations
  14. // (SyncableService) within the new sync architecture (USS), for types living on
  15. // the UI thread.
  16. class SyncableServiceBasedModelTypeController : public ModelTypeController {
  17. public:
  18. enum class DelegateMode { kFullSyncModeOnly, kTransportModeWithSingleModel };
  19. // |syncable_service| may be null in tests. If |use_transport_mode| is true,
  20. // two delegates are created: one for full sync and one for transport only.
  21. // Otherwise, only the full sync delegate is created.
  22. SyncableServiceBasedModelTypeController(
  23. ModelType type,
  24. OnceModelTypeStoreFactory store_factory,
  25. base::WeakPtr<SyncableService> syncable_service,
  26. const base::RepeatingClosure& dump_stack,
  27. DelegateMode delegate_mode = DelegateMode::kFullSyncModeOnly);
  28. SyncableServiceBasedModelTypeController(
  29. const SyncableServiceBasedModelTypeController&) = delete;
  30. SyncableServiceBasedModelTypeController& operator=(
  31. const SyncableServiceBasedModelTypeController&) = delete;
  32. ~SyncableServiceBasedModelTypeController() override;
  33. private:
  34. // Delegate owned by this instance; delegate instances passed to the base
  35. // class forward their calls to |delegate_|.
  36. std::unique_ptr<ModelTypeControllerDelegate> delegate_;
  37. };
  38. } // namespace syncer
  39. #endif // COMPONENTS_SYNC_DRIVER_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_