sync_api_component_factory.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2014 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_SYNC_API_COMPONENT_FACTORY_H_
  5. #define COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_
  6. #include <memory>
  7. #include <string>
  8. #include "components/sync/base/model_type.h"
  9. #include "components/sync/driver/data_type_controller.h"
  10. namespace invalidation {
  11. class InvalidationService;
  12. } // namespace invalidation
  13. namespace syncer {
  14. class DataTypeEncryptionHandler;
  15. class DataTypeManager;
  16. class DataTypeManagerObserver;
  17. class ModelTypeConfigurer;
  18. class SyncEngine;
  19. class SyncInvalidationsService;
  20. // This factory provides sync driver code with the model type specific sync/api
  21. // service (like SyncableService) implementations.
  22. class SyncApiComponentFactory {
  23. public:
  24. virtual ~SyncApiComponentFactory() = default;
  25. virtual std::unique_ptr<DataTypeManager> CreateDataTypeManager(
  26. const DataTypeController::TypeMap* controllers,
  27. const DataTypeEncryptionHandler* encryption_handler,
  28. ModelTypeConfigurer* configurer,
  29. DataTypeManagerObserver* observer) = 0;
  30. // Creating this in the factory helps us mock it out in testing. |invalidator|
  31. // and |sync_invalidation_service| are different invalidations. SyncEngine
  32. // handles incoming invalidations from both of them (if provided).
  33. // |sync_invalidation_service| is a new sync-specific invalidations service
  34. // and it may be nullptr if it is disabled or not supported. In future, there
  35. // will leave only one invalidation service.
  36. virtual std::unique_ptr<SyncEngine> CreateSyncEngine(
  37. const std::string& name,
  38. invalidation::InvalidationService* invalidator,
  39. syncer::SyncInvalidationsService* sync_invalidation_service) = 0;
  40. // Clears all local transport data. Upon calling this, the deletion is
  41. // guaranteed to finish before a new engine returned by |CreateSyncEngine()|
  42. // can do any proper work.
  43. virtual void ClearAllTransportData() = 0;
  44. };
  45. } // namespace syncer
  46. #endif // COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_