model_type_store_service_impl.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_MODEL_MODEL_TYPE_STORE_SERVICE_IMPL_H_
  5. #define COMPONENTS_SYNC_MODEL_MODEL_TYPE_STORE_SERVICE_IMPL_H_
  6. #include "base/files/file_path.h"
  7. #include "base/memory/scoped_refptr.h"
  8. #include "base/sequence_checker.h"
  9. #include "base/task/sequenced_task_runner.h"
  10. #include "components/sync/model/model_type_store.h"
  11. #include "components/sync/model/model_type_store_service.h"
  12. namespace syncer {
  13. class ModelTypeStoreBackend;
  14. // Handles the shared resources for ModelTypeStore and related classes,
  15. // including a shared background sequence runner.
  16. class ModelTypeStoreServiceImpl : public ModelTypeStoreService {
  17. public:
  18. // |base_path| represents the profile's path.
  19. explicit ModelTypeStoreServiceImpl(const base::FilePath& base_path);
  20. ModelTypeStoreServiceImpl(const ModelTypeStoreServiceImpl&) = delete;
  21. ModelTypeStoreServiceImpl& operator=(const ModelTypeStoreServiceImpl&) =
  22. delete;
  23. ~ModelTypeStoreServiceImpl() override;
  24. // ModelTypeStoreService:
  25. const base::FilePath& GetSyncDataPath() const override;
  26. RepeatingModelTypeStoreFactory GetStoreFactory() override;
  27. scoped_refptr<base::SequencedTaskRunner> GetBackendTaskRunner() override;
  28. private:
  29. // The path to the base directory under which sync should store its
  30. // information.
  31. const base::FilePath sync_path_;
  32. // Subdirectory where ModelTypeStore persists the leveldb database.
  33. const base::FilePath leveldb_path_;
  34. // The backend sequence or thread.
  35. const scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
  36. // Constructed on the UI thread, used on |backend_task_runner_| and destroyed
  37. // on any sequence.
  38. const scoped_refptr<ModelTypeStoreBackend> store_backend_;
  39. SEQUENCE_CHECKER(ui_sequence_checker_);
  40. };
  41. } // namespace syncer
  42. #endif // COMPONENTS_SYNC_MODEL_MODEL_TYPE_STORE_SERVICE_IMPL_H_