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