model_type_connector_proxy.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_ENGINE_MODEL_TYPE_CONNECTOR_PROXY_H_
  5. #define COMPONENTS_SYNC_ENGINE_MODEL_TYPE_CONNECTOR_PROXY_H_
  6. #include <memory>
  7. #include "base/memory/weak_ptr.h"
  8. #include "base/task/sequenced_task_runner.h"
  9. #include "components/sync/base/model_type.h"
  10. #include "components/sync/engine/model_type_connector.h"
  11. namespace syncer {
  12. // Proxies all ModelTypeConnector calls to another thread. Typically used by
  13. // the SyncBackend to call from the UI thread to the real ModelTypeConnector on
  14. // the sync thread.
  15. class ModelTypeConnectorProxy : public ModelTypeConnector {
  16. public:
  17. ModelTypeConnectorProxy(
  18. const scoped_refptr<base::SequencedTaskRunner>& task_runner,
  19. const base::WeakPtr<ModelTypeConnector>& model_type_connector);
  20. ~ModelTypeConnectorProxy() override;
  21. // ModelTypeConnector implementation
  22. void ConnectDataType(
  23. ModelType type,
  24. std::unique_ptr<DataTypeActivationResponse> activation_response) override;
  25. void DisconnectDataType(ModelType type) override;
  26. void SetProxyTabsDatatypeEnabled(bool enabled) override;
  27. private:
  28. // A SequencedTaskRunner representing the thread where the ModelTypeConnector
  29. // lives.
  30. scoped_refptr<base::SequencedTaskRunner> task_runner_;
  31. // The ModelTypeConnector this object is wrapping.
  32. base::WeakPtr<ModelTypeConnector> model_type_connector_;
  33. };
  34. } // namespace syncer
  35. #endif // COMPONENTS_SYNC_ENGINE_MODEL_TYPE_CONNECTOR_PROXY_H_