non_ui_syncable_service_based_model_type_controller.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_NON_UI_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_
  5. #define COMPONENTS_SYNC_DRIVER_NON_UI_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_
  6. #include "base/callback_forward.h"
  7. #include "base/memory/scoped_refptr.h"
  8. #include "base/memory/weak_ptr.h"
  9. #include "base/task/sequenced_task_runner.h"
  10. #include "components/sync/base/model_type.h"
  11. #include "components/sync/driver/model_type_controller.h"
  12. #include "components/sync/model/model_type_store.h"
  13. namespace syncer {
  14. class SyncableService;
  15. // Controller responsible for integrating legacy data type implementations
  16. // (SyncableService) within the new sync architecture (USS), for types living
  17. // outside the UI thread.
  18. // This requires interacting with the SyncableService in a model thread that is
  19. // not the UI thread, including the construction and destruction of objects
  20. // (most notably SyncableServiceBasedBridge) in the model thread as specified
  21. // in the constructor.
  22. class NonUiSyncableServiceBasedModelTypeController
  23. : public ModelTypeController {
  24. public:
  25. using SyncableServiceProvider =
  26. base::OnceCallback<base::WeakPtr<syncer::SyncableService>()>;
  27. // |syncable_service_provider| and |store_factory| will be run on the backend
  28. // sequence, i.e. |task_runner|.
  29. // |allow_transport_mode| will sync the data in both full-sync mode and in
  30. // transport-only mode.
  31. NonUiSyncableServiceBasedModelTypeController(
  32. ModelType type,
  33. OnceModelTypeStoreFactory store_factory,
  34. SyncableServiceProvider syncable_service_provider,
  35. const base::RepeatingClosure& dump_stack,
  36. scoped_refptr<base::SequencedTaskRunner> task_runner,
  37. bool allow_transport_mode = false);
  38. NonUiSyncableServiceBasedModelTypeController(
  39. const NonUiSyncableServiceBasedModelTypeController&) = delete;
  40. NonUiSyncableServiceBasedModelTypeController& operator=(
  41. const NonUiSyncableServiceBasedModelTypeController&) = delete;
  42. ~NonUiSyncableServiceBasedModelTypeController() override;
  43. };
  44. } // namespace syncer
  45. #endif // COMPONENTS_SYNC_DRIVER_NON_UI_SYNCABLE_SERVICE_BASED_MODEL_TYPE_CONTROLLER_H_